Adding labeled test set (Image Segmentation)

I’m new using Fast.ai. Currently I’m trying to apply fast.ai to an image segmentation problem that I have been facing through using Keras. I have created my custom ItemBase and ItemList classes and loaded train and validation datasets successfully. The problem that I’m facing now is how to add a custom labeled test set to databunch.

[1] data = ImageList.from_folder(…).split_by_valid_func(…).databunch() <- Here I have labeled train and valid set loaded.
[2] data.add_test(test_data) <- Here I add only the inputs of test set

What I’m missing?

Test sets are deliberately unlabeled by fast.ai. If you want to test the model on your test data:

data_test = ImageDataBunch.from_folder(
data,
valid_pct=0,
ds_tfms=test_tfms,
size=(336, 336),
num_workers=8,
bs=32).normalize(imagenet_stats)

After you’ve created your own ImageDataBunch, you can add that to your model after it’s finished its fitting by:

learn.validate(data_test.train_dl)

Considering learn is your learner and data_test is your ImageDataBunch. Have fun!

1 Like

@senecamanu right track, but the above won’t quite work. Please see my notebook and experiments here to see why :slight_smile:

2 Likes

Your examples are better!

1 Like