Hello,
So I have trained a model using fastai 2, and with the new functionalities I’m not required to normalise my data myself during training, since cnn_learner
function takes care of that automatically when I pass my data in the function.
Now I have created a validation set of images my model has never seen and want to make predictions with learner.predict(img)
.
I create the model and load the saved weights from the previous training:
learner = cnn_learner(data, resnet50, metrics=accuracy) learner.load('weights')
Then I load an image, resize it and convert it to a numpy array:
img = PILImage.create('val_set/img1.jpg')
img = img.resize((224, 224))
img = np.array(img)
And I make the prediction: learner.predict(img)
The outcome is unfortunately wrong and predicts always the same class, regardless of what image I show it. I suppose it’s because I haven’t normalised the image, but since there’s no Normalize function in fastai 2 how should I go about it?
Any help is appreciated, thanks!