FileNotFoundError: Caught FileNotFoundError in DataLoader worker process 0. Original Traceback (most recent call last):

FileNotFoundError Traceback (most recent call last)
in
----> 1 learn.fit_one_cycle(2)

/opt/conda/envs/fastai/lib/python3.6/site-packages/fastai/train.py in fit_one_cycle(learn, cyc_len, max_lr, moms, div_factor, pct_start, final_div, wd, callbacks, tot_epochs, start_epoch)
21 callbacks.append(OneCycleScheduler(learn, max_lr, moms=moms, div_factor=div_factor, pct_start=pct_start,
22 final_div=final_div, tot_epochs=tot_epochs, start_epoch=start_epoch))
β€”> 23 learn.fit(cyc_len, max_lr, wd=wd, callbacks=callbacks)
24
25 def fit_fc(learn:Learner, tot_epochs:int=1, lr:float=defaults.lr, moms:Tuple[float,float]=(0.95,0.85), start_pct:float=0.72,

/opt/conda/envs/fastai/lib/python3.6/site-packages/fastai/basic_train.py in fit(self, epochs, lr, wd, callbacks)
198 else: self.opt.lr,self.opt.wd = lr,wd
199 callbacks = [cb(self) for cb in self.callback_fns + listify(defaults.extra_callback_fns)] + listify(callbacks)
–> 200 fit(epochs, self, metrics=self.metrics, callbacks=self.callbacks+callbacks)
201
202 def create_opt(self, lr:Floats, wd:Floats=0.)->None:

/opt/conda/envs/fastai/lib/python3.6/site-packages/fastai/basic_train.py in fit(epochs, learn, callbacks, metrics)
104 if not cb_handler.skip_validate and not learn.data.empty_val:
105 val_loss = validate(learn.model, learn.data.valid_dl, loss_func=learn.loss_func,
–> 106 cb_handler=cb_handler, pbar=pbar)
107 else: val_loss=None
108 if cb_handler.on_epoch_end(val_loss): break

/opt/conda/envs/fastai/lib/python3.6/site-packages/fastai/basic_train.py in validate(model, dl, loss_func, cb_handler, pbar, average, n_batch)
55 val_losses,nums = [],[]
56 if cb_handler: cb_handler.set_dl(dl)
β€”> 57 for xb,yb in progress_bar(dl, parent=pbar, leave=(pbar is not None)):
58 if cb_handler: xb, yb = cb_handler.on_batch_begin(xb, yb, train=False)
59 val_loss = loss_batch(model, xb, yb, loss_func, cb_handler=cb_handler)

/opt/conda/envs/fastai/lib/python3.6/site-packages/fastprogress/fastprogress.py in iter(self)
45 except Exception as e:
46 self.on_interrupt()
β€”> 47 raise e
48
49 def update(self, val):

/opt/conda/envs/fastai/lib/python3.6/site-packages/fastprogress/fastprogress.py in iter(self)
39 if self.total != 0: self.update(0)
40 try:
β€”> 41 for i,o in enumerate(self.gen):
42 if i >= self.total: break
43 yield o

/opt/conda/envs/fastai/lib/python3.6/site-packages/fastai/basic_data.py in iter(self)
73 def iter(self):
74 β€œProcess and returns items from DataLoader.”
β€”> 75 for b in self.dl: yield self.proc_batch(b)
76
77 @classmethod

/opt/conda/envs/fastai/lib/python3.6/site-packages/torch/utils/data/dataloader.py in next(self)
343
344 def next(self):
–> 345 data = self._next_data()
346 self._num_yielded += 1
347 if self._dataset_kind == _DatasetKind.Iterable and \

/opt/conda/envs/fastai/lib/python3.6/site-packages/torch/utils/data/dataloader.py in _next_data(self)
854 else:
855 del self._task_info[idx]
–> 856 return self._process_data(data)
857
858 def _try_put_index(self):

/opt/conda/envs/fastai/lib/python3.6/site-packages/torch/utils/data/dataloader.py in _process_data(self, data)
879 self._try_put_index()
880 if isinstance(data, ExceptionWrapper):
–> 881 data.reraise()
882 return data
883

/opt/conda/envs/fastai/lib/python3.6/site-packages/torch/_utils.py in reraise(self)
392 # (https://bugs.python.org/issue2651), so we work around it.
393 msg = KeyErrorMessage(msg)
–> 394 raise self.exc_type(msg)

FileNotFoundError: Caught FileNotFoundError in DataLoader worker process 0.
Original Traceback (most recent call last):
File β€œ/opt/conda/envs/fastai/lib/python3.6/site-packages/torch/utils/data/_utils/worker.py”, line 178, in _worker_loop
data = fetcher.fetch(index)
File β€œ/opt/conda/envs/fastai/lib/python3.6/site-packages/torch/utils/data/_utils/fetch.py”, line 44, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File β€œ/opt/conda/envs/fastai/lib/python3.6/site-packages/torch/utils/data/_utils/fetch.py”, line 44, in
data = [self.dataset[idx] for idx in possibly_batched_index]
File β€œ/opt/conda/envs/fastai/lib/python3.6/site-packages/fastai/data_block.py”, line 651, in getitem
if self.item is None: x,y = self.x[idxs],self.y[idxs]
File β€œ/opt/conda/envs/fastai/lib/python3.6/site-packages/fastai/data_block.py”, line 120, in getitem
if isinstance(idxs, Integral): return self.get(idxs)
File β€œ/opt/conda/envs/fastai/lib/python3.6/site-packages/fastai/vision/data.py”, line 271, in get
res = self.open(fn)
File β€œ/opt/conda/envs/fastai/lib/python3.6/site-packages/fastai/vision/data.py”, line 267, in open
return open_image(fn, convert_mode=self.convert_mode, after_open=self.after_open)
File β€œ/opt/conda/envs/fastai/lib/python3.6/site-packages/fastai/vision/image.py”, line 398, in open_image
x = PIL.Image.open(fn).convert(convert_mode)
File β€œ/opt/conda/envs/fastai/lib/python3.6/site-packages/PIL/Image.py”, line 2634, in open
fp = builtins.open(filename, β€œrb”)
FileNotFoundError: [Errno 2] No such file or directory: β€˜data/Train/frame297.jpg’

1 Like

I have the same issue.
Please solve it.

For your case, it should be your csv file can not find the frame297.jpg file.

It can not find the urls_black.csv file. Can you show us your file structure from the left hand side? I suggest you to just create a imagenet style dataset, and it should save a lot of time.

1 Like

You need to change the black.txt to be urls_black.csv and put it under the bear folder.

Listen to me, the google image way i think is waste of time because it does not work all the time.
Here is another way that can solve this issue in 10 mins.

Download 50 images of black bear, grizzly bear, and teddys bear. Put them into 3 different folders, black, grizzly, and teddys. Then, you need to put these folder under the bears folder and run the code. If you still have issue, upload these two folders in zip to drop box, and provide the direct download link, I will set up the notebook for you to see how it work.

1 Like

Thanks Bro. Issue solved.
Thanks for more information.

1 Like