Hello,
I am using the detectron2 model. Using Google Colab, I have trained and tested the custom dataset and downloaded the config and pth file to local. I am facing an issue with inference. trained weight file not returning bounding box value it gives empty result.
Can you guide me to find out issue.
Thanks in advance.
@app.post('/api/ocr/table')
async def predict_api(file: UploadFile = File(...)):
fp = Path((r'{}data/input/img.png').format(uri))
imgjson = ''
async with aiofiles.open(fp, 'wb') as fh:
while True:
chunk = await file.read(CHUNK_SIZE)
if not chunk:
break
await fh.write(chunk)
img_path = fp
image1 = cv2.imread((f'{img_path}').format(uri))
cfg = get_cfg()
cfg.merge_from_file((r"{}Detectron2_model/config.yml").format(uri))"""
cfg.MODEL.ROI_HEADS.SCORE_THRESH_TEST = 0.8
cfg.MODEL.ROI_HEADS.NUM_CLASSES = 2
cfg.MODEL.WEIGHTS = (r"{}Detectron2_model/model_final.pth").format(uri)
predictor = DefaultPredictor(cfg)
outputs = predictor(image1)
return {"details":"saved", "result": outputs }
Response:
{
"details": "saved",
"result": {
"instances": {
"_image_size": [
3301,
2550
],
"_fields": {
"pred_boxes": {
"tensor": {}
},
"scores": {},
"pred_classes": {}
}
}
}
}