Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

image classifcation function throws error with corrupt images files #3

Open
matobler opened this issue Mar 24, 2022 · 2 comments
Open
Labels
bug Something isn't working

Comments

@matobler
Copy link
Collaborator

When an image file is corrupted (e.g. was not terminated) we get the following error message from the classifySpecies function:

`2022-03-24 14:24:32.329992: W tensorflow/core/framework/op_kernel.cc:1680] Unknown: OSError: image file is truncated (35 bytes not processed)
Traceback (most recent call last):

File "C:\Users\mtobler\ANACON1\envs\TE1D751\lib\site-packages\tensorflow\python\ops\script_ops.py", line 249, in call
ret = func(*args)

File "C:\Users\mtobler\ANACON1\envs\TE1D751\lib\site-packages\tensorflow\python\autograph\impl\api.py", line 645, in wrapper
return func(*args, **kwargs)

File "C:\Users\mtobler\ANACON1\envs\TE1D751\lib\site-packages\tensorflow\python\data\ops\dataset_ops.py", line 892, in generator_py_func
values = next(generator_state.get_iterator(iterator_id))

File "C:\Users\mtobler\ANACON1\envs\TE1D751\lib\site-packages\keras\engine\data_adapter.py", line 822, in wrapped_generator
for data in generator_fn():

File "C:\Users\mtobler\ANACON1\envs\TE1D751\lib\site-packages\keras\engine\data_adapter.py", line 948, in generator_fn
yield x[i]

File "", line 109, in getitem

File "C:\Users\mtobler\ANACON1\envs\TE1D751\lib\site-packages\PIL\Image.py", line 1146, in crop
self.load()

File "C:\Users\mtobler\ANACON1\envs\TE1D751\lib\site-packages\PIL\ImageFile.py", line 248, in load
"image file is truncated "

OSError: image file is truncated (35 bytes not processed)

Error in py_call_impl(callable, dots$args, dots$keywords) :
UnknownError: 2 root error(s) found.
(0) Unknown: OSError: image file is truncated (35 bytes not processed)
Traceback (most recent call last):

File "C:\Users\mtobler\ANACON1\envs\TE1D751\lib\site-packages\tensorflow\python\ops\script_ops.py", line 249, in call
ret = func(*args)

File "C:\Users\mtobler\ANACON1\envs\TE1D751\lib\site-packages\tensorflow\python\autograph\impl\api.py", line 645, in wrapper
return func(*args, **kwargs)

File "C:\Users\mtobler\ANACON1\envs\TE1D751\lib\site-packages\tensorflow\python\data\ops\dataset_ops.py", line 892, in generator_py_func
values = next(generator_state.get_iterator(iterator_id))

File "C:\Users\mtobler\ANACON1\envs\TE1D751\lib\site-packages\keras\engine\data_adapter.py", line 822, in wrapped_generator
for data in generator_fn():

File "C:\Users\mtobler\ANACON1\envs\TE1D751\lib\site-packages\keras\engine\data_adapter.py", line 948, in generator_fn
yield x[i]

File "", line 109,
In addition: Warning message:
In predict_generator(., generator = cropGenerator, steps = predict_steps, :
`

Need to add error handling for this.

@tkswanson
Copy link
Collaborator

tkswanson commented Mar 24, 2022 via email

@tkswanson tkswanson added the bug Something isn't working label Mar 25, 2022
@matobler
Copy link
Collaborator Author

matobler commented Apr 2, 2022

This particular issue was likely solved with the new tf.data generator, but there might still be some cases that could lead to errors. Currently I check for zero-length files and the decoder function can handle truncated files. But there might be other possible corruptions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants