quot;RuntimeError: Found 0 files in subfolders of quot;.. Error about subfolder in Pytorch(quot;RuntimeError: Found 0 files in subfolders of quot;.. 关于 Pytorch 中的子文件夹的错误)
问题描述
我目前基于 Window 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.
但我遇到了错误:
运行时错误:在以下子文件夹中找到 0 个文件:./Dataset/images/支持的扩展名有:.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: Found 0 files in subfolders of ".. 关于 Pytorch 中的子文件夹的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:"RuntimeError: Found 0 files in subfolders of &q
基础教程推荐
- kivy 应用程序中的一个简单网页作为小部件 2022-01-01
- 在 Django Admin 中使用内联 OneToOneField 2022-01-01
- matplotlib 设置 yaxis 标签大小 2022-01-01
- 对多索引数据帧的列进行排序 2022-01-01
- Python,确定字符串是否应转换为 Int 或 Float 2022-01-01
- 比较两个文本文件以找出差异并将它们输出到新的文本文件 2022-01-01
- Python 中是否有任何支持将长字符串转储为块文字或折叠块的 yaml 库? 2022-01-01
- Kivy 使用 opencv.调整图像大小 2022-01-01
- 在 Python 中将货币解析为数字 2022-01-01
- 究竟什么是“容器"?在蟒蛇?(以及所有的 python 容器类型是什么?) 2022-01-01
