Unet / ResNet, training a model for image segmentation. This is the dataloader I have now:
def src_get_label(fn):
label_name = src_dataset / "GT" / f"{fn.stem}_GT.png"
return label_name
src_datablock = DataBlock(
blocks=(ImageBlock, MaskBlock),
get_items=get_image_files,
get_y=src_get_label,
splitter=RandomSplitter(seed=42),
item_tfms=Resize(size=input_image_size, method="squish"),
batch_tfms=aug_transforms(),
)
src_dataloader = src_datablock.dataloaders(
src_dataset / "original", path=src_dataset, bs=src_batch_size
)
In most cases, each image file in the dataset has exactly one mask file. In some cases, an image file will have multiple mask files, each mask highlighting a different object in the image. I can tell by the filenames which masks are assigned to each image - that’s not the problem.
The problem is - how do I merge multiple mask files into a single mask structure in the dataloader? I can identify the mask files just fine, I just don’t know where to begin to merge them.
The masks have a single category, so in principle merging could be as simple as generating the union of the regions of interest. I could do that myself, if I had access to the mask structures as arrays or something - that’s the part I don’t know.
(I’m still pretty new to FastAI.)