emedvedev/attention-ocr

OSError: cannot identify image file/ PIL error

sushanth-d opened this issue · 2 comments

Hello!
First of all, a humble Thank you to you for creating this repository and of course the python module :)

Here is an issue I am facing, the log of which is pasted:
....
2019-08-14 20:41:58,231 root INFO Step 173: 0.058s, loss: 2.590488, perplexity: 13.336274.
2019-08-14 20:41:58,284 root INFO Step 174: 0.051s, loss: 2.541614, perplexity: 12.700156.
2019-08-14 20:41:58,337 root INFO Step 175: 0.051s, loss: 2.576047, perplexity: 13.145072.
Traceback (most recent call last):
File "/opt/conda/bin/aocr", line 10, in
sys.exit(main())
File "/opt/conda/lib/python3.6/site-packages/aocr/main.py", line 257, in main
num_epoch=parameters.num_epoch
File "/opt/conda/lib/python3.6/site-packages/aocr/model/model.py", line 376, in train
for batch in s_gen.gen(self.batch_size):
File "/opt/conda/lib/python3.6/site-packages/aocr/util/data_gen.py", line 70, in gen
if self.max_width and (Image.open(IO(img)).size[0] <= self.max_width):
File "/opt/conda/lib/python3.6/site-packages/PIL/Image.py", line 2687, in open
% (filename if filename else fp))
OSError: cannot identify image file <_io.BytesIO object at 0x7f2efc5169e8>

As seen above in the log, the training has successfully started and just when it is about to unleash its powers, an error is thrown and the training stops.
Tensorflow version: 1.14.0
Pillow version: 5.4.1
aocr version: 0.7.6

ANY help or thoughts on this will be much, much appreciated.
Gratitude,
Sushanth

May be a zero byte file or a text or different file is present.
The reason why when it is loading, leading to this error.