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

WEBUI插件支持 #150

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions sd-webui-hunyuan-dit/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 sethgggg

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
68 changes: 68 additions & 0 deletions sd-webui-hunyuan-dit/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Hunyuan extension for sd-webui

The extension helps you to use [Hunyuan DiT Model](https://github.com/Tencent/HunyuanDiT) in [Stable-diffusion-webui](https://github.com/AUTOMATIC1111/stable-diffusion-webui):

### Features

- Core
- [x] [Txt2Img]
- [x] [Img2Img]
- [] [LORA]
- [] [ControlNet]
- [] [HiresUpscaler]
- Advanced
- [] [MultiDiffusion]
- [] [Adetailer]

### Installation

1. You can install this extension via the webui extension downloader by copying the git repository ```https://github.com/sethgggg/sd-webui-hunyuan-dit.git```.

![install](examples/20240709-000053.jpg)

2. Download the HunyuanDiT model from [Huggingface](https://huggingface.co/Tencent-Hunyuan/HunyuanDiT-v1.2-Diffusers) to local storage, the default storage location is in ```models/hunyuan``` of webui folder. You can change the default storage location via the settings card of the webui.

![folder](examples/20240708-235015.jpg)

![settings](examples/20240708-235001.jpg)

3. You have to place the transformer model in ```models/Stable-Diffusion```, which is the main storage location of checkpoints. If you have fine-tuned a new model, you can also place the transformer model in the same folder and then you could select the model here.

4. Find the HunyuanDiT card and enable them, if you want to use stable diffusion models, remember to disable the HunyuanDiT model.

![enable](examples/20240708-235013.jpg)

5. This project is use the diffusers as inference backend, thus we support the following samplers:

| Sampler Name | Sampler Instance in diffusers |
|-------------------------|------------------------------------------------------------------------------|
| Euler a | EulerAncestralDiscreteScheduler() |
| Euler | EulerDiscreteScheduler() |
| LMS | LMSDiscreteScheduler() |
| Heun | HeunDiscreteScheduler() |
| DPM2 | KDPM2DiscreteScheduler() |
| DPM2 a | KDPM2AncestralDiscreteScheduler() |
| DPM++ SDE | DPMSolverSinglestepScheduler() |
| DPM++ 2M | DPMSolverMultistepScheduler() |
| DPM++ 2S a | DPMSolverSinglestepScheduler() |
| LMS Karras | LMSDiscreteScheduler(use_karras_sigmas=True) |
| DPM2 Karras | KDPM2DiscreteScheduler(use_karras_sigmas=True) |
| DPM2 a Karras | KDPM2AncestralDiscreteScheduler(use_karras_sigmas=True) |
| DPM++ SDE Karras | DPMSolverSinglestepScheduler(use_karras_sigmas=True) |
| DPM++ 2M Karras | DPMSolverMultistepScheduler(use_karras_sigmas=True) |
| DPM++ 2S a Karras | DPMSolverSinglestepScheduler(use_karras_sigmas=True) |
| DDIM | DDIMScheduler() |
| UniPC | UniPCMultistepScheduler() |
| DPM++ 2M SDE Karras | DPMSolverMultistepScheduler(use_karras_sigmas=True, algorithm_type="sde-dpmsolver++") |
| DPM++ 2M SDE | DPMSolverMultistepScheduler(algorithm_type="sde-dpmsolver++") |
| LCM | LCMScheduler() |

### Examples

⚪ Txt2img: generating images, you can use the webui style prompts to generate

![txt2img](examples/20240708-235005.jpg)

⚪ Img2img: given a image, you can use the Hunyuan DiT model to generate more images.

![img2img](examples/20240708-234944.jpg)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sd-webui-hunyuan-dit/examples/20240708-235013.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sd-webui-hunyuan-dit/examples/20240708-235015.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from modules import prompt_parser, shared

def get_learned_conditioning_hunyuan(batch: prompt_parser.SdConditioning | list[str]):
clip_l_conds, clip_l_attention = shared.clip_l_model(batch)
t5_conds, t5_attention = shared.mt5_model(batch)
return {"crossattn":clip_l_conds, "mask":clip_l_attention, "crossattn_2":t5_conds, "mask_2":t5_attention}
Loading