(WIP) WebUI extension for ControlNet and T2I-Adapter
This extension is for AUTOMATIC1111's Stable Diffusion web UI, allows the Web UI to add ControlNet to the original Stable Diffusion model to generate images. The addition is on-the-fly, the merging is not required.
ControlNet is a neural network structure to control diffusion models by adding extra conditions.
Thanks & Inspired: kohya-ss/sd-webui-additional-networks
scripts/cldm.py)Upgrade gradio if any ui issues occured: pip install gradio==3.16.2
.pt, .pth, .ckpt or .safetensors) inside the models/ControlNet folder.Currently it supports both full models and trimmed models. Use extract_controlnet.py to extract controlnet from original .pth file.
Pretrained Models: https://huggingface.co/lllyasviel/ControlNet/tree/main/models
Two methods can be used to reduce the model's filesize:
Directly extract controlnet from original .pth file using extract_controlnet.py.
Transfer control from original checkpoint by making difference using extract_controlnet_diff.py.
All type of models can be correctly recognized and loaded. The results of different extraction methods are discussed in https://github.com/lllyasviel/ControlNet/discussions/12 and https://github.com/Mikubill/sd-webui-controlnet/issues/73.
Pre-extracted model: https://huggingface.co/webui/ControlNet-modules-safetensors
Pre-extracted difference model: https://huggingface.co/kohya-ss/ControlNet-diff-modules
| Source | Input | Output |
|---|---|---|
| (no preprocessor) | ![]() | ![]() |
| (no preprocessor) | ![]() | ![]() |
![]() | ![]() | ![]() |
![]() | ![]() | ![]() |
![]() | ![]() | ![]() |
![]() | ![]() | ![]() |
![]() | ![]() | ![]() |
(From TencentARC/T2I-Adapter)
T2I-Adapter is a small network that can provide additional guidance for pre-trained text-to-image models.
To use T2I-Adapter models:
| Adapter | Config |
|---|---|
| t2iadapter_canny_sd14v1.pth | sketch_adapter_v14.yaml |
| t2iadapter_sketch_sd14v1.pth | sketch_adapter_v14.yaml |
| t2iadapter_seg_sd14v1.pth | image_adapter_v14.yaml |
| t2iadapter_keypose_sd14v1.pth | image_adapter_v14.yaml |
| t2iadapter_openpose_sd14v1.pth | image_adapter_v14.yaml |
| t2iadapter_color_sd14v1.pth | t2iadapter_color_sd14v1.yaml |
| t2iadapter_style_sd14v1.pth | t2iadapter_style_sd14v1.yaml |
Note:
| Source | Input | Output |
|---|---|---|
| (no preprocessor) | ![]() | ![]() |
| (no preprocessor) | ![]() | ![]() |
| (no preprocessor) | ![]() | ![]() |
| (no preprocessor) | ![]() | ![]() |
![]() | ![]() | ![]() |
![]() | (clip, non-image) | ![]() |
Examples by catboxanon, no tweaking or cherrypicking. (Color Guidance)
| Image | Disabled | Enabled |
|---|---|---|
![]() | ![]() | ![]() |
![]() | ![]() | ![]() |
--xformers enabled, and Low VRAM mode ticked in the UI, goes up to 768x832The original ControlNet applies control to both conditional (cond) and unconditional (uncond) parts. Enabling this option will make the control only apply to the cond part. Some experiments indicate that this approach improves image quality.
To enable this option, tick Enable CFG-Based guidance for ControlNet in the settings.
Note that you need to use a low cfg scale/guidance scale (such as 3-5) and proper weight tuning to get good result.
Guess Mode is CFG Based ControlNet + Exponential decay in weighting.
See issue https://github.com/Mikubill/sd-webui-controlnet/issues/236 for more details.
Original introduction from controlnet:
The "guess mode" (or called non-prompt mode) will completely unleash all the power of the very powerful ControlNet encoder.
In this mode, you can just remove all prompts, and then the ControlNet encoder will recognize the content of the input control map, like depth map, edge map, scribbles, etc.
This mode is very suitable for comparing different methods to control stable diffusion because the non-prompted generating task is significantly more difficult than prompted task. In this mode, different methods' performance will be very salient.
For this mode, we recommend to use 50 steps and guidance scale between 3 and 5.
This option allows multiple ControlNet inputs for a single generation. To enable this option, change Multi ControlNet: Max models amount (requires restart) in the settings. Note that you will need to restart the WebUI for changes to take effect.
| Source A | Source B | Output |
|---|---|---|
![]() | ![]() | ![]() |
Weight is the weight of the controlnet "influence". It's analogous to prompt attention/emphasis. E.g. (myprompt: 1.2). Technically, it's the factor by which to multiply the ControlNet outputs before merging them with original SD Unet.
Guidance Start/End is the percentage of total steps the controlnet applies (guidance strength = guidance end). It's analogous to prompt editing/shifting. E.g. [myprompt::0.8] (It applies from the beginning until 80% of total steps)
This extension can accept txt2img or img2img tasks via API or external extension call. Note that you may need to enable Allow other scripts to control this extension in settings for external calls.
To use the API: start WebUI with argument --api and go to http://webui-address/docs for documents or checkout examples.
To use external call: Checkout Wiki
Tested with pytorch nightly: https://github.com/Mikubill/sd-webui-controlnet/pull/143#issuecomment-1435058285
To use this extension with mps and normal pytorch, currently you may need to start WebUI with --no-half.
Quick start:
# Run WebUI in API mode
python launch.py --api --xformers
# Install/Upgrade transformers
pip install -U transformers
# Install deps
pip install langchain==0.0.101 openai
# Run exmaple
python example/chatgpt.py
(top 30 of 46)
Python
95.1%
Cuda
3.2%
C++
1.5%
(WIP) WebUI extension for ControlNet and T2I-Adapter
This extension is for AUTOMATIC1111's Stable Diffusion web UI, allows the Web UI to add ControlNet to the original Stable Diffusion model to generate images. The addition is on-the-fly, the merging is not required.
ControlNet is a neural network structure to control diffusion models by adding extra conditions.
Thanks & Inspired: kohya-ss/sd-webui-additional-networks
scripts/cldm.py)Upgrade gradio if any ui issues occured: pip install gradio==3.16.2
.pt, .pth, .ckpt or .safetensors) inside the models/ControlNet folder.Currently it supports both full models and trimmed models. Use extract_controlnet.py to extract controlnet from original .pth file.
Pretrained Models: https://huggingface.co/lllyasviel/ControlNet/tree/main/models
Two methods can be used to reduce the model's filesize:
Directly extract controlnet from original .pth file using extract_controlnet.py.
Transfer control from original checkpoint by making difference using extract_controlnet_diff.py.
All type of models can be correctly recognized and loaded. The results of different extraction methods are discussed in https://github.com/lllyasviel/ControlNet/discussions/12 and https://github.com/Mikubill/sd-webui-controlnet/issues/73.
Pre-extracted model: https://huggingface.co/webui/ControlNet-modules-safetensors
Pre-extracted difference model: https://huggingface.co/kohya-ss/ControlNet-diff-modules
| Source | Input | Output |
|---|---|---|
| (no preprocessor) | ![]() | ![]() |
| (no preprocessor) | ![]() | ![]() |
![]() | ![]() | ![]() |
![]() | ![]() | ![]() |
![]() | ![]() | ![]() |
![]() | ![]() | ![]() |
![]() | ![]() | ![]() |
(From TencentARC/T2I-Adapter)
T2I-Adapter is a small network that can provide additional guidance for pre-trained text-to-image models.
To use T2I-Adapter models:
| Adapter | Config |
|---|---|
| t2iadapter_canny_sd14v1.pth | sketch_adapter_v14.yaml |
| t2iadapter_sketch_sd14v1.pth | sketch_adapter_v14.yaml |
| t2iadapter_seg_sd14v1.pth | image_adapter_v14.yaml |
| t2iadapter_keypose_sd14v1.pth | image_adapter_v14.yaml |
| t2iadapter_openpose_sd14v1.pth | image_adapter_v14.yaml |
| t2iadapter_color_sd14v1.pth | t2iadapter_color_sd14v1.yaml |
| t2iadapter_style_sd14v1.pth | t2iadapter_style_sd14v1.yaml |
Note:
| Source | Input | Output |
|---|---|---|
| (no preprocessor) | ![]() | ![]() |
| (no preprocessor) | ![]() | ![]() |
| (no preprocessor) | ![]() | ![]() |
| (no preprocessor) | ![]() | ![]() |
![]() | ![]() | ![]() |
![]() | (clip, non-image) | ![]() |
Examples by catboxanon, no tweaking or cherrypicking. (Color Guidance)
| Image | Disabled | Enabled |
|---|---|---|
![]() | ![]() | ![]() |
![]() | ![]() | ![]() |
--xformers enabled, and Low VRAM mode ticked in the UI, goes up to 768x832The original ControlNet applies control to both conditional (cond) and unconditional (uncond) parts. Enabling this option will make the control only apply to the cond part. Some experiments indicate that this approach improves image quality.
To enable this option, tick Enable CFG-Based guidance for ControlNet in the settings.
Note that you need to use a low cfg scale/guidance scale (such as 3-5) and proper weight tuning to get good result.
Guess Mode is CFG Based ControlNet + Exponential decay in weighting.
See issue https://github.com/Mikubill/sd-webui-controlnet/issues/236 for more details.
Original introduction from controlnet:
The "guess mode" (or called non-prompt mode) will completely unleash all the power of the very powerful ControlNet encoder.
In this mode, you can just remove all prompts, and then the ControlNet encoder will recognize the content of the input control map, like depth map, edge map, scribbles, etc.
This mode is very suitable for comparing different methods to control stable diffusion because the non-prompted generating task is significantly more difficult than prompted task. In this mode, different methods' performance will be very salient.
For this mode, we recommend to use 50 steps and guidance scale between 3 and 5.
This option allows multiple ControlNet inputs for a single generation. To enable this option, change Multi ControlNet: Max models amount (requires restart) in the settings. Note that you will need to restart the WebUI for changes to take effect.
| Source A | Source B | Output |
|---|---|---|
![]() | ![]() | ![]() |
Weight is the weight of the controlnet "influence". It's analogous to prompt attention/emphasis. E.g. (myprompt: 1.2). Technically, it's the factor by which to multiply the ControlNet outputs before merging them with original SD Unet.
Guidance Start/End is the percentage of total steps the controlnet applies (guidance strength = guidance end). It's analogous to prompt editing/shifting. E.g. [myprompt::0.8] (It applies from the beginning until 80% of total steps)
This extension can accept txt2img or img2img tasks via API or external extension call. Note that you may need to enable Allow other scripts to control this extension in settings for external calls.
To use the API: start WebUI with argument --api and go to http://webui-address/docs for documents or checkout examples.
To use external call: Checkout Wiki
Tested with pytorch nightly: https://github.com/Mikubill/sd-webui-controlnet/pull/143#issuecomment-1435058285
To use this extension with mps and normal pytorch, currently you may need to start WebUI with --no-half.
Quick start:
# Run WebUI in API mode
python launch.py --api --xformers
# Install/Upgrade transformers
pip install -U transformers
# Install deps
pip install langchain==0.0.101 openai
# Run exmaple
python example/chatgpt.py
(top 30 of 46)
Python
95.1%
Cuda
3.2%
C++
1.5%