-
Notifications
You must be signed in to change notification settings - Fork 453
Automatic image blob creation doesn't handle RGBA images with JPEG. #160
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
Comments
it seems that the code in Gemini API Overview is not correct,
|
Definitely seems to be the case |
In my tests PNG is working fine. IDK what your Can you share a colab that reproducs es the problem?
Thanks, I'm sending a fix for this. |
Hi, I am trying to read image from https: URL, but it seems to be not working, it's showing below error: |
Here's the
|
Marking this issue as stale since it has been open for 14 days with no activity. This issue will be closed if no further activity occurs. |
This is caused because the code generates the bytes to send tries to create a JPEG file, but the image is RGBA.
|
Description of the bug:
Calling
generate_content
on a Gemini Pro Vision model returns an error when it receives a PNG image sayingKeyError: 'RGBA'
which causes another execption sayingOSError: cannot write mode RGBA as JPEG
. This seems to indicate that PNG is not supported, but according to the Gemini API docs, PNG is a supported MIME type. Note that the png example from that docs page doesn't seem to work. It uses acontents
kwarg togenerate_content
, but that argument doesn't exist. Modifying the code to use the right arguments gives the errorgoogle.api_core.exceptions.InvalidArgument: 400 Request contains an invalid argument.
Actual vs expected behavior:
The expected behavior is for this code:
to work successfully. This code was modified from the text from image and text example in the quickstart. Instead, it outputs the KeyError and OSError above. Changing the code to:
Raises a 400 error as described above. This code is modified from that Gemini API Overview
Any other information you'd like to share?
#112 is related to this. Specifically, it deals with my second attempt at solving this problem. This issue is about the fact that generate_content doesn't handle PNG by default even though it is supposedly supported.
The text was updated successfully, but these errors were encountered: