我正在尝试从这个 tutorial 运行代码。我已将代码和数据集放在同一目录中,但仍然出现以下错误。
FileNotFoundError Traceback (most recent call last)
<ipython-input-6-5f5284db0527> in <module>()
39 # extract features from all images
40 directory = 'Flicker8k'
---> 41 features = extract_features(directory)
42 print('Extracted Features: %d' % len(features))
43 # save to file
<ipython-input-6-5f5284db0527> in extract_features(directory)
18 # extract features from each photo
19 features = dict()
---> 20 for name in listdir(directory):
21 # load an image from file
22 filename = directory + '/' + name
**FileNotFoundError: [WinError 3] The system cannot find the path specified: 'Flicker8k'**
最佳答案
它提示无法找到指定的目录。尝试将相对目录路径 directory = 'Flicker8k'
替换为 Flicker8k
目录的完整绝对路径(似乎您在 Windows 上,所以看起来像 C:\myproject\Flicker8k
或者如果您在 linux 上 /home/user/myproject/Flicker8k
或该数据集所在的任何位置)。因此,请确保:
关于python-3.x - FileNotFoundError : [WinError 3] The system cannot find the path specified:,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/51007476/