well after much researching and trying i finally got it to work. I must say that the
get_image_files(path, recurse=True, folders=None)
does not work or (very plausible) I do not get the usage.
My solution, I hope it will help others.
get_my_images simply creates a list of my images
def get_my_images(data_dir=data_dir, folders=[‘train/images’, ‘val/images’]):
res =
for d in folders:
for f in os.listdir(data_dir/f’{d}'):
res.append(Path(os.path.join(data_dir, d, f)))return L(res)
assigns labels (masks)
def label_func(x):
if '/images/' in str(x): x = str(x).replace('/images/','/masks/').replace('.png','_masks.png') return Path(x)
datablock does not need a splitter
db = DataBlock(blocks=(ImageBlock(),MaskBlock(codes)),
get_items=partial(get_my_images),
get_y=label_func,
item_tfms=[Resize(im_size)],
batch_tfms= [
*aug_transforms(),
Normalize.from_stats(*imagenet_stats)],
)
ds = db.datasets(source=data_dir)
dls = db.dataloaders(data_dir, bs = bs)