Hello,
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.
Hypothesis:
- I believe, once i have trained the model, i can do: learn.save(‘model_name’)
- 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”) - 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-
- 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?)
- 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.