Skip to content
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

Added merging of transparent images and post-processing (ADtailer, Hires. fix, etc.). #99

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

new-sankaku
Copy link

  • Added saving process for transparent images created by Layerdiffuse
  • Save transparent images that reflect modifications made by Extensions (Hires, ADtailer)
    Note: Does Hires cause an error if the image size after enlargement is not a multiple of 256? We recommend multiplying 1024*1024 by 1.5 to 1536x1536.
  • When Batch count is set to 2 or more, the previous image is always included in the Image List returned by the webui side. Also,
    since the order is different in ascending/descending order, initialization processing is added to Layerdiffuse. It might cause some problems.
  • The black and white check pattern in the non-transparent image has been changed to 1pixel*1pixel for the convenience of merging corrections.

new-sankaku and others added 8 commits April 16, 2024 00:01
…Extension

・Added saving process for transparent images created by Layerdiffuse.
・Save transparent images that reflect modifications made by Extensions (Hires, ADtailer).
Note: Does Hires cause an error if the image size after enlargement is not a multiple of 256? We recommend multiplying 1024*1024 by 1.5 to 1536x1536.
・When Batch count is set to 2 or more, the previous image is always included in the Image List returned by the webui side. Also, since the order is different in ascending/descending order, initialization processing is added to Layerdiffuse. It might cause some problems.
…net (I tried to prevent the error from occurring, but it does not become a transparent image. Only the error is avoided once)
@new-sankaku
Copy link
Author

You should be able to resolve the issues below.

Could you upload the transparent sample images #7
Can LayerDiffusion be executed after ADetailer? #12
Feature Suggestion: Save/Output the actually transparent image, instead of the one with grid background #28
How to convert the generated img to real transparent img? #31
Only grey background picture generated, cant get transparent backgroud version at the same time. #45
Alpha output does not have ReActor results applied #50
Extension generates only saves image with checkerboard #52
Transparent image not saved to the output folder #77
hope can support output image before layerdiffuse proceed in result #86
Layerdiffuse with ADetailer ? #88
How to save the transparent images in bulk? #94

@starush
Copy link

starush commented May 5, 2024

How to use/activate it? I'm "already up to date", but Prompts from file or textbox gives me non-transparent images only

git pull
remote: Enumerating objects: 85, done.
remote: Counting objects: 100% (85/85), done.
remote: Compressing objects: 100% (57/57), done.
remote: Total 85 (delta 35), reused 52 (delta 25), pack-reused 0
Unpacking objects: 100% (85/85), 76.27 KiB | 1.25 MiB/s, done.
From https://github.com/lllyasviel/stable-diffusion-webui-forge
 * [new branch]        conrevo/gn-patcher-for-early-ad -> origin/conrevo/gn-patcher-for-early-ad
 * [new branch]        depth_fm   -> origin/depth_fm
 * [new branch]        dev2       -> origin/dev2
Already up to date.

@new-sankaku
Copy link
Author

If you want to generate transparent images, you need the "sd-forge-layerdiffuse" functionality. However, this feature is not included in the default extensions of stable-diffusion-webui-forge. Therefore, simply pulling the stable-diffusion-webui-forge repository will not add the sd-forge-layerdiffuse feature.

First, please check if sd-forge-layerdiffuse is already installed. If it is not, follow the installation instructions at the URL below. Since this PR has not yet been merged, you will need to specify the source URL of the PR.

https://github.com/new-sankaku/sd-forge-layerdiffuse

If it is already installed and you're still facing issues, please uninstall it and reinstall it.

INSTALL
image

@starush
Copy link

starush commented May 6, 2024

https://github.com/new-sankaku/sd-forge-layerdiffuse

I noticed that I have installed it from other URL: https://github.com/layerdiffusion/sd-forge-layerdiffuse
And it is up to date (2024-03-08 16:36:24 | latest)
Should I uninstall it and then instal from https://github.com/new-sankaku/sd-forge-layerdiffuse ?

@new-sankaku
Copy link
Author

Yes, the PR has not passed, so you will need to uninstall and reinstall.

@starush
Copy link

starush commented May 6, 2024

Thank you, it is working now. May I ask you what is rebuilt image (there are checkbox to save it)
Is it possible to save transparent image only, without that on checkered background?

@new-sankaku
Copy link
Author

There is no need to check rebuild if you do not use Adetailer or Hires.fix. Adtailer and Hires. fix improve transparent images, but they do not support alpha channels, so they are generated as non-transparent images. In other words, a transparent image cannot be obtained.

For this reason, we reapply the alpha channel of the transparent image to the non-transparent image to restore it to a transparent image. That's what rebuild is all about.

Is it possible to save transparent image only, without that on checkered background?

Are there three images?
1st: 02872-1427398048.png
2nd: 02871-1427398048-transparent.png
3rd:02883--rebuild.png

1st is the first non-transparent image created. I think it's basically unnecessary.
2nd is the first transparent image created. This is sufficient if you do not use Adtailer or Hires.fix.
3rd is the last transparent image created. This is required if you use Adtailer or Hires.fix.

@starush
Copy link

starush commented May 6, 2024

Yes, I unchecked 'Save rebuild image' and now it is not saving. I would be grateful to know about how to avoid saving the first, non-transparent image.

@4as
Copy link

4as commented May 7, 2024

I've noticed that the "rebuild" file doesn't contain the result of the filename pattern like the other two files. Would it be possible add it the generated file? I personally do not use the "Add number to filename when saving" option and instead use only the "Images filename pattern" option, so the rebuild file comes up always being named "--rebuild.png" and gets rewritten on each generation.

@new-sankaku
Copy link
Author

Yes, I unchecked 'Save rebuild image' and now it is not saving. I would be grateful to know about how to avoid saving the first, non-transparent image.

I forgot to mention it, but I think the problem occurred when I tried not to save opaque images. Or maybe I forgot, like I couldn't find the save code...

@new-sankaku
Copy link
Author

I've noticed that the "rebuild" file doesn't contain the result of the filename pattern like the other two files. Would it be possible add it the generated file? I personally do not use the "Add number to filename when saving" option and instead use only the "Images filename pattern" option, so the rebuild file comes up always being named "--rebuild.png" and gets rewritten on each generation.

It might work if you put the Seed here. I'll take a look on Saturday and Sunday.
images.save_image

@halkony
Copy link

halkony commented Jun 3, 2024

+1 for merging this PR so the transparent files are saved in bulk

@GUILINZUHE
Copy link

After the update, Layerdiffuse can now save transparent PNG files in text-to-image. The current issue is that adding Layerdiffuse significantly affects the output results, making the images generated completely different from those produced without Layerdiffusion. Additionally, in image-to-image generation, Layerdiffuse shows obvious defects. The images it generates tend to be overly red, and although it produces backgrounds with checkered patterns, it fails to properly save transparent PNG files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants