bears = DataBlock(
blocks=(ImageBlock, CategoryBlock),
get_items=get_image_files,
splitter=RandomSplitter(valid_pct=0.20, seed=42),
get_y= ## How do I custom read my labels??,
item_tfms=Resize(128))
This assumes images and labels are in a directory structure like
/bears/images/[images here]
/bears/labels/[labels here]
def get_y(x):
return (str(x).replace('images','labels')) #<== or custom code to get your equivalent label for the image
bears = DataBlock(
... get_y=get_y, ...
or
this assumes the ‘path’ variable is loaded with ‘/bears’ directory
Ok thanks so , I can just code my own function and say get_y=My_Function(x)
Do I have to give the input, in your example you define def get_y(x): , but in the Datablock you say get_y=get_y . Should I say get_y=get_y(x) instead???