Error using learner after adding test folder via datablock API

I’m trying to add a test folder to a trained learner using these steps:

  1. train learner, save stage
  2. load stage
  3. create new data object, this time invoking the add_test_folder api as well.
  4. assign this data to the original learner
  5. run learner.predict and interpretations on the test set

The last step runs into errors. I think I know why, but don’t know how to fix it. Here is how I added the test folder:

The only way I could get test folder to be added to test_ds was by placing it in the same location as the training/validation data, which was kdeftpath. But because I do label_from_folder, the new data object now has 1 additional label called “test”. This results in mismatch in sizes and indices between the original data/model and the interpretation on the new data block. Can someone please help me fix this?

This is the actual error I see when i try to create the Interpretation object:

I added a test set to a trained learner using following code and it works fine.
tfsm1 = get_transforms(do_flip=False)
test_df = (test_data.split_none().label_from_folder().transform(tfms1,size=224,).databunch(num_workers=4)).to_df()

Hmm. Which version of is this? I thought the preferred approach now is to use the datablock API to manipulate data. Not directly via databunches.

Anyone else using my approach and can help? If not, then I might use the hack above.

I am using 1.0.54 version.

Instead of add_test_folder you should be able to do add_test() and pass in an ImageList of your new items instead on your test path