Image-Text-to-Text
Transformers
Safetensors
English
idefics2
pretraining
multimodal
vision
Inference Endpoints
5 papers

load_image(URL) is invalid

#17
by micaelcarvalho - opened

The "How to Get Started" instructions starts with an invalid call to load_image: https://huggingface.co/HuggingFaceM4/idefics2-8b
This results in PIL.UnidentifiedImageError: cannot identify image file <_io.BytesIO ...>
The instructions are likely incorrect/outdated and need to be fixed

HuggingFaceM4 org

hi @micaelcarvalho ,
would you be able to share your full traceback? i am hitting no error with these image loads

I'm seeing the same thing, though I admittedly don't use Python all that much, so I might be doing something silly. Here's my traceback:

Traceback (most recent call last):
  File "[path-to-directory]/idefics2-test/test.py", line 12, in <module>
    image1 = load_image("https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg")
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/transformers/image_utils.py", line 314, in load_image
    image = PIL.Image.open(requests.get(image, stream=True, timeout=timeout).raw)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/PIL/Image.py", line 3280, in open
    raise UnidentifiedImageError(msg)
PIL.UnidentifiedImageError: cannot identify image file <_io.BytesIO object at 0x12501b880>

My issue seems to be fixed by using different image URLs -- I'm guessing some sort of bot detection has been triggered on britannica.com

HuggingFaceM4 org

yes, i suspect indeed that the download failed because of rate limiting (or something of that sort). would need to see the result of requests.get(image, stream=True, timeout=timeout). i am glad that different URLs work.

Yeah, it seems to be an intermittent issue on my end. I just tried to print the response with the images that were failing, but the requests are succeeding for me now. Thanks for following up here!

HuggingFaceM4 org

i'll close this discussion, feel free to re-open if needed!
glad you found a way to move forward!

VictorSanh changed discussion status to closed

Sign up or log in to comment