I have two models, first one is for classifying images and crop to classes.
After cropping classes from an image I send it to the second model, which classifies digits.
Both of them Yolo v5 models.
But the problem is that I can't send the second one directly from GPU.
First I need to crop, I will get a NumPy array. After receiving the NumPy array I send it to the second one.
I want to stop losing time on converting to NumPy to tensor and vice-versa
model = torch.hub.load('.', 'custom', path=img_cls_path, source='local', force_reload=True)
model_ocr = torch.hub.load('.', 'custom', path=ocr_path, source='local', force_reload=True)
cap = cv2.VideoCapture(some_video_path)
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)
How to combine two models?