ImageDataBunch.from_folder 没有看到我的测试集

ImageDataBunch.from_folder does not see my test set

我正在处理 Food-101 数据集,我正在尝试为 ImageDataBunch.from_folder() 提供一个单独的测试集,但由于某种原因,它无法识别它。

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

当我之前遇到这个问题时,我被告知必须将训练图像和测试图像保持在同一水平面上。这是我的文件结构 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

这基本上是我使用的代码:

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)

将测试参数指定为包含测试的文件夹的名称

例如

data = ImageDataBunch.from_folder(path=path, train = "Train", test = "Test", ds_tfms=get_transforms(),size=224,valid_pct=0.3)