Can someone please help with pointers to good code for how to deploy segmentation models in inference?
For example, after training, I reload the pkl model and use the following: src = (SegmentationItemList.from_df(tst_df, path=tst_path, cols='filename').split_none()) data = src.databunch(bs=bs).normalize(imagenet_stats)
It gives the following error: Exception: Your data isn’t labeled, can’t turn it in a DataBunch yet!
I would like to use learn.get_preds to get inference predictions, but it requires a databunch to work?
I’ve been on the fastai tutorial for inference, but there’s very little information for segmentation predictions using learn.get_preds https://docs.fast.ai/tutorial.inference.html
Oh, that’s because you have transforms applied to your validation set. The fastai library returns this error to protect you (in a way) because transforms are usually irreversible and you might lose some part of your images in the test set which won’t have a proper mask. Plus the predicted mask will apply to the transformed image, not the original one.
If your images aren’t all of the same size, you’ll need to manually resize them to have the same size, then post-process your predictions accordingly, but you shouldn’t have transforms on your validation set.