【发布时间】:2021-10-11 18:10:07
【问题描述】:
我正在寻找与 pytorch 一起使用的 OCR 预训练模型。我试过https://github.com/clovaai/CRAFT-pytorch,但它在 pytorch hub 上不受支持。而且我无法加载 pth 模型,因为它只有权重。如何加载模型?
我的第一个模型是使用自定义数据训练的 yolov5 模型,因此它应该裁剪图像并将其发送到下一个模型。下一个模型应该是 OCR,主要是数字识别。但是我不能运行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)
【问题讨论】: