Allow PNG-RGBA for Extras Tab#15334
Merged
AUTOMATIC1111 merged 4 commits intoAUTOMATIC1111:devfrom Mar 21, 2024
Merged
Conversation
AUTOMATIC1111
requested changes
Mar 20, 2024
| existing_pnginfo["parameters"] = parameters | ||
|
|
||
| initial_pp = scripts_postprocessing.PostprocessedImage(image_data.convert("RGB")) | ||
| initial_pp = scripts_postprocessing.PostprocessedImage(image_data.convert("RGBA")) if image_data.mode == "RGBA" else scripts_postprocessing.PostprocessedImage(image_data.convert("RGB")) |
Owner
There was a problem hiding this comment.
if image_data.mode != "RGBA":
image_data = image_data.convert("RGB")
initial_pp = scripts_postprocessing.PostprocessedImage(image_data)
Contributor
Author
There was a problem hiding this comment.
Yes, I also tried this way, but it throws ValueError: Operation on closed image during the test:
*** API error: POST: http://127.0.0.1:7860/sdapi/v1/extra-single-image {'error': 'ValueError', 'detail': '', 'body': '', 'errors': 'Operation on closed image'}
Traceback (most recent call last):
File "C:\_NN\A1111\venv\lib\site-packages\anyio\streams\memory.py", line 98, in receive
return self.receive_nowait()
File "C:\_NN\A1111\venv\lib\site-packages\anyio\streams\memory.py", line 93, in receive_nowait
raise WouldBlock
anyio.WouldBlock
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\_NN\A1111\venv\lib\site-packages\starlette\middleware\base.py", line 78, in call_next
message = await recv_stream.receive()
File "C:\_NN\A1111\venv\lib\site-packages\anyio\streams\memory.py", line 118, in receive
raise EndOfStream
anyio.EndOfStream
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\_NN\A1111\modules\api\api.py", line 186, in exception_handling
return await call_next(request)
File "C:\_NN\A1111\venv\lib\site-packages\starlette\middleware\base.py", line 84, in call_next
raise app_exc
File "C:\_NN\A1111\venv\lib\site-packages\starlette\middleware\base.py", line 70, in coro
await self.app(scope, receive_or_disconnect, send_no_error)
File "C:\_NN\A1111\venv\lib\site-packages\starlette\middleware\base.py", line 108, in __call__
response = await self.dispatch_func(request, call_next)
File "C:\_NN\A1111\modules\api\api.py", line 150, in log_and_time
res: Response = await call_next(req)
File "C:\_NN\A1111\venv\lib\site-packages\starlette\middleware\base.py", line 84, in call_next
raise app_exc
File "C:\_NN\A1111\venv\lib\site-packages\starlette\middleware\base.py", line 70, in coro
await self.app(scope, receive_or_disconnect, send_no_error)
File "C:\_NN\A1111\venv\lib\site-packages\starlette\middleware\cors.py", line 84, in __call__
await self.app(scope, receive, send)
File "C:\_NN\A1111\venv\lib\site-packages\starlette\middleware\gzip.py", line 24, in __call__
await responder(scope, receive, send)
File "C:\_NN\A1111\venv\lib\site-packages\starlette\middleware\gzip.py", line 44, in __call__
await self.app(scope, receive, self.send_with_gzip)
File "C:\_NN\A1111\venv\lib\site-packages\starlette\middleware\exceptions.py", line 79, in __call__
raise exc
File "C:\_NN\A1111\venv\lib\site-packages\starlette\middleware\exceptions.py", line 68, in __call__
await self.app(scope, receive, sender)
File "C:\_NN\A1111\venv\lib\site-packages\fastapi\middleware\asyncexitstack.py", line 21, in __call__
raise e
File "C:\_NN\A1111\venv\lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in __call__
await self.app(scope, receive, send)
File "C:\_NN\A1111\venv\lib\site-packages\starlette\routing.py", line 718, in __call__
await route.handle(scope, receive, send)
File "C:\_NN\A1111\venv\lib\site-packages\starlette\routing.py", line 276, in handle
await self.app(scope, receive, send)
File "C:\_NN\A1111\venv\lib\site-packages\starlette\routing.py", line 66, in app
response = await func(request)
File "C:\_NN\A1111\venv\lib\site-packages\fastapi\routing.py", line 237, in app
raw_response = await run_endpoint_function(
File "C:\_NN\A1111\venv\lib\site-packages\fastapi\routing.py", line 165, in run_endpoint_function
return await run_in_threadpool(dependant.call, **values)
File "C:\_NN\A1111\venv\lib\site-packages\starlette\concurrency.py", line 41, in run_in_threadpool
return await anyio.to_thread.run_sync(func, *args)
File "C:\_NN\A1111\venv\lib\site-packages\anyio\to_thread.py", line 33, in run_sync
return await get_asynclib().run_sync_in_worker_thread(
File "C:\_NN\A1111\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 877, in run_sync_in_worker_thread
return await future
File "C:\_NN\A1111\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 807, in run
result = context.run(func, *args)
File "C:\_NN\A1111\modules\api\api.py", line 566, in extras_single_image_api
return models.ExtrasSingleImageResponse(image=encode_pil_to_base64(result[0][0]), html_info=result[1])
File "C:\_NN\A1111\modules\api\api.py", line 113, in encode_pil_to_base64
image.save(output_bytes, format="PNG", pnginfo=(metadata if use_metadata else None), quality=opts.jpeg_quality)
File "C:\_NN\A1111\venv\lib\site-packages\PIL\Image.py", line 2395, in save
self._ensure_mutable()
File "C:\_NN\A1111\venv\lib\site-packages\PIL\Image.py", line 610, in _ensure_mutable
self._copy()
File "C:\_NN\A1111\venv\lib\site-packages\PIL\Image.py", line 603, in _copy
self.load()
File "C:\_NN\A1111\venv\lib\site-packages\PIL\ImageFile.py", line 162, in load
pixel = Image.Image.load(self)
File "C:\_NN\A1111\venv\lib\site-packages\PIL\Image.py", line 872, in load
return self.im.pixel_access(self.readonly)
File "C:\_NN\A1111\venv\lib\site-packages\PIL\_util.py", line 19, in __getattr__
raise self.ex
ValueError: Operation on closed image
AUTOMATIC1111
approved these changes
Mar 21, 2024
AUTOMATIC1111
added a commit
that referenced
this pull request
Mar 21, 2024
|
I get a related issue with a grayscale upscaling model "RuntimeError: Given groups=1, weight of size [64, 1, 3, 3], expected input[1, 3, 192, 192] to have 1 channels, but got 3 channels instead". Is this related ? How should it be implemented ? |
4 tasks
|
I discovered that this commit is breaking transparency support for the upscalers, and finding new flaws in the pre-existing support for transparency there as well.. Maybe there's a way to leverage the changes of this commit so the upscalers can benefit from it too instead of it breaking their transparency support? 🤔 |
ruchej
pushed a commit
to ruchej/stable-diffusion-webui
that referenced
this pull request
Sep 30, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
Hello guys!
There's a small issue when we want to swap a face to PNG images (with RGBA) - (in particular via ReActor)
By default SD WebUI cuts Alpha-channel when we postprocess the image via the Extras Tab
E.g.:
I load the image with transparency and want to swap the face
So I get the following result:
As we can see the alpha channel is lost
With this little fix we can operate with all 4 channels of the input image - and the result is:
Screenshots/videos:
Additional information
Related Issue: Gourieff/sd-webui-reactor#382
Checklist: