Rationale for .predict being a method of Image class rather than Learner?

The _predict method is defined in learner.py in the vision module and then bound to the Image class.

In general, I am curious as to why the predict method was exposed in the Image class as opposed to the Learner or ConvLearner class? It seems a lot more intuitive to expect a trained model in Learner to have a .predict() method that takes in an image (or array of Images) rather than to expect an Image class to have a .predict() method that takes in a learner object? Perhaps I am missing some subtle aspect of how things are implemented.


1 Like

Yes I agree - I was looking at this this morning and I think it’s a mistake. Unless @sgugger convinces me otherwise, expect to see this changed later today.

1 Like

Agree, it was a bit confusing for me as well when I was trying to run the model against custom data. If we take into account other frameworks, like, sklearn or keras, they always provide various prediction methods for their models.