I am looking for an OCR pretrained model that works with pytorch. I tried https://github.com/clovaai/CRAFT-pytorch, but it is not supported on pytorch hub. And I cannot load pth model, because it has only weights. How to load model?
My first model is a yolov5 model trained on custom data, so it should crop an image and send it to the next model. The next model should be OCR, mostly digit recognition. But I can't run craft-pytorch
model = torch.hub.load('.', 'custom', path='runs/train/exp2/weights/best.pt', source='local', force_reload=True)
# It throws an error with pytorch hub
model_ocr = torch.hub.load('clovaai/CRAFT-pytorch', 'craft_mlt_25k.pth')
# Tried with torch load, but pth files have only weights not model
ocr_model = torch.load('runs/ocr/craft_mlt_25k.pth')
cap = cv2.VideoCapture('../Dataset/test/09-10.mp4')
while(cap.isOpened()):
ret, frame = cap.read()
results = model(frame)
crops = results.crop(save=False)
for crop in crops:
if 'number' in crop['label']:
ocr_result = model_ocr(crop['im'])
ocr_crop = ocr_result.crop(save=False)