Hi guys. I’ve used pyTorch to implement an EfficientNetB3 classifier that I have saved as ‘efficientNet_b3.pt’.
Now I would like to use this classsifier ad so what I do is:
- load the classifier in this way
classifier = torch.load(cls_path, map_location=torch.device('cpu'))
- then, reading a video in input, when I detect something that has to be classified, I take the Region of interest (ROI), I process that, and then I call the clasifier on it:
roi_resized = cv2.resize(roi, (300, 300)) # Right dimension for efficientNetB3
roi_resized = roi_resized / 255.0 # Normalization phase
roi_resized = roi_resized.reshape(1, 300, 300, 3)
# Classify
pred = classifier(torch.tensor(roi_resized, dtype=torch.float32))
But in this way, when there is something that needs to be classified, I get:
pred = classifier(torch.tensor(roi_resized, dtype=torch.float32))
TypeError: 'collections.OrderedDict' object is not callable
How can I resolve?