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

Error decoding base64 image with charset. #202

Closed
matatonic opened this issue Sep 13, 2024 · 2 comments
Closed

Error decoding base64 image with charset. #202

matatonic opened this issue Sep 13, 2024 · 2 comments
Assignees

Comments

@matatonic
Copy link

The error:

  File "/app/backend/qwen2-vl.py", line 52, in stream_chat_with_images
    image_inputs, video_inputs = process_vision_info(messages)
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/qwen_vl_utils/vision_process.py", line 217, in process_vision_info
    image_inputs.append(fetch_image(vision_info))
                        ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/qwen_vl_utils/vision_process.py", line 92, in fetch_image
    raise ValueError(f"Unrecognized image input, support local path, http url, base64 and PIL.Image, got {image}")
ValueError: Unrecognized image input, support local path, http url, base64 and PIL.Image, got data:image/jpeg;charset=utf-8;base64,/9j/4AAQSkZJRgABAQEAtAC0...........
                                                                                                              ^^^^^^^^^^^^^
---------------------------------------------------------------------------------------------------------------------------

From here:

elif image.startswith("data:image"):
data = image.split(";", 1)[1]
if data.startswith("base64,"):
data = base64.b64decode(data[7:])
image_obj = Image.open(BytesIO(data))
else:

@matatonic
Copy link
Author

The images were made with this: https://pypi.org/project/python-datauri/

kq-chen added a commit that referenced this issue Sep 18, 2024
fix(fetch_image) base64 image url allow more url options (#202)
@kq-chen
Copy link
Collaborator

kq-chen commented Sep 18, 2024

the bug has been fix by #215 , so I will close this issue.

@kq-chen kq-chen closed this as completed Sep 18, 2024
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

2 participants