This seems so simple yet I can’t quite figure out what the best solution would be…
Here is what happened. I created a callback that normalizes input images (very similar to
norm_imagenette which normalizes a batch during
begin_batch phase). The learner trains great and I saved the model’s
state_dict. Then when it was time to do an inference using the saved model, it was not performing as I would have expected. After hours of poking around, I realized the obvious. The input to the model did not get normalized by the callback like the training/validation set did because the model’s
forward function was called directly with a user’s input image.
Now I am contemplating whether I should have put the normalization mechanism in the model’s forward method (that way, the input is always normalized). If this was discussed in the class, I totally missed it and I feel silly for it.