Open Pjumpod opened 1 month ago
Hi @Pjumpod
I've tested the code and images you mentioned, and it works correctly, producing a light blue background. You can check it out in this gist. I don't believe the issue lies with BytesIO. The format parameter used when saving the PIL image ensures that transparency is preserved.
Thanks
@manojssmk the light blue that show in this issue is the color from my app background, not the actually picture.
The picture should not have any background. (Transparency.)
@manojssmk you might try with your gist again with my test set pictures.
@manojssmk you have to use the picture with rgba mode which it is the blank background. (Background should not have any color).
When you got the light blue background, that also showing your answer is still wrong.
Hi @Pjumpod
Yes, you're correct. The image with a blank background that was passed to the model is producing an incorrect output, showing the background as black. You can find the code in this gist.
Thanks
Hi @Pjumpod
Yes, you're correct. The image with a blank background that was passed to the model is producing an incorrect output, showing the background as black. You can find the code in this gist.
Thanks
@manojssmk @MarkDaoust this is great, now we are in sync. I think this can fix on the server site to convert the picture to RGBA mode follow by mime type. or I am not sure if anything can fix on API at client site?
I haven't looked into this. But the behavior will be affected by: https://github.com/google-gemini/generative-ai-python/pull/570, that PR ensures that we don't process the images before sending them.
Try installing from main:
pip install git+https://github.com/google-gemini/generative-ai-python
But it's possible that the PR doesn't change anything: the API may handle the alpha channel by showing the model the picture over a black background. If the API isn't passing an actual alpha channel, there's not much I can do in the SDK.
Testing a bit, I'm just not convinced that the model uses the alpha channel at all.
pro
says "I can see it, maybe there's something wrong with your display"b/369593779
Testing a bit, I'm just not convinced that the model uses the alpha channel at all.
- If I make an image totally transparent the model still describes it.
- If I ask it why I can't see anything in the image
pro
says "I can see it, maybe there's something wrong with your display"- If I set different colors of transparent sections, the model reports the "correct" background color.
do you have any idea or if google can help?
I think this is happening in the API backend. I think there's nothing we can do from out here.
Do you have any idea to report this bug to backend?
@Pjumpod , I did this morning. The b/369593779 in my previous message was an internal bug reference.
@MarkDaoust long time no see, Do you have any update from the API backend?
Description of the bug:
My code is
and here is the output/ `
`
From this link, It should upload from generate_content as PNG and transparency mode. as show in #523 but when I got the output of "describe the image", I found the word, "on black background" which is mean the PNG with RGBA was convert to RGB.
Actual vs expected behavior:
expect to upload as PNG with RGBA. but actual still RGB.
Any other information you'd like to share?
google-generativeai 0.8.1
ByeIO may not able to decode the alpha channel of an image. I attached this in the code review. and Here is from stackoverflow.