How do you create an image segmentation data_block with lists of paths?

I’m trying to create a data_block using 4 lists of ordered paths.
List 1: paths to the training data
List 2: paths to the validation data
List 3: paths to the training segmentation labels (mask images)
List 4: paths to the validation segmentation labels (mask images)

I feel like I’m finding answers in the API documentation that gets me right to edge of what I’m looking for but nothing quite gets me right there. My workaround is that I re-name and folder my data to work with what I see in the API but it feels like there is a built-in way to do what I want I’m just not finding it. Thanks in advanced.

So I was able to get some code that functioned:

train = SegmentationItemList(train_data_paths)
valid = SegmentationItemList(valid_data_paths)
# train_label = SegmentationLabelList(train_label_paths)
# valid_label = SegmentationLabelList(valid_label_paths)
src = (SegmentationItemList.from_folder(data_root)
        .split_by_list(train=train, valid=valid)
        .label_from_lists(train_labels=train_label_paths, valid_labels=valid_label_paths, classes=codes))

data = (src.transform(zoom_crop(scale=1.25), size=size, tfm_y=True)

But this just left me with more questions:

  1. Why do I need to use SegmentationItem lists to create objects for my training data but it crashes (first fills up 75 gis of memory then crashes) with a “‘ImageSegment’ object has no attribute ‘read’” error when I try to use SegmentationLabelLists for the label data?
  2. How do I use both a zoom_crop and get_transformation transformation src.transformation() function?

I think i find a way can help your problem

src = (SegmentationItemList.from_folder(path_img)
#        .split_by_folder(train='img', valid='valid')
       .label_from_func(get_y_fn, classes=codes))

src_valid = (SegmentationItemList.from_folder(valid_path_img)
       .label_from_func(valid_get_y_fn, classes=codes))

src.valid = src_valid.train

data = (src.transform(get_transforms(), size=size, tfm_y=True)
#         .add_test_folder()   
1 Like

Hi, I was wondering what is the definition for the function valid_get_y_fn and is it different from the function get_y_fn?