custom dataset error no csv file found

FileNotFoundError Traceback (most recent call last)
in
17
18 return(image,y_label)
—> 19 dataset=plantpathology(train_csv=‘train_csv’, root_dir=‘plant_pathology’, transform=transforms.ToTensor())

in init(self, train_csv, root_dir, transform)
1 class plantpathology(Dataset):
2 def init(self, train_csv, root_dir, transform=None):
----> 3 self.annotations= pd.read_csv(train_csv)
4 self.root_dir=root_dir
5 self.transform =transform

/opt/conda/lib/python3.7/site-packages/pandas/io/parsers.py in read_csv(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, squeeze, prefix, mangle_dupe_cols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, skipfooter, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, dayfirst, cache_dates, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, doublequote, escapechar, comment, encoding, dialect, error_bad_lines, warn_bad_lines, delim_whitespace, low_memory, memory_map, float_precision, storage_options)
603 kwds.update(kwds_defaults)
604
→ 605 return _read(filepath_or_buffer, kwds)
606
607

/opt/conda/lib/python3.7/site-packages/pandas/io/parsers.py in _read(filepath_or_buffer, kwds)
455
456 # Create the parser.
→ 457 parser = TextFileReader(filepath_or_buffer, **kwds)
458
459 if chunksize or iterator:

/opt/conda/lib/python3.7/site-packages/pandas/io/parsers.py in init(self, f, engine, **kwds)
812 self.options[“has_index_names”] = kwds[“has_index_names”]
813
→ 814 self._engine = self._make_engine(self.engine)
815
816 def close(self):

/opt/conda/lib/python3.7/site-packages/pandas/io/parsers.py in _make_engine(self, engine)
1043 )
1044 # error: Too many arguments for “ParserBase”
→ 1045 return mapping[engine](self.f, **self.options) # type: ignore[call-arg]
1046
1047 def _failover_to_python(self):

/opt/conda/lib/python3.7/site-packages/pandas/io/parsers.py in init(self, src, **kwds)
1860
1861 # open handles
→ 1862 self._open_handles(src, kwds)
1863 assert self.handles is not None
1864 for key in (“storage_options”, “encoding”, “memory_map”, “compression”):

/opt/conda/lib/python3.7/site-packages/pandas/io/parsers.py in _open_handles(self, src, kwds)
1361 compression=kwds.get(“compression”, None),
1362 memory_map=kwds.get(“memory_map”, False),
→ 1363 storage_options=kwds.get(“storage_options”, None),
1364 )
1365

/opt/conda/lib/python3.7/site-packages/pandas/io/common.py in get_handle(path_or_buf, mode, encoding, compression, memory_map, is_text, errors, storage_options)
642 encoding=ioargs.encoding,
643 errors=errors,
→ 644 newline=“”,
645 )
646 else:

FileNotFoundError: [Errno 2] No such file or directory: ‘train_csv’

Search Stack Overflow

This error is raised by pandas, as it cannot find the specified file:

FileNotFoundError: [Errno 2] No such file or directory: ‘train_csv’

Make sure the train_csv is located in the current working directly or adjust the path appropriately.

PS: you can post code snippets by wrapping them into three backticks ```, which makes debugging easier and indexing possible. :wink: