Skip to content

Commit 914a585

Browse files
authored
Add ControlNetUnion (#10131)
* ControlNetUnion model
1 parent ad40e26 commit 914a585

14 files changed

+6132
-80
lines changed

docs/source/en/_toctree.yml

+4
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,8 @@
252252
title: SD3ControlNetModel
253253
- local: api/models/controlnet_sparsectrl
254254
title: SparseControlNetModel
255+
- local: api/models/controlnet_union
256+
title: ControlNetUnionModel
255257
title: ControlNets
256258
- sections:
257259
- local: api/models/allegro_transformer3d
@@ -368,6 +370,8 @@
368370
title: ControlNet-XS
369371
- local: api/pipelines/controlnetxs_sdxl
370372
title: ControlNet-XS with Stable Diffusion XL
373+
- local: api/pipelines/controlnet_union
374+
title: ControlNetUnion
371375
- local: api/pipelines/dance_diffusion
372376
title: Dance Diffusion
373377
- local: api/pipelines/ddim
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<!--Copyright 2024 The HuggingFace Team and The InstantX Team. All rights reserved.
2+
3+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4+
the License. You may obtain a copy of the License at
5+
6+
http://www.apache.org/licenses/LICENSE-2.0
7+
8+
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9+
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10+
specific language governing permissions and limitations under the License.
11+
-->
12+
13+
# ControlNetUnionModel
14+
15+
ControlNetUnionModel is an implementation of ControlNet for Stable Diffusion XL.
16+
17+
The ControlNet model was introduced in [ControlNetPlus](https://github.com/xinsir6/ControlNetPlus) by xinsir6. It supports multiple conditioning inputs without increasing computation.
18+
19+
*We design a new architecture that can support 10+ control types in condition text-to-image generation and can generate high resolution images visually comparable with midjourney. The network is based on the original ControlNet architecture, we propose two new modules to: 1 Extend the original ControlNet to support different image conditions using the same network parameter. 2 Support multiple conditions input without increasing computation offload, which is especially important for designers who want to edit image in detail, different conditions use the same condition encoder, without adding extra computations or parameters.*
20+
21+
## Loading
22+
23+
By default the [`ControlNetUnionModel`] should be loaded with [`~ModelMixin.from_pretrained`].
24+
25+
```py
26+
from diffusers import StableDiffusionXLControlNetUnionPipeline, ControlNetUnionModel
27+
28+
controlnet = ControlNetUnionModel.from_pretrained("xinsir/controlnet-union-sdxl-1.0")
29+
pipe = StableDiffusionXLControlNetUnionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", controlnet=controlnet)
30+
```
31+
32+
## ControlNetUnionModel
33+
34+
[[autodoc]] ControlNetUnionModel
35+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<!--Copyright 2024 The HuggingFace Team. All rights reserved.
2+
3+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4+
the License. You may obtain a copy of the License at
5+
6+
http://www.apache.org/licenses/LICENSE-2.0
7+
8+
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9+
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10+
specific language governing permissions and limitations under the License.
11+
-->
12+
13+
# ControlNetUnion
14+
15+
ControlNetUnionModel is an implementation of ControlNet for Stable Diffusion XL.
16+
17+
The ControlNet model was introduced in [ControlNetPlus](https://github.com/xinsir6/ControlNetPlus) by xinsir6. It supports multiple conditioning inputs without increasing computation.
18+
19+
*We design a new architecture that can support 10+ control types in condition text-to-image generation and can generate high resolution images visually comparable with midjourney. The network is based on the original ControlNet architecture, we propose two new modules to: 1 Extend the original ControlNet to support different image conditions using the same network parameter. 2 Support multiple conditions input without increasing computation offload, which is especially important for designers who want to edit image in detail, different conditions use the same condition encoder, without adding extra computations or parameters.*
20+
21+
22+
## StableDiffusionXLControlNetUnionPipeline
23+
[[autodoc]] StableDiffusionXLControlNetUnionPipeline
24+
- all
25+
- __call__
26+
27+
## StableDiffusionXLControlNetUnionImg2ImgPipeline
28+
[[autodoc]] StableDiffusionXLControlNetUnionImg2ImgPipeline
29+
- all
30+
- __call__
31+
32+
## StableDiffusionXLControlNetUnionInpaintPipeline
33+
[[autodoc]] StableDiffusionXLControlNetUnionInpaintPipeline
34+
- all
35+
- __call__

src/diffusers/__init__.py

+8
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
"CogView3PlusTransformer2DModel",
9393
"ConsistencyDecoderVAE",
9494
"ControlNetModel",
95+
"ControlNetUnionModel",
9596
"ControlNetXSAdapter",
9697
"DiTTransformer2DModel",
9798
"FluxControlNetModel",
@@ -378,6 +379,9 @@
378379
"StableDiffusionXLControlNetPAGImg2ImgPipeline",
379380
"StableDiffusionXLControlNetPAGPipeline",
380381
"StableDiffusionXLControlNetPipeline",
382+
"StableDiffusionXLControlNetUnionImg2ImgPipeline",
383+
"StableDiffusionXLControlNetUnionInpaintPipeline",
384+
"StableDiffusionXLControlNetUnionPipeline",
381385
"StableDiffusionXLControlNetXSPipeline",
382386
"StableDiffusionXLImg2ImgPipeline",
383387
"StableDiffusionXLInpaintPipeline",
@@ -586,6 +590,7 @@
586590
CogView3PlusTransformer2DModel,
587591
ConsistencyDecoderVAE,
588592
ControlNetModel,
593+
ControlNetUnionModel,
589594
ControlNetXSAdapter,
590595
DiTTransformer2DModel,
591596
FluxControlNetModel,
@@ -850,6 +855,9 @@
850855
StableDiffusionXLControlNetPAGImg2ImgPipeline,
851856
StableDiffusionXLControlNetPAGPipeline,
852857
StableDiffusionXLControlNetPipeline,
858+
StableDiffusionXLControlNetUnionImg2ImgPipeline,
859+
StableDiffusionXLControlNetUnionInpaintPipeline,
860+
StableDiffusionXLControlNetUnionPipeline,
853861
StableDiffusionXLControlNetXSPipeline,
854862
StableDiffusionXLImg2ImgPipeline,
855863
StableDiffusionXLInpaintPipeline,

src/diffusers/models/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
]
4646
_import_structure["controlnets.controlnet_sd3"] = ["SD3ControlNetModel", "SD3MultiControlNetModel"]
4747
_import_structure["controlnets.controlnet_sparsectrl"] = ["SparseControlNetModel"]
48+
_import_structure["controlnets.controlnet_union"] = ["ControlNetUnionModel"]
4849
_import_structure["controlnets.controlnet_xs"] = ["ControlNetXSAdapter", "UNetControlNetXSModel"]
4950
_import_structure["controlnets.multicontrolnet"] = ["MultiControlNetModel"]
5051
_import_structure["embeddings"] = ["ImageProjection"]
@@ -102,6 +103,7 @@
102103
)
103104
from .controlnets import (
104105
ControlNetModel,
106+
ControlNetUnionModel,
105107
ControlNetXSAdapter,
106108
FluxControlNetModel,
107109
FluxMultiControlNetModel,

src/diffusers/models/controlnets/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
SparseControlNetModel,
1616
SparseControlNetOutput,
1717
)
18+
from .controlnet_union import ControlNetUnionInput, ControlNetUnionInputProMax, ControlNetUnionModel
1819
from .controlnet_xs import ControlNetXSAdapter, ControlNetXSOutput, UNetControlNetXSModel
1920
from .multicontrolnet import MultiControlNetModel
2021

0 commit comments

Comments
 (0)