I’m working on the Food-101 dataset and I’m trying to supply ImageDataBunch.from_folder() with a separate test set but for some reason, it doesn’t recognize it.
ImageDataBunch;
Train: LabelList (60600 items)
x: ImageList
Image (3, 224, 224),Image (3, 224, 224),Image (3, 224, 224),Image (3, 224, 224),Image (3, 224, 224)
y: CategoryList
train,train,train,train,train
Path: images/train;
Valid: LabelList (15150 items)
x: ImageList
Image (3, 224, 224),Image (3, 224, 224),Image (3, 224, 224),Image (3, 224, 224),Image (3, 224, 224)
y: CategoryList
train,train,train,train,train
Path: images/train;
Test: None
When I had this problem previously, I was told that I had to keep my train and test images on the same level. This is my file structure atm:
Food-101
images
train
...75750 train images
test
...25250 test images
meta
classes.txt
labes.txt
test.json
test.txt
train.json
train.txt
README.txt
license_agreement.txt
And this is basically the code I’m using:
train_image_path = Path('images/train/')
test_image_path = Path('images/test/')
path = Path('../Food-101')
food_names = get_image_files(train_image_path)
file_parse = r'/([^/]+)_\d+\.(png|jpg|jpeg)$'
data = ImageDataBunch.from_folder(train_image_path, test_image_path, valid_pct=0.2, ds_tfms=get_transforms(), size=224)
data.normalize(imagenet_stats)
Specify the test parameter as the name of the folder that contains the tests
e.g.
data = ImageDataBunch.from_folder(path=path, train = "Train", test = "Test", ds_tfms=get_transforms(),size=224,valid_pct=0.3)