Beginner Question: How to predict on Test Set

Hi guys,
Context: DogBreedClassifier
I am new to DL. I have trained my model and saved my weights.
Now I want to use this model to predict on Test Folder, and update my submission.csv file.
Thanks in Advance

1 Like

def split_data_add_test_folder(self, test_folder:str=‘test’, label:Any=None):
“Add test set containing items from folder test_folder and an arbitrary label”
items = ImageFileList.from_folder(self.path/test_folder)
return self.add_test(items, label=label)

SplitData.add_test_folder = split_data_add_test_folder.

We can add the test folder using this.

File Structure for my scenario



path = ‘data/train’
Also while defining the data I had to
data = ImageDataBunch.from_folder(path, train=‘train’, valid_pct=0.2, test=’…/test’, ds_tfms=tfms, size=224)
See here I had to define test = ‘…/input’,
somehow with path set at ‘data/’ I could not get the test_ds loaded.

1 Like

Should I be able to mix from types in the same databunch() API call? I have a dataframe input for my train/valid images and I want to use a folder for my test images. How should I approach this?

When you call add_test you can pass any ItemList so you can create your train/valid with ImageItemList.from_df then when you add the test set:


or even more direct: add_test_from_folder should work.


Thanks for the explanation, it works. But I could not able to retrieve the test image files name.

The test image filenames will be in data.test_ds.x.items.

When using the .add_test(…) approach, is the test data normalized automatically the same way as train data or does that have to be specified when adding the test itemlist?

Yes, anything that occurs to the validation set occurs to the test set here.