-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
fix extra batch mode P Transparency #15664
Conversation
red, green, blue = transparency TypeError: cannot unpack non-iterable int object
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worked for my sample files in #6534 (comment)
Not seeing any detrimental effects at all. It does change some behavior between batch and single image processing though.
Namely that batches now try to preserve alpha while single image processing does not, this is in my opinion an improvement though and maybe it'd be worth it to figure out a way to get transparency working on single image processing as well.
about the single image basically the cause of the losing of transparency for P mode images is due the the gradio convertion the input image into RGBA next depending on the process module you use such as upscale it workd for in this branch https://github.com/AUTOMATIC1111/stable-diffusion-webui/tree/more-extra-transparency-fix-again what I did is disable Gradios auto converting of image to RGBA, by disalbeing the issue is as far as I'm aware disalbeing so if there's a way of preserving the another method is to set
from RGBA bask to RGB the change to RGB was done in
yeah it's kind of ironic making RGBA possible for some modules actually breaks transparency for other image mode |
Actually, here's an extra sample file to test this. And here's the old sample file I am still using here as well: Unmodified 1.9.3 baselineWith this, we have established that this commit: #15334 Is only enabling transparency for the reactor extension, not upscaling. #15664 applied to 1.9.3Identical to baseline. #15334 undone for 1.9.3Interestingly undoing the commit made it preserve transparency on one sample file but not the other when upscaling. #15664 applied and #15334 undone for 1.9.3Identical to above. master...more-extra-transparency-fix-again changes applied to 1.9.3One of the sample files still isn't transparent. Reactor successfully preserves transparency but fails to apply any changes to the face. |
no we have not established that what that PR dose it's enabling possibility of "Proper" RGBA support for single image input for ANY module as long as the module "itself" support transparency upscaller depending on the upscaler method you use, and most dose not support transparency (Alpha Channel) the reason you were able to get desirable transparency results is mostly a combination of luck your image is a P mode image
which uses a different method of encoding transparency then RGBA the lucky part is if the color palettes transparency is save and re-apply back to the image you would get the transparency back you can test it with different upscaling methods the more a particular message shifts the color the more likely that the transparency will be ruined some of the test image you sent, image is basically composed of non don't transparent color parts
test of img1 with different upscaling methods if you are "lucky" and the color of the output image has the same color pallette as the input, it we then restore the info back transparency gets restored the issue is not with that PR it's issue with lots of modules does not support transparency
in fact after taht PR it has better transparency support the reason that PR accidentally break transparency support for certain images you are using the issue with gradio preprocess auto converting image into RGBA, and when later down the pipeling after going through upstairs that does not support transparency (Alpha) is lost so the way I found to "fix" that is to take converting image into our own hands and not handled gradio what I would consider doing would be to patch gradio so that we have more contorl but the thing is I'm not entirely sure if doing all this is worth it as transparency is at best support finicky
personally I think it might be a good idea to just remove the transparency altogether because it could potentially ruin the image |
Yeah, including transparency is never going to be harmful, it's pretty hard to make an opaque image transparent, but the reverse is extremely easy, so it's never a bad thing. But yeah, this PR solves the error it set out to solve perfectly. |
Description
fix
when
enable_pnginfo
using extra "batch" theexisting_pnginfo
will also be restoredwhen converting a none RGB mode image to
RGB
someexisting_pnginfo
keys will also have to be converted to make it workthis is the case with a
P
mode image withTransparency
keythe issue is we currently extract the
existing_pnginfo
"before" we convert the image intoRGB
modeas suche the
existing_pnginfo
we restore later will have the old unconvertedexisting_pnginfo
fromP
modein the case of
P
-> toRGB
ifTransparency : 0
key exist, it will have to be converted in to a 3 value tuple(0, 0, 0)
this is why some users are seeing error
the easiest solution I found is to convert the image to the to our desired mode before parseing the info with
read_info_from_image()
I have tested with the 4 formats of images generated by webui (png jpg webp avif) the info (the parts we wish to preserve) read after conversion seems to be intact
test images
test images.zip
test from #15421 #6534
2 p mode image with and without transparency key
before the PR the image with transparency key should faile to save using
extra batch
should be fixed after the PR
note
I'm not an expert on image formats it's it is possible this modification can potentially messed up other things
Checklist: