Get the prediction on a specific image after training
Links :
- Code from @jeremy
- Use
val_tfms
instead oftrn_tfms
- use the learn.load command to load a set and then the code below to get a prediction
- Another possibility is to make a test folder and put your image there
- Only way to use TTA to get prediction on a specific image is to put her in a test set
- Using open_image
Code (fn is the file name of the image) :
trn_tfms,val_tfms = tfms_from_model(arch, sz, aug_tfms=transforms_side_on, max_zoom=1.1)
img = open_image(PATH+fn)
im = val_tfms(img)
pred = learn.predict_array(im[None])
result = np.argmax(preds, axis=0)
print(f'The class is : {data.classes[result[0]]}')
plt.imshow(img)