I used a pretrained Resnet34 model to classify images of 10 species of monkeys that I obtained from a Kaggle Dataset
Even though I achieved an accuracy of 99.6% on the validation (272 images), I still got incorrect labels for every single image that I predicted individually.
img=plt.imread(f'{PATH}validation/n5/{files[7]}') plt.imshow(img) img=tfms[1](img) preds=learn.predict_array(img[None]) print(preds) print(df[df.Label==data.classes[np.argmax(preds)]]['Common Name'])
I initially used the plt.imread() method to read the numpy.array of the image. This was then transformed using val_tfms(as it normally should) and fed into the model for prediction. When I replaced that with fast ai’s open_image() function instead…
img=open_image(f'{PATH}validation/n5/{files[7]}')
I got every label right. So what’s the difference between the two?