Fastai - GrandparentSplitter - test/valid data not selected

12 Views Asked by At

I have manually split my data into train and test sets. This is how my data directory looks like.

pothole_or_not/
   test/
   train/
     pothole/
     road/

And this is my datablock:

dls = DataBlock(
    blocks=(ImageBlock, CategoryBlock),
    get_items=get_image_files,
    splitter=GrandparentSplitter(train_name='train', valid_name='test'),
    get_y=parent_label,
    item_tfms=[Resize(192, method='squish')]
).dataloaders(path)

print(f"Train paths: {dls.train.items}")
print(f"Test paths: {dls.valid.items}")

After training the model, the "valid_loss" and "metric" sections are all "None" which suggests that the test data was not included in the training. The test directory contains just the images; the images are not in any sub-directories like the train directory. I also get a warning which says "Your generator is empty". What do I do? I have been stuck on this for a while. Thank you.

I was expecting the model to train successfully since my directory structures follow what has to be done to be able to use the GrandparentSplitter.

0

There are 0 best solutions below