Help on SegmentationItemList

Hi Guys,

I was working on replicating the Image Segmention task on the TGS Salt segmentation challenge on kaggle. (
When trying to get the databunch, I ran into an error in getting the src right.

src = (SegmentationItemList.from_folder(train_images, extensions=".png")

where train_images is the path for the train images and
get_y_fn provides the labels (the segmented images)

The above code segment generates the following error:

/opt/anaconda3/lib/python3.7/site-packages/fastai/vision/ in process(self, ds)![41%20AM|558x500]
    355     "`PreProcessor` that stores the classes for segmentation."
    356     def __init__(self, ds:ItemList): self.classes = ds.classes
--> 357     def process(self, ds:ItemList):  ds.classes,ds.c = self.classes,len(self.classes)

359 class SegmentationLabelList(ImageItemList):

TypeError: object of type ‘NoneType’ has no len().

I tried to trace out the hierarchy of the objects and was not able to understand what went wrong. The same piece of code works well for ImageItemList class.

Any direction would be a great help!


1 Like

I think you need to add classes in label_from_func

your_classes = # should be a list with your class names eg:  ['cat', 'dog', 'pig'...]
.label_from_func(get_y_path, classes=your_clases)

Thanks so much Renato! Adding classes fixed the problem.

Yes, add a “background” class is OK