Skip to content

OSError: cannot identify image file <_io.BytesIO object at 0x7fc87f2ec678> #43

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

Open
checongcong opened this issue Feb 16, 2018 · 3 comments
Labels
bug Something isn't working

Comments

@checongcong
Copy link

I'm following the Example Use: A building detector with TensorFlow API, and ran into an error when trying to generate the training/eval data.

System information

** What is the top-level directory of the model you are using: **
~/tensorflow/models/research/object_detection

OS Platform and Distribution: Linux Ubuntu 16.04, Elementary OS

TensorFlow installed from (source or binary): pip install tensorflow-gpu

TensorFlow version: v1.5.0

Python version: v3.6.0

CUDA/cuDNN version: CUDA 9.0, cudnn 7.0, nVidia driver: 384.111

GPU: nVidia GeForce GTX 1070 Ti 8GB memory

CPU: Intel x86-64 Intel Core i5-6400K @ 2.70GHz x 4, 16GB memory

Exact command to reproduce:

python tf_record_generation.py --label_input=labels.npz              --train_rd_path=data/train_buildings.record              --test_rd_path=data/test_buildings.record

Sample code / logs:

python tf_record_generation.py --label_input=labels.npz              --train_rd_path=data/train_buildings.record              --test_rd_path=data/test_buildings.record
You have 221 training tiles and 144 test tiles ready
Traceback (most recent call last):
  File "tf_record_generation.py", line 172, in <module>
    tf.app.run()
  File "/home/xban/.pyenv/versions/general/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 124, in run
    _sys.exit(main(argv))
  File "tf_record_generation.py", line 143, in main
    tf_example = create_tf_example(group, train_dir)
  File "tf_record_generation.py", line 56, in create_tf_example
    image = Image.open(encoded_jpg_io)
  File "/home/xban/.pyenv/versions/general/lib/python3.6/site-packages/PIL/Image.py", line 2572, in open
    % (filename if filename else fp))
OSError: cannot identify image file <_io.BytesIO object at 0x7fc87f2ec678>
@Geoyi
Copy link
Contributor

Geoyi commented Feb 16, 2018

@checongcong, I have python 3.6.3 installed in my python environment and used tensorflow 1.4.1 originally, but I also tried tensorflow 1.5.0, and both worked.
Can you do two things over here:

  • go to your tiles folder, and inspect if all the image tiles are properly downloaded, and if they all could be opened;
  • assume your tiles are correctly downloaded. If you still run into the same problem, upgrade your pillow version, not sure if it's caused by pillow version particularly. I have Pillow==5.0.0 in my python environment.

@blairjordan
Copy link

My issue here was that the demo attempts to download sample content using the mapbox API. For some reason, it'll just render invalid images instead of displaying an error message (If you look at images under data/examples/Buildings, you'll find they are probably broken) .

If you look at config.json, you'll see TOKEN_KEY under the imagery URL.

Sign up for mapbox (if you haven't already). The confirmation page should display your key, otherwise you can see it under https://www.mapbox.com/account/access-tokens.

Replace the TOKEN_KEY with your mapbox public token, and retry this.

@drewbo
Copy link
Contributor

drewbo commented Apr 18, 2018

Yeah replacing the ACCESS_TOKEN is noted in the README but it's pretty buried and has certainly caused its fair share of issues. I propose adding a specific check for this string in the config and displaying an error/warning if it's present

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

4 participants