Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
7ce3745
Check in 23-10-05
UmerHA Oct 5, 2023
70d58d9
check-in 23-10-06
UmerHA Oct 6, 2023
762bdfd
check-in 23-10-07 2pm
UmerHA Oct 7, 2023
267ca00
check-in 23-10-08
UmerHA Oct 8, 2023
5356478
check-in 231009T1200
UmerHA Oct 9, 2023
b30120c
check-in 230109
UmerHA Oct 9, 2023
7b67ceb
checkin 231010
UmerHA Oct 10, 2023
f4d8d62
init + forward run
UmerHA Oct 11, 2023
9c17549
checkin
UmerHA Oct 16, 2023
cc40b55
checkin
UmerHA Oct 18, 2023
95b7425
ControlNetXSModel is now saveable+loadable
UmerHA Oct 19, 2023
0e7c848
Forward works
UmerHA Oct 19, 2023
969e7e8
checkin
UmerHA Oct 19, 2023
111fa2d
Pipeline works with `no_control=True`
UmerHA Oct 20, 2023
34b7dbb
Merge branch 'huggingface:main' into controlnet-xs
UmerHA Oct 20, 2023
6270bc0
checkin
UmerHA Oct 23, 2023
7ae8a46
Merge branch 'controlnet-xs' of https://github.com/UmerHA/diffusers i…
UmerHA Oct 23, 2023
9267388
debug: save intermediate outputs of resnet
UmerHA Oct 27, 2023
8bcb3d0
checkin
UmerHA Oct 27, 2023
a52e605
Understood time error + fixed connection error
UmerHA Nov 2, 2023
b408dbc
checkin
UmerHA Nov 2, 2023
e0ad61b
checkin 231106T1600
UmerHA Nov 6, 2023
d76881a
turned off detailled debug prints
UmerHA Nov 6, 2023
202d3de
time debug logs
UmerHA Nov 7, 2023
8996cf4
small fix
UmerHA Nov 7, 2023
f54ac82
Separated control_scale for connections/time
UmerHA Nov 8, 2023
7654c32
simplified debug logging
UmerHA Nov 9, 2023
cc1a706
Full denoising works with control scale = 0
UmerHA Nov 12, 2023
05f9926
aligned logs
UmerHA Nov 12, 2023
34ecd9a
Added control_attention_head_dim param
UmerHA Nov 13, 2023
c975ea8
Passing n_heads instead of dim_head into ctrl unet
UmerHA Nov 13, 2023
535149d
Fixed ctrl midblock bug
UmerHA Nov 13, 2023
1583c13
Cleanup
UmerHA Nov 13, 2023
73a7b99
Fixed time dtype bug
UmerHA Nov 13, 2023
e20d4b5
checkin
UmerHA Nov 13, 2023
56e9b59
1. from_unet, 2. base passed, 3. all unet params
UmerHA Nov 14, 2023
2cc2cfb
checkin
UmerHA Nov 14, 2023
0bb9457
Finished docstrings
UmerHA Nov 14, 2023
39257c5
cleanup
UmerHA Nov 14, 2023
e4f412e
make style
UmerHA Nov 14, 2023
031aab3
Merge remote-tracking branch 'upstream/main' into controlnet-xs
UmerHA Nov 14, 2023
e032fa0
checkin
UmerHA Nov 15, 2023
e543a54
more tests pass
UmerHA Nov 16, 2023
6945de8
Fixed tests
UmerHA Nov 16, 2023
1a0c4ad
removed debug logs
UmerHA Nov 16, 2023
7cc437e
make style + quality
UmerHA Nov 16, 2023
0f655bb
make fix-copies
UmerHA Nov 16, 2023
cf0b6d5
fixed documentation
UmerHA Nov 17, 2023
3cb6d32
added cnxs to doc toc
UmerHA Nov 17, 2023
f11e0e7
added control start/end param
UmerHA Nov 17, 2023
7b05af4
Update controlnetxs_sdxl.md
UmerHA Nov 17, 2023
5f99f79
tried to fix copies..
UmerHA Nov 17, 2023
85dc485
Fixed norm_num_groups in from_unet
UmerHA Nov 17, 2023
c76eb35
added sdxl-depth test
UmerHA Nov 17, 2023
08668ae
created SD2.1 controlnet-xs pipeline
UmerHA Nov 20, 2023
c9d7e7d
Merge branch 'huggingface:main' into controlnet-xs
UmerHA Nov 21, 2023
ad1f39f
re-added debug logs
UmerHA Nov 22, 2023
76e9b96
Merge branch 'main' into controlnet-xs
UmerHA Nov 22, 2023
37cbe6c
Adjusting group norm ; readded logs
UmerHA Nov 23, 2023
d2c2635
Added debug log statements
UmerHA Nov 24, 2023
f794113
removed debug logs ; started tests for sd2.1
UmerHA Nov 27, 2023
e6de144
updated sd21 tests
UmerHA Nov 27, 2023
0ba4b03
fixed tests
UmerHA Nov 28, 2023
412c772
fixed tests
UmerHA Nov 28, 2023
3776ce7
slightly increased error tolerance for 1 test
UmerHA Nov 28, 2023
6897ea9
Merge branch 'main' into controlnet-xs
UmerHA Nov 28, 2023
17a12ce
make style & quality
UmerHA Nov 28, 2023
a884e87
Added docs for CNXS-SD
UmerHA Nov 28, 2023
e6dc473
make fix-copies
UmerHA Nov 28, 2023
b598273
Fixed sd compile test ; fixed gradient ckpointing
UmerHA Nov 28, 2023
b75e623
vae downs = cnxs conditioning downs; removed guess
UmerHA Nov 28, 2023
0f2a05f
make style & quality
UmerHA Nov 28, 2023
f59231c
Fixed tests
UmerHA Nov 28, 2023
165a358
fixed test
UmerHA Nov 28, 2023
8416484
Merge branch 'main' into controlnet-xs
UmerHA Nov 28, 2023
a2d5a52
Incorporated review feedback
UmerHA Nov 30, 2023
a5d94d7
simplified control model surgery
UmerHA Nov 30, 2023
87a3254
fixed tests & make style / quality
UmerHA Nov 30, 2023
d8e723b
Updated docs; deleted pip & cursor files
UmerHA Nov 30, 2023
7b00646
Rolled back minimal change to resnet
UmerHA Nov 30, 2023
d8cc418
Update resnet.py
UmerHA Nov 30, 2023
aacf54e
Update resnet.py
UmerHA Nov 30, 2023
d05be07
Merge branch 'main' into controlnet-xs
UmerHA Nov 30, 2023
5997cf9
Update src/diffusers/models/controlnetxs.py
UmerHA Dec 1, 2023
40e099a
Update src/diffusers/models/controlnetxs.py
UmerHA Dec 1, 2023
b789646
Incorporated review feedback
UmerHA Dec 4, 2023
a3bd017
Merge branch 'main' into controlnet-xs
UmerHA Dec 4, 2023
06bfe12
Update docs/source/en/api/pipelines/controlnetxs_sdxl.md
UmerHA Dec 4, 2023
4e9448a
Update docs/source/en/api/pipelines/controlnetxs.md
UmerHA Dec 4, 2023
348bedb
Update docs/source/en/api/pipelines/controlnetxs.md
UmerHA Dec 4, 2023
167b767
Update docs/source/en/api/pipelines/controlnetxs.md
UmerHA Dec 4, 2023
40744c9
Update src/diffusers/models/controlnetxs.py
UmerHA Dec 4, 2023
bab91cb
Update src/diffusers/models/controlnetxs.py
UmerHA Dec 4, 2023
bf976d0
Update src/diffusers/pipelines/controlnet_xs/pipeline_controlnet_xs.py
UmerHA Dec 4, 2023
dfa97f0
Update docs/source/en/api/pipelines/controlnetxs.md
UmerHA Dec 4, 2023
eb8dd2b
Update src/diffusers/pipelines/controlnet_xs/pipeline_controlnet_xs_s…
UmerHA Dec 4, 2023
58ea5ab
Incorporated doc feedback
UmerHA Dec 4, 2023
7e35ccf
Merge branch 'main' into controlnet-xs
UmerHA Dec 4, 2023
51e4fdd
Merge branch 'main' into controlnet-xs
UmerHA Dec 6, 2023
83a2b11
Merge branch 'main' into controlnet-xs
DN6 Dec 6, 2023
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
4 changes: 4 additions & 0 deletions docs/source/en/_toctree.yml
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,10 @@
title: ControlNet
- local: api/pipelines/controlnet_sdxl
title: ControlNet with Stable Diffusion XL
- local: api/pipelines/controlnetxs
title: ControlNet-XS
- local: api/pipelines/controlnetxs_sdxl
title: ControlNet-XS with Stable Diffusion XL
- local: api/pipelines/cycle_diffusion
title: Cycle Diffusion
- local: api/pipelines/dance_diffusion
Expand Down
39 changes: 39 additions & 0 deletions docs/source/en/api/pipelines/controlnetxs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!--Copyright 2023 The HuggingFace Team. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
-->

