I get different inferences to result from my Image classifier. When I do inference on Pytorch as compared to fastai

When I use the pickle file of fastai and do prediction using learn.predict() method. And I use the same pickle file and convert that pickle file using this method to PyTorch. Below is the code snippet.

learn = load_learner(src_path,model_name)
import pickle
file = open(new_str, 'wb')
pickle.dump(var, file)
# close the file

And do the prediction using that generated pickle file in PyTorch but I get the different result as compared to fastai. What is the reason behind this I want to know? Am I doing the right way to convert that pickle file for PyTorch inference?

Hi, have you been able to figure this out?
I am also looking into training in fastai but then running inference in plain pytorch.

Fastai automatically applies the validation transforms. make sure you are using exactly the same transforms in your plain pytorch implementation. (I guess at least resize and normalization)


Basically what @florianl said. Remember that fastai runs center crop on the validation set as well


Thanks both! Makes sense.