Hello developers.
Using fastai v1, I would like to construct a DataBunch for image segmentation training. However the masks will not be taken from image files. Rather, the y-mask will be constructed by my own function given the x filename as a parameter.
Please show me the right way to do this using the data block API. I understand how to return a mask filename label given the image filename, but not how to hook into the datablock API to return the mask image itself.
Here’s what I have so far:
src = SegmentationItemList.from_csv(num_workers=0, seed=rseed, csv_name='train_labels.csv', suffix='.tif', path=DATA, folder='train', test='test', ds_tfms=tfms, bs=BATCH_SIZE, size=ORIGIMSIZE)
data = (src
.random_split_by_pct()
# .label_from_func(get_y_fn, classes=codes)
.databunch(bs=BATCH_SIZE, path=DATA, num_workers=0)
.normalize(imagenet_stats))
Also, it would help to know where to specify num_workers=0. data.show_batch() seems to use 4 workers regardless of num_workers=0.
Thanks for your help.