Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Allow PNG-RGBA for Extras Tab#15334

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

@Gourieff
Copy link
Contributor

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:

image
image

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:

image
image

Screenshots/videos:

image

Additional information

Related Issue:Gourieff/sd-webui-reactor#382

Checklist:

existing_pnginfo["parameters"]=parameters

initial_pp=scripts_postprocessing.PostprocessedImage(image_data.convert("RGB"))
initial_pp=scripts_postprocessing.PostprocessedImage(image_data.convert("RGBA"))ifimage_data.mode=="RGBA"elsescripts_postprocessing.PostprocessedImage(image_data.convert("RGB"))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

if image_data.mode != "RGBA":    image_data = image_data.convert("RGB")initial_pp = scripts_postprocessing.PostprocessedImage(image_data)

Copy link
ContributorAuthor

@GourieffGourieffMar 20, 2024
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Yes, I also tried this way, but it throwsValueError: 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

image

@AUTOMATIC1111AUTOMATIC1111 merged commitb80b1cf intoAUTOMATIC1111:devMar 21, 2024
@builder-main
Copy link

builder-main commentedMar 21, 2024
edited
Loading

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 ?

@w-e-ww-e-w mentioned this pull requestApr 30, 2024
4 tasks
@Rabcor
Copy link

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..

#15664 (comment)

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 requestSep 30, 2024
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@AUTOMATIC1111AUTOMATIC1111AUTOMATIC1111 approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@Gourieff@builder-main@Rabcor@AUTOMATIC1111

[8]ページ先頭

©2009-2025 Movatter.jp