Segmentation dataset datablock api

Still learning how to use the data block API, and I have a segmentation dataset that is formatted like this:

images/
–train/<long_integer>.jpg
–val/<long_integer>.jpg
annotations/
–train/<matching_integer>.png
–val/<matching_integer>.png

Would anyone please help me out in setting up the data block api?

I could also modify the structure to this if it’s more straightforward:

train/
–images/<long_integer>.jpg
–annotations/<matching_integer>.png
valid/
–images/<long_integer>.jpg
–annotations/<matching_integer>.png

I think if I do it the second way I can start out like this:

data = (SegmentationItemList.from_folder(path)
        .split_by_folder()

But I’m getting hung up on how to set the labels.

Your first folder structure works. You just have to give as path the path where the images are and define an appropriate function that transforms your image path to a mask path.

Hence, your path is: root_path/‘images’