Skip to content

Commit 4b86649

Browse files
committed
add to docs
1 parent a4b701a commit 4b86649

File tree

3 files changed

+118
-0
lines changed

3 files changed

+118
-0
lines changed

docs/source/en/_toctree.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,8 @@
274274
title: SparseControlNetModel
275275
- local: api/models/controlnet_union
276276
title: ControlNetUnionModel
277+
- local: api/models/controlnet_sana
278+
title: SanaControlNetModel
277279
title: ControlNets
278280
- sections:
279281
- local: api/models/allegro_transformer3d
@@ -416,6 +418,8 @@
416418
title: ControlNet with Stable Diffusion 3
417419
- local: api/pipelines/controlnet_sdxl
418420
title: ControlNet with Stable Diffusion XL
421+
- local: api/pipelines/controlnet_sana
422+
title: ControlNet-Sana
419423
- local: api/pipelines/controlnetxs
420424
title: ControlNet-XS
421425
- local: api/pipelines/controlnetxs_sdxl
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
# SanaControlNetModel
14+
15+
The ControlNet model was introduced in [Adding Conditional Control to Text-to-Image Diffusion Models](https://huggingface.co/papers/2302.05543) by Lvmin Zhang, Anyi Rao, Maneesh Agrawala. It provides a greater degree of control over text-to-image generation by conditioning the model on additional inputs such as edge maps, depth maps, segmentation maps, and keypoints for pose detection.
16+
17+
The abstract from the paper is:
18+
19+
*We present ControlNet, a neural network architecture to add spatial conditioning controls to large, pretrained text-to-image diffusion models. ControlNet locks the production-ready large diffusion models, and reuses their deep and robust encoding layers pretrained with billions of images as a strong backbone to learn a diverse set of conditional controls. The neural architecture is connected with "zero convolutions" (zero-initialized convolution layers) that progressively grow the parameters from zero and ensure that no harmful noise could affect the finetuning. We test various conditioning controls, eg, edges, depth, segmentation, human pose, etc, with Stable Diffusion, using single or multiple conditions, with or without prompts. We show that the training of ControlNets is robust with small (<50k) and large (>1m) datasets. Extensive results show that ControlNet may facilitate wider applications to control image diffusion models.*
20+
21+
This model was contributed by [ishan24](https://huggingface.co/ishan24). ❤️
22+
The original codebase can be found at [NVlabs/Sana](https://github.com/NVlabs/Sana), and you can find official ControlNet checkpoints on [Efficient-Large-Model's](https://huggingface.co/Efficient-Large-Model) Hub profile.
23+
24+
## Loading from the original format
25+
By default the [`SanaControlNetModel`] should be loaded with [`~ModelMixin.from_pretrained`]
26+
```py
27+
from diffusers import SanaControlNetModel, SanaControlNetPipeline
28+
import torch
29+
30+
controlnet = SanaControlNetModel.from_pretrained(
31+
"ishan24/Sana_600M_1024px_ControlNet_diffusers",
32+
)
33+
pipe = SanaControlNetPipeline.from_pretrained(
34+
"Efficient-Large-Model/Sana_600M_1024px_diffusers",
35+
controlnet=controlnet,
36+
)
37+
pipe.to('cuda')
38+
```
39+
40+
## SanaControlNetModel
41+
[[autodoc]] SanaControlNetModel
42+
43+
## SanaControlNetOutput
44+
[[autodoc]] models.controlnets.controlnet_sana.SanaControlNetOutput
45+
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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+
# ControlNet
14+
15+
<div class="flex flex-wrap space-x-1">
16+
<img alt="LoRA" src="https://img.shields.io/badge/LoRA-d8b4fe?style=flat"/>
17+
</div>
18+
19+
ControlNet was introduced in [Adding Conditional Control to Text-to-Image Diffusion Models](https://huggingface.co/papers/2302.05543) by Lvmin Zhang, Anyi Rao, and Maneesh Agrawala.
20+
21+
With a 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.
22+
23+
The abstract from the paper is:
24+
25+
*We present ControlNet, a neural network architecture to add spatial conditioning controls to large, pretrained text-to-image diffusion models. ControlNet locks the production-ready large diffusion models, and reuses their deep and robust encoding layers pretrained with billions of images as a strong backbone to learn a diverse set of conditional controls. The neural architecture is connected with "zero convolutions" (zero-initialized convolution layers) that progressively grow the parameters from zero and ensure that no harmful noise could affect the finetuning. We test various conditioning controls, eg, edges, depth, segmentation, human pose, etc, with Stable Diffusion, using single or multiple conditions, with or without prompts. We show that the training of ControlNets is robust with small (<50k) and large (>1m) datasets. Extensive results show that ControlNet may facilitate wider applications to control image diffusion models.*
26+
27+
This pipeline was contributed by [ishan24](https://huggingface.co/ishan24). ❤️
28+
The original codebase can be found at [NVlabs/Sana](https://github.com/NVlabs/Sana), and you can find official ControlNet checkpoints on [Efficient-Large-Model's](https://huggingface.co/Efficient-Large-Model) Hub profile.
29+
30+
## Loading from the original format
31+
```py
32+
import torch
33+
from diffusers import SanaControlNetModel, SanaControlNetPipeline
34+
from diffusers.utils import load_image
35+
36+
controlnet = SanaControlNetModel.from_pretrained(
37+
"ishan24/Sana_600M_1024px_ControlNet_diffusers",
38+
torch_dtype=torch.float16
39+
)
40+
41+
pipe = SanaControlNetPipeline.from_pretrained(
42+
"Efficient-Large-Model/Sana_600M_1024px_diffusers",
43+
variant="fp16",
44+
controlnet=controlnet,
45+
torch_dtype=torch.float16,
46+
)
47+
48+
pipe.to('cuda')
49+
pipe.vae.to(torch.bfloat16)
50+
pipe.text_encoder.to(torch.bfloat16)
51+
52+
cond_image = load_image(
53+
"https://huggingface.co/ishan24/Sana_600M_1024px_ControlNet_diffusers/resolve/main/hed_example.png"
54+
)
55+
prompt='a cat with a neon sign that says "Sana"'
56+
image = pipe(
57+
prompt,
58+
control_image=cond_image,
59+
).images[0]
60+
image.save("sana.png")
61+
```
62+
63+
## SanaControlNetPipeline
64+
[[autodoc]] SanaControlNetPipeline
65+
- all
66+
- __call__
67+
68+
## SanaControlNetPipelineOutput
69+
[[autodoc]] pipelines.controlnet_sana.SanaControlNetPipelineOutput

0 commit comments

Comments
 (0)