I defined label_func function to return True when there is ‘_spl’ in path (meaning there is a split in the parcel) and False otherwise. As stated in the documentation, it accepts strings. I checked and the function does work. When I provide it with a str having ‘_spl’ - it returned True.
However, when I use the function in the dataloader it always returns False.
Code:
folders = os.listdir(MAIN)
folders = [f for f in folders if '_all' not in f and 'csv' not in f]
files = get_image_files(MAIN, folders=folders)
files = [f for f in files if '/bl_' not in str(f)]
random.shuffle(files)
def label_func(f):
return '_spl' in str(f)
dls = ImageDataLoaders.from_name_func(PRANAS, files, label_func=label_func, item_tfms=Resize(400))
dls.show_batch()
The first, second, fifth and sixth, eighth images should have True for labels.
Does anyone have an idea why it is so??