Learn.predict() vs learn.predict_array()

I have a confusion when we do learn.predict how are images read from the test directory (orderwise) is there a way to know.The reason asking is because on a particular dataset when i use learn.predict on test set it only gives me an accuracy of about 6% but when i read in the image manually in order
and use learn.predict_array and then combine the results ,i get an accuracy 94%.The images in my test set have numbers from 1 to 8000.The same goes for learn.TTA on test set

2 Likes
  • learn.predict(): predict using validation dataloader, val_dl. The function iterate the validation set by batches and make predictions by calling the model.
  • learn.predict_array(): predict using a specific (single) image.
  • learn.TTA(): predict with Test Time Augmentation (TTA). Additional to the original test/validation images, apply image augmentation to them (just like for training images) and calculate the mean of predictions.

Inspect the validation dataloader. It’s a Python iterator, so you can write code to iterate over it.

1 Like

So to check which images are being used ,i think we can iterate over data.trn_ds specifically data.trn_ds.fnames_ to see the image names that are being loaded in a particular batch

Currently learn.predict(img) gives the predicted class, index and the probabilities.

Is there any direct way of getting the class/label of the top three predictions/probability?

Or is the only option is to get the output.topk(3) and use it to find the corresponding class/label?