我不明白为什么Pandas找不到我的fer2013.csv。我有以下代码:
class DataManager(object):
"""Class for loading fer2013 emotion classification dataset or
imdb gender classification dataset."""
def __init__(self, dataset_name='imdb', dataset_path=None, image_size=(48, 48)):
self.dataset_name = dataset_name
self.dataset_path = dataset_path
self.image_size = image_size
if self.dataset_path != None:
self.dataset_path = dataset_path
elif self.dataset_name == 'imdb':
self.dataset_path = '../datasets/imdb_crop/imdb.mat'
elif self.dataset_name == 'fer2013':
self.dataset_path = '../datasets/fer2013/fer2013.csv'
elif self.dataset_name == 'KDEF':
self.dataset_path = '../datasets/KDEF/'
else:
raise Exception('Incorrect dataset name, please input imdb or fer2013')
我收到此错误:
Traceback (most recent call last):
File "train_model.py", line 55, in <module>
faces, emotions = data_loader.get_data()
File "C:\Users\devel\Documents\Proyectos\erecog\utils\datasets.py", line 31, in get_data
ground_truth_data = self._load_fer2013()
File "C:\Users\devel\Documents\Proyectos\erecog\utils\datasets.py", line 57, in _load_fer2013
data = pd.read_csv(self.dataset_path)
File "C:\Users\devel\Documents\Proyectos\erecog\env\lib\site-packages\pandas\io\parsers.py", line 676, in parser_f
return _read(filepath_or_buffer, kwds)
File "C:\Users\devel\Documents\Proyectos\erecog\env\lib\site-packages\pandas\io\parsers.py", line 448, in _read
parser = TextFileReader(fp_or_buf, **kwds)
File "C:\Users\devel\Documents\Proyectos\erecog\env\lib\site-packages\pandas\io\parsers.py", line 880, in __init__
self._make_engine(self.engine)
File "C:\Users\devel\Documents\Proyectos\erecog\env\lib\site-packages\pandas\io\parsers.py", line 1114, in _make_engine
self._engine = CParserWrapper(self.f, **self.options)
File "C:\Users\devel\Documents\Proyectos\erecog\env\lib\site-packages\pandas\io\parsers.py", line 1891, in __init__
self._reader = parsers.TextReader(src, **kwds)
File "pandas\_libs\parsers.pyx", line 374, in pandas._libs.parsers.TextReader.__cinit__
File "pandas\_libs\parsers.pyx", line 674, in pandas._libs.parsers.TextReader._setup_parser_source
FileNotFoundError: [Errno 2] File ../datasets/fer2013/fer2013.csv does not exist: '../datasets/fer2013/fer2013.csv'
我在那个文件夹中有那个文件,我不知道为什么找不到我的文件。
答案 0 :(得分:0)
我解决了这个错误。感谢@DYZ,我可以看到进程正在运行的目录,该进程位于'utils'文件夹中。我将路线更改为“ ./datasets/fer2013/fer2013.csv”,指向“。”。在“ /”之前。