Skip to content

Instantly share code, notes, and snippets.

@fabridigua
Created January 28, 2021 09:09
Digit prediction with a pretrained model
roi = cv2.resize(digit_image, (28, 28))
roi = roi.astype("float") / 255.0
roi = img_to_array(roi)
roi = np.expand_dims(roi, axis=0)
preds = self.model.predict(roi)
for c in self.exclude_classes:
preds[0][c] = 0
return preds.argmax(axis=1)[0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment