Hi, this is Mukesh i am working on custom dataset for classification.got stucked Help me with this
notebook link
By giving the folder name as parent label image block takes the images of test not train folder. How to give y to train model on train dataset and test accordingly
The issue is that when you pass the dataset’s path to your DataBlock, fastai recursively finds every image under that path (in this case, every file under path/train/ and path/test) and splits them into training & validation sets randomly because of the RandomSplitter argument (meaning some images under path/test would likely be part of the training set, and some images under path/train would likely be part of the validation set). If you would like to have one DataLoaders whose training & validation sets are path/train/ and path/test/ respectively, you would do,
food = DataBlock(
blocks=(ImageBlock, CategoryBlock),
get_items=get_image_files,
# The following tells fastai to split training/validation based on
# folder names, where the training set's name is 'train',
# and the validation set's name is 'test'
splitter=GrandparentSplitter(train_name='train', valid_name='test'),
get_y=parent_label,
item_tfms=Resize(128),
)
# dls.train is the images under path/train/,
# dls.valid is the images under path/test/
dls = food.dataloaders(path)
Thank you very much Borna and thank you for the time, This is very much helpful. I just started week before for fast ai. This gives me motivation to move forward if i got stuck somewhere someone helps in the fastai commmunity.