# ControlNet-XS

ControlNet-XS was introduced in [ControlNet-XS](https://vislearn.github.io/ControlNet-XS/) by Denis Zavadski and Carsten Rother. It is based on the observation that the control model in the [original ControlNet](https://huggingface.co/papers/2302.05543) can be made much smaller and still produce good results.

Like the original ControlNet model, you can provide an additional control image to condition and control Stable Diffusion generation. For example, if you provide a depth map, the ControlNet model generates an image that'll preserve the spatial information from the depth map. It is a more flexible and accurate way to control the image generation process.

ControlNet-XS generates images with comparable quality to a regular ControlNet, but it is 20-25% faster ([see benchmark](https://github.com/UmerHA/controlnet-xs-benchmark/blob/main/Speed%20Benchmark.ipynb) with StableDiffusion-XL) and uses ~45% less memory.

Here's the overview from the [project page](https://vislearn.github.io/ControlNet-XS/):

*With increasing computing capabilities, current model architectures appear to follow the trend of simply upscaling all components without validating the necessity for doing so. In this project we investigate the size and architectural design of ControlNet [Zhang et al., 2023] for controlling the image generation process with stable diffusion-based models. We show that a new architecture with as little as 1% of the parameters of the base model achieves state-of-the art results, considerably better than ControlNet in terms of FID score. Hence we call it ControlNet-XS. We provide the code for controlling StableDiffusion-XL [Podell et al., 2023] (Model B, 48M Parameters) and StableDiffusion 2.1 [Rombach et al. 2022] (Model B, 14M Parameters), all under openrail license.*

This model was contributed by [UmerHA](https://twitter.com/UmerHAdil). ❤️

<Tip>

Make sure to check out the Schedulers [guide](../../using-diffusers/schedulers) to learn how to explore the tradeoff between scheduler speed and quality, and see the [reuse components across pipelines](../../using-diffusers/loading#reuse-components-across-pipelines) section to learn how to efficiently load the same components into multiple pipelines.

</Tip>

## StableDiffusionControlNetXSPipeline
[[autodoc]] StableDiffusionControlNetXSPipeline
- all
- __call__

## StableDiffusionPipelineOutput
[[autodoc]] pipelines.stable_diffusion.StableDiffusionPipelineOutput
45 changes: 45 additions & 0 deletions docs/source/en/api/pipelines/controlnetxs_sdxl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<!--Copyright 2023 The HuggingFace Team. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
-->

# ControlNet-XS with Stable Diffusion XL

ControlNet-XS was introduced in [ControlNet-XS](https://vislearn.github.io/ControlNet-XS/) by Denis Zavadski and Carsten Rother. It is based on the observation that the control model in the [original ControlNet](https://huggingface.co/papers/2302.05543) can be made much smaller and still produce good results.

Like the original ControlNet model, you can provide an additional control image to condition and control Stable Diffusion generation. For example, if you provide a depth map, the ControlNet model generates an image that'll preserve the spatial information from the depth map. It is a more flexible and accurate way to control the image generation process.

ControlNet-XS generates images with comparable quality to a regular ControlNet, but it is 20-25% faster ([see benchmark](https://github.com/UmerHA/controlnet-xs-benchmark/blob/main/Speed%20Benchmark.ipynb)) and uses ~45% less memory.

Here's the overview from the [project page](https://vislearn.github.io/ControlNet-XS/):

*With increasing computing capabilities, current model architectures appear to follow the trend of simply upscaling all components without validating the necessity for doing so. In this project we investigate the size and architectural design of ControlNet [Zhang et al., 2023] for controlling the image generation process with stable diffusion-based models. We show that a new architecture with as little as 1% of the parameters of the base model achieves state-of-the art results, considerably better than ControlNet in terms of FID score. Hence we call it ControlNet-XS. We provide the code for controlling StableDiffusion-XL [Podell et al., 2023] (Model B, 48M Parameters) and StableDiffusion 2.1 [Rombach et al. 2022] (Model B, 14M Parameters), all under openrail license.*

This model was contributed by [UmerHA](https://twitter.com/UmerHAdil). ❤️

<Tip warning={true}>

🧪 Many of the SDXL ControlNet checkpoints are experimental, and there is a lot of room for improvement. Feel free to open an [Issue](https://github.com/huggingface/diffusers/issues/new/choose) and leave us feedback on how we can improve!

</Tip>

<Tip>

Make sure to check out the Schedulers [guide](../../using-diffusers/schedulers) to learn how to explore the tradeoff between scheduler speed and quality, and see the [reuse components across pipelines](../../using-diffusers/loading#reuse-components-across-pipelines) section to learn how to efficiently load the same components into multiple pipelines.

</Tip>

## StableDiffusionXLControlNetXSPipeline
[[autodoc]] StableDiffusionXLControlNetXSPipeline
- all
- __call__

## StableDiffusionPipelineOutput
[[autodoc]] pipelines.stable_diffusion.StableDiffusionPipelineOutput
2 changes: 2 additions & 0 deletions docs/source/en/api/pipelines/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ The table below lists all the pipelines currently available in 🤗 Diffusers an
| [Consistency Models](consistency_models) | unconditional image generation |
| [ControlNet](controlnet) | text2image, image2image, inpainting |
| [ControlNet with Stable Diffusion XL](controlnet_sdxl) | text2image |
| [ControlNet-XS](controlnetxs) | text2image |
| [ControlNet-XS with Stable Diffusion XL](controlnetxs_sdxl) | text2image |
| [Cycle Diffusion](cycle_diffusion) | image2image |
| [Dance Diffusion](dance_diffusion) | unconditional audio generation |
| [DDIM](ddim) | unconditional image generation |
Expand Down
6 changes: 6 additions & 0 deletions src/diffusers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
"AutoencoderTiny",
"ConsistencyDecoderVAE",
"ControlNetModel",
"ControlNetXSModel",
"Kandinsky3UNet",
"ModelMixin",
"MotionAdapter",
Expand Down Expand Up @@ -250,6 +251,7 @@
"StableDiffusionControlNetImg2ImgPipeline",
"StableDiffusionControlNetInpaintPipeline",
"StableDiffusionControlNetPipeline",
"StableDiffusionControlNetXSPipeline",
"StableDiffusionDepth2ImgPipeline",
"StableDiffusionDiffEditPipeline",
"StableDiffusionGLIGENPipeline",
Expand All @@ -273,6 +275,7 @@
"StableDiffusionXLControlNetImg2ImgPipeline",
"StableDiffusionXLControlNetInpaintPipeline",
"StableDiffusionXLControlNetPipeline",
"StableDiffusionXLControlNetXSPipeline",
"StableDiffusionXLImg2ImgPipeline",
"StableDiffusionXLInpaintPipeline",
"StableDiffusionXLInstructPix2PixPipeline",
Expand Down Expand Up @@ -454,6 +457,7 @@
AutoencoderTiny,
ConsistencyDecoderVAE,
ControlNetModel,
ControlNetXSModel,
Kandinsky3UNet,
ModelMixin,
MotionAdapter,
Expand Down Expand Up @@ -603,6 +607,7 @@
StableDiffusionControlNetImg2ImgPipeline,
StableDiffusionControlNetInpaintPipeline,
StableDiffusionControlNetPipeline,
StableDiffusionControlNetXSPipeline,
StableDiffusionDepth2ImgPipeline,
StableDiffusionDiffEditPipeline,
StableDiffusionGLIGENPipeline,
Expand All @@ -626,6 +631,7 @@
StableDiffusionXLControlNetImg2ImgPipeline,
StableDiffusionXLControlNetInpaintPipeline,
StableDiffusionXLControlNetPipeline,
StableDiffusionXLControlNetXSPipeline,
StableDiffusionXLImg2ImgPipeline,
StableDiffusionXLInpaintPipeline,
StableDiffusionXLInstructPix2PixPipeline,
Expand Down
2 changes: 2 additions & 0 deletions src/diffusers/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
_import_structure["autoencoder_tiny"] = ["AutoencoderTiny"]
_import_structure["consistency_decoder_vae"] = ["ConsistencyDecoderVAE"]
_import_structure["controlnet"] = ["ControlNetModel"]
_import_structure["controlnetxs"] = ["ControlNetXSModel"]
_import_structure["dual_transformer_2d"] = ["DualTransformer2DModel"]
_import_structure["modeling_utils"] = ["ModelMixin"]
_import_structure["embeddings"] = ["ImageProjection"]
Expand Down Expand Up @@ -63,6 +64,7 @@
from .autoencoder_tiny import AutoencoderTiny
from .consistency_decoder_vae import ConsistencyDecoderVAE
from .controlnet import ControlNetModel
from .controlnetxs import ControlNetXSModel
from .dual_transformer_2d import DualTransformer2DModel
from .embeddings import ImageProjection
from .modeling_utils import ModelMixin
Expand Down
Loading