fastai / course-v3

The 3rd edition of course.fast.ai
https://course.fast.ai/
Apache License 2.0
4.9k stars 3.55k forks source link

label_from_folder can't handle different directories #528

Open TJ-C opened 4 years ago

TJ-C commented 4 years ago

I was running Lesson 7 in a Kaggle notebook. My Images were in: /kaggle/input/the-oxfordiiit-pet-dataset/images My generated images were in: /kaggle/working/image_gen

When I came to run the following it only shows the images and not the generated images:

print(path)
/kaggle/input/the-oxfordiiit-pet-dataset

def get_crit_data(classes, bs, size):
    src = ImageList.from_folder(path, include=classes).split_by_rand_pct(0.1, seed=42)
    ll = src.label_from_folder(classes=classes)
    data = (ll.transform(get_transforms(max_zoom=2.), size=size)
           .databunch(bs=bs).normalize(imagenet_stats))
    data.c = 3
    return data

data_crit = get_crit_data([name_gen, 'images'], bs=bs, size=size)

So it appears the label function cannot traverse different directories, or is unable to except dir paths in the folder string, e.g. '/kaggle/output/working/image_gen'