I am working on a segmentation task, where my original images and masked images are in separate folder namely images and segmentation. I tried to build the DataBlock with the code,
Ok I think (not totally sure) that if your segmented images are in a separate folder, you need a label_func which can map from the input image path to the output image path.
def label_func(o):
""" takes in a file as found from `get_image_files`
and maps to the path name of the segmented image
"""
return Path("segmented_images") / o.name # or whatever is right for your directory setup.
DataBlock(blocks=(ImageBlock, ImageBlock),
splitter=RandomSplitter(0.2, seed=42),
get_items=get_image_files,
get_y=label_func,)
Trying out different things, but the pain point is I have my segmented images in a separate folder. Thanks for your answer, it really helps and now I was able to figure out where I was wrong.