" RuntimeError:在"的子文件夹中找到0个文件.有关Pytorch中子文件夹的错误 [英] "RuntimeError: Found 0 files in subfolders of ".. Error about subfolder in Pytorch
问题描述
我目前基于Windows 10,Jupyter Notebook,Pytorch 1.0,Python 3.6.x.
I'm based on Window 10, Jupyter Notebook, Pytorch 1.0, Python 3.6.x currently.
首先,我使用以下代码确认文件的正确路径:print(os.listdir('./Dataset/images/'))
.
At first I confirm to the correct path of files using this code : print(os.listdir('./Dataset/images/'))
.
我可以检查该路径是否正确.
and I could check that this path is correct.
但是我遇到了错误:
RuntimeError:在./Dataset/images/的子文件夹中找到0个文件 支持的扩展名是:.jpg,.jpeg,.png,.ppm,.bmp,.pgm,.tif"
RuntimeError: Found 0 files in subfolders of: ./Dataset/images/ Supported extensions are: .jpg,.jpeg,.png,.ppm,.bmp,.pgm,.tif"
怎么了? 您能提出解决方案吗?
What is the matter? Could you suggest a solution?
我试图./dataset/1/images
喜欢这种方法.但是结果是一样的....
I tried to ./dataset/1/images
like this method. but the result was same....
img_dir = './Dataset/images/'
img_data = torchvision.datasets.ImageFolder(os.path.join(img_dir), transforms.Compose([
transforms.Scale(256),
transforms.RandomResizedCrop(224),
transforms.RandomHorizontalFlip(),
transforms.ToTensor(),
]))
img_batch = data.DataLoader(img_data, batch_size=batch_size,
shuffle = True, drop_last=True)
推荐答案
可以发布文件的结构吗?在您的情况下,应该是:
Can you post the structure of your files? In your case, it is supposed to be:
img_dir
|_class1
|_a.jpg
|_b.jpg
|_class2
|_a.jpg
|_b.jpg
...
这篇关于" RuntimeError:在"的子文件夹中找到0个文件.有关Pytorch中子文件夹的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!