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

Raw image URL from GitHub #1478

Open
PacoGrax opened this issue May 1, 2024 · 0 comments
Open

Raw image URL from GitHub #1478

PacoGrax opened this issue May 1, 2024 · 0 comments

Comments

@PacoGrax
Copy link

PacoGrax commented May 1, 2024

Describe the issue

Issue:
I'm trying to get the image_url to use eval_model, but I always have the same error and I don't know why. I don't know hot to use raw image from GitHub
I think the problem is in the image file because when in try this in another notebook it works

Command:

PASTE THE COMMANDS HERE.
import requests
from PIL import Image
from io import BytesIO


#la imagen URL (utilizar la fila imagen URL from Github)
image_url = 'https://github.com/haotian-liu/LLaVA/blob/main/images/llava_v1_5_radar.jpg'
#download the image and open it with PIL
response = requests.get(image_url)
image = Image.open(BytesIO(response.content))

import matplotlib.pyplot as plt
#display the image using matplotlib
plt.imshow(image)
plt.axis('off') #turn off axis nu,bers and ticks
plt.show()

#ahora pasar la imagen procesada al eval_model

eval_model(
    tokenizer,
    model,
    image_processor,
    context_len,
    image,
    "what do you see in this picture?"
)


Log: 
UnidentifiedImageError                    Traceback (most recent call last)
[<ipython-input-20-9a1b8412d79e>](https://localhost:8080/#) in <cell line: 10>()
      8 #download the image and open it with PIL
      9 response = requests.get(image_url)
---> 10 image = Image.open(BytesIO(response.content))
     11 
     12 import matplotlib.pyplot as plt

[/usr/local/lib/python3.10/dist-packages/PIL/Image.py](https://localhost:8080/#) in open(fp, mode, formats)
   3281         fp.seek(0)
   3282     except (AttributeError, io.UnsupportedOperation):
-> 3283         fp = io.BytesIO(fp.read())
   3284         exclusive_fp = True
   3285 

UnidentifiedImageError: cannot identify image file <_io.BytesIO object at 0x7a68fc2f6f20>
PASTE THE LOGS HERE.

Screenshots:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant