在用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/

问题解决!