How to use the trained model on a new test set in an application

So I complete the 3rd lesson in Part 1, and learned how to train the model to classify my images.
What i want to know is, once i have trained my model, how do I use that model to perform classification of images on external test sets. For eg: I have trained my model using some train images and now I have, say a script which asks the user the directory of the test set, which i want to apply the model on.
Further after the classification, i’ll perform some operations based on the predictions.


  1. I believe, once i have trained the model, i can do:‘model_name’)
  2. Then every time, i want to predict on a test case, i can go learn.load (‘model_name’)
    and provide data.test_name = ‘test_directory_name’ (I saw that one of the parameters passes to the “ImageClassifierData.from_csv” function was “test_name”)
  3. I can further do a learn.predict(is_test=True) or learn.TTA(is_test=True), to get predictions.

Now a few doubts i have regarding this hypothesis is that-

  1. Will i have to define all the variables used in the learn object (data, tfms){created while training} in my script and then create a learn object or can i simply load the model into a new object variable and use its methods(if so, how?)
  2. Can i even use data.test_name to set the path for a different test case after the model is done training. [again, do i have to define “data” again in my script]

I may be missing something said during the lecture, but I am unable to find any relevant answer. Thanks for the help.


I had similar struggles with structured data and the Columnar model. It’s a different case so I’m not sure this helps you but the best way I’ve found so far to use my trained model and predict on new data is to pass that data from the same pre-processing (in my case that’s proc_df) that the training data went through. Passing them through a test set before training did not work in that case, since the target value was missing.


1 Like