在用pycharm运行深度神经网络加载数据时,发现报错
Traceback (most recent call last):
File “D:/PyCharmWorkPlace/graduate_project/lsgan/main.py”, line 16, in
class LSGAN:
File “D:/PyCharmWorkPlace/graduate_project/lsgan/main.py”, line 125, in LSGAN
dataset = dset.ImageFolder(root=dataroot,
File “D:\welcomeminiconda\envs\tensorflow\lib\site-packages\torchvision\datasets\folder.py”, line 310, in init
super().init(
File “D:\welcomeminiconda\envs\tensorflow\lib\site-packages\torchvision\datasets\folder.py”, line 145, in init
classes, class_to_idx = self.find_classes(self.root)
File “D:\welcomeminiconda\envs\tensorflow\lib\site-packages\torchvision\datasets\folder.py”, line 219, in find_classes
return find_classes(directory)
File “D:\welcomeminiconda\envs\tensorflow\lib\site-packages\torchvision\datasets\folder.py”, line 43, in find_classes
raise FileNotFoundError(f"Couldn’t find any class folder in {directory}.")
FileNotFoundError: Couldn’t find any class folder in D:/PyCharmWorkPlace/graduate_project/data/graydata/.
这里的原因是ImageFolder调用的是一个数据包
我的png文件路径是D:/PyCharmWorkPlace/graduate_project/data/graydata/.
此时应该把路径写为图片的上一级目录,所以添加一个文件夹,将路径改为
D:/PyCharmWorkPlace/graduate_project/data/gray/
文章来源:https://www.toymoban.com/news/detail-467057.html
问题解决!文章来源地址https://www.toymoban.com/news/detail-467057.html
到了这里,关于解决raise FileNotFoundError(f“Couldn’t find any class folder in {directory}.“) FileNotFoundError: Coul的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!