I’m getting following error in midway of second epoch. First epoch ran successfully without any error.
OSError Traceback (most recent call last)
<ipython-input-91-be1ab4476b35> in <module>()
----> 1 learn.fit_one_cycle(5, slice(lr))
/usr/local/lib/python3.6/dist-packages/fastai/train.py in fit_one_cycle(learn, cyc_len, max_lr, moms, div_factor, pct_start, wd, callbacks, **kwargs)
18 callbacks.append(OneCycleScheduler(learn, max_lr, moms=moms, div_factor=div_factor,
19 pct_start=pct_start, **kwargs))
---> 20 learn.fit(cyc_len, max_lr, wd=wd, callbacks=callbacks)
21
22 def lr_find(learn:Learner, start_lr:Floats=1e-7, end_lr:Floats=10, num_it:int=100, stop_div:bool=True, **kwargs:Any):
/usr/local/lib/python3.6/dist-packages/fastai/basic_train.py in fit(self, epochs, lr, wd, callbacks)
160 callbacks = [cb(self) for cb in self.callback_fns] + listify(callbacks)
161 fit(epochs, self.model, self.loss_func, opt=self.opt, data=self.data, metrics=self.metrics,
--> 162 callbacks=self.callbacks+callbacks)
163
164 def create_opt(self, lr:Floats, wd:Floats=0.)->None:
/usr/local/lib/python3.6/dist-packages/fastai/basic_train.py in fit(epochs, model, loss_func, opt, data, callbacks, metrics)
92 except Exception as e:
93 exception = e
---> 94 raise e
95 finally: cb_handler.on_train_end(exception)
96
/usr/local/lib/python3.6/dist-packages/fastai/basic_train.py in fit(epochs, model, loss_func, opt, data, callbacks, metrics)
80 cb_handler.on_epoch_begin()
81
---> 82 for xb,yb in progress_bar(data.train_dl, parent=pbar):
83 xb, yb = cb_handler.on_batch_begin(xb, yb)
84 loss = loss_batch(model, xb, yb, loss_func, opt, cb_handler)
/usr/local/lib/python3.6/dist-packages/fastprogress/fastprogress.py in __iter__(self)
63 self.update(0)
64 try:
---> 65 for i,o in enumerate(self._gen):
66 yield o
67 if self.auto_update: self.update(i+1)
/usr/local/lib/python3.6/dist-packages/fastai/basic_data.py in __iter__(self)
45 def __iter__(self):
46 "Process and returns items from `DataLoader`."
---> 47 for b in self.dl:
48 y = b[1][0] if is_listy(b[1]) else b[1]
49 if not self.skip_size1 or y.size(0) != 1: yield self.proc_batch(b)
/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py in __next__(self)
635 self.reorder_dict[idx] = batch
636 continue
--> 637 return self._process_next_batch(batch)
638
639 next = __next__ # Python 2 compatibility
/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py in _process_next_batch(self, batch)
656 self._put_indices()
657 if isinstance(batch, ExceptionWrapper):
--> 658 raise batch.exc_type(batch.exc_msg)
659 return batch
660
OSError: Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py", line 138, in _worker_loop
samples = collate_fn([dataset[i] for i in batch_indices])
File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py", line 138, in <listcomp>
samples = collate_fn([dataset[i] for i in batch_indices])
File "/usr/local/lib/python3.6/dist-packages/fastai/data_block.py", line 383, in __getitem__
if self.item is None: x,y = self.x[idxs],self.y[idxs]
File "/usr/local/lib/python3.6/dist-packages/fastai/data_block.py", line 67, in __getitem__
if isinstance(try_int(idxs), int): return self.get(idxs)
File "/usr/local/lib/python3.6/dist-packages/fastai/vision/data.py", line 265, in get
res = super().get(i)
File "/usr/local/lib/python3.6/dist-packages/fastai/data_block.py", line 43, in get
return self.create_func(item) if self.create_func else item
File "/usr/local/lib/python3.6/dist-packages/fastai/vision/image.py", line 422, in open_image
x = PIL.Image.open(fn).convert('RGB')
File "/usr/local/lib/python3.6/dist-packages/PIL/Image.py", line 844, in convert
"""
File "/usr/local/lib/python3.6/dist-packages/PIL/ImageFile.py", line 231, in load
"(%d bytes not processed)" % len(b))
OSError: image file is truncated (38 bytes not processed)
What could be the reason? I guess it may be due to small size of image but then error should have come in first epoch too.