I am using the fastai library (fast.ai) to train an image classifier. The model created by fastai is actually a pytorch model.
type(model) <class 'torch.nn.modules.container.Sequential'> Now, I want to use this model from pytorch for inference. Here is my code so far:
torch.save(model,"./torch_model_v1") the_model = torch.load("./torch_model_v1") the_model.eval() # shows the entire network architecture Based on the example shown here: http://pytorch.org/tutorials/beginner/data_loading_tutorial.html#sphx-glr-beginner-data-loading-tutorial-py, I understand that I need to write my own data loading class which will override some of the functions in the Dataset class. But what is not clear to me is the transformations that I need to apply at test time? In particular, how do I normalize the images at test time?
Another question: is my approach of saving and loading the model in pytorch fine? I read in the tutorial here: http://pytorch.org/docs/master/notes/serialization.html that the approach that I have used is not recommended. The reason is not clear though.