patrickvonplaten
commited on
Commit
•
1008d5d
1
Parent(s):
b052f13
Update README.md
Browse files
README.md
CHANGED
@@ -1,146 +1 @@
|
|
1 |
-
|
2 |
-
license: openrail
|
3 |
-
base_model: runwayml/stable-diffusion-v1-5
|
4 |
-
tags:
|
5 |
-
- art
|
6 |
-
- controlnet
|
7 |
-
- stable-diffusion
|
8 |
-
duplicated_from: ControlNet-1-1-preview/control_v11p_sd15_depth
|
9 |
-
---
|
10 |
-
|
11 |
-
# Controlnet - v1.1 - *depth Version*
|
12 |
-
|
13 |
-
**Controlnet v1.1** is the successor model of [Controlnet v1.0](https://huggingface.co/lllyasviel/ControlNet)
|
14 |
-
and was released in [lllyasviel/ControlNet-v1-1](https://huggingface.co/lllyasviel/ControlNet-v1-1) by [Lvmin Zhang](https://huggingface.co/lllyasviel).
|
15 |
-
|
16 |
-
This checkpoint is a conversion of [the original checkpoint](https://huggingface.co/lllyasviel/ControlNet-v1-1/blob/main/control_v11p_sd15_depth.pth) into `diffusers` format.
|
17 |
-
It can be used in combination with **Stable Diffusion**, such as [runwayml/stable-diffusion-v1-5](https://huggingface.co/runwayml/stable-diffusion-v1-5).
|
18 |
-
|
19 |
-
|
20 |
-
For more details, please also have a look at the [🧨 Diffusers docs](https://huggingface.co/docs/diffusers/api/pipelines/stable_diffusion/controlnet).
|
21 |
-
|
22 |
-
|
23 |
-
ControlNet is a neural network structure to control diffusion models by adding extra conditions.
|
24 |
-
|
25 |
-
![img](./sd.png)
|
26 |
-
|
27 |
-
This checkpoint corresponds to the ControlNet conditioned on **depth images**.
|
28 |
-
|
29 |
-
## Model Details
|
30 |
-
- **Developed by:** Lvmin Zhang, Maneesh Agrawala
|
31 |
-
- **Model type:** Diffusion-based text-to-image generation model
|
32 |
-
- **Language(s):** English
|
33 |
-
- **License:** [The CreativeML OpenRAIL M license](https://huggingface.co/spaces/CompVis/stable-diffusion-license) is an [Open RAIL M license](https://www.licenses.ai/blog/2022/8/18/naming-convention-of-responsible-ai-licenses), adapted from the work that [BigScience](https://bigscience.huggingface.co/) and [the RAIL Initiative](https://www.licenses.ai/) are jointly carrying in the area of responsible AI licensing. See also [the article about the BLOOM Open RAIL license](https://bigscience.huggingface.co/blog/the-bigscience-rail-license) on which our license is based.
|
34 |
-
- **Resources for more information:** [GitHub Repository](https://github.com/lllyasviel/ControlNet), [Paper](https://arxiv.org/abs/2302.05543).
|
35 |
-
- **Cite as:**
|
36 |
-
|
37 |
-
@misc{zhang2023adding,
|
38 |
-
title={Adding Conditional Control to Text-to-Image Diffusion Models},
|
39 |
-
author={Lvmin Zhang and Maneesh Agrawala},
|
40 |
-
year={2023},
|
41 |
-
eprint={2302.05543},
|
42 |
-
archivePrefix={arXiv},
|
43 |
-
primaryClass={cs.CV}
|
44 |
-
}
|
45 |
-
|
46 |
-
## Introduction
|
47 |
-
|
48 |
-
Controlnet was proposed in [*Adding Conditional Control to Text-to-Image Diffusion Models*](https://arxiv.org/abs/2302.05543) by
|
49 |
-
Lvmin Zhang, Maneesh Agrawala.
|
50 |
-
|
51 |
-
The abstract reads as follows:
|
52 |
-
|
53 |
-
*We present a neural network structure, ControlNet, to control pretrained large diffusion models to support additional input conditions.
|
54 |
-
The ControlNet learns task-specific conditions in an end-to-end way, and the learning is robust even when the training dataset is small (< 50k).
|
55 |
-
Moreover, training a ControlNet is as fast as fine-tuning a diffusion model, and the model can be trained on a personal devices.
|
56 |
-
Alternatively, if powerful computation clusters are available, the model can scale to large amounts (millions to billions) of data.
|
57 |
-
We report that large diffusion models like Stable Diffusion can be augmented with ControlNets to enable conditional inputs like edge maps, depthmentation maps, keypoints, etc.
|
58 |
-
This may enrich the methods to control large diffusion models and further facilitate related applications.*
|
59 |
-
|
60 |
-
## Example
|
61 |
-
|
62 |
-
It is recommended to use the checkpoint with [Stable Diffusion v1-5](https://huggingface.co/runwayml/stable-diffusion-v1-5) as the checkpoint
|
63 |
-
has been trained on it.
|
64 |
-
Experimentally, the checkpoint can be used with other diffusion models such as dreamboothed stable diffusion.
|
65 |
-
|
66 |
-
**Note**: If you want to process an image to create the auxiliary conditioning, external dependencies are required as shown below:
|
67 |
-
|
68 |
-
1. Let's install `diffusers` and related packages:
|
69 |
-
|
70 |
-
```
|
71 |
-
$ pip install diffusers transformers accelerate
|
72 |
-
```
|
73 |
-
|
74 |
-
3. Run code:
|
75 |
-
|
76 |
-
```python
|
77 |
-
import torch
|
78 |
-
import os
|
79 |
-
from huggingface_hub import HfApi
|
80 |
-
from pathlib import Path
|
81 |
-
from diffusers.utils import load_image
|
82 |
-
from PIL import Image
|
83 |
-
import numpy as np
|
84 |
-
from transformers import pipeline
|
85 |
-
|
86 |
-
|
87 |
-
from diffusers import (
|
88 |
-
ControlNetModel,
|
89 |
-
StableDiffusionControlNetPipeline,
|
90 |
-
UniPCMultistepScheduler,
|
91 |
-
)
|
92 |
-
|
93 |
-
checkpoint = "lllyasviel/control_v11p_sd15_depth"
|
94 |
-
|
95 |
-
image = load_image(
|
96 |
-
"https://huggingface.co/lllyasviel/control_v11p_sd15_depth/resolve/main/images/input.png"
|
97 |
-
)
|
98 |
-
|
99 |
-
prompt = "Stormtrooper's lecture in beautiful lecture hall"
|
100 |
-
|
101 |
-
depth_estimator = pipeline('depth-estimation')
|
102 |
-
image = depth_estimator(image)['depth']
|
103 |
-
image = np.array(image)
|
104 |
-
image = image[:, :, None]
|
105 |
-
image = np.concatenate([image, image, image], axis=2)
|
106 |
-
control_image = Image.fromarray(image)
|
107 |
-
|
108 |
-
control_image.save("./images/control.png")
|
109 |
-
|
110 |
-
controlnet = ControlNetModel.from_pretrained(checkpoint, torch_dtype=torch.float16)
|
111 |
-
pipe = StableDiffusionControlNetPipeline.from_pretrained(
|
112 |
-
"runwayml/stable-diffusion-v1-5", controlnet=controlnet, torch_dtype=torch.float16
|
113 |
-
)
|
114 |
-
|
115 |
-
pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config)
|
116 |
-
pipe.enable_model_cpu_offload()
|
117 |
-
|
118 |
-
generator = torch.manual_seed(0)
|
119 |
-
image = pipe(prompt, num_inference_steps=30, generator=generator, image=control_image).images[0]
|
120 |
-
|
121 |
-
image.save('images/image_out.png')
|
122 |
-
|
123 |
-
```
|
124 |
-
|
125 |
-
![bird](./images/input.png)
|
126 |
-
|
127 |
-
![bird_canny](./images/control.png)
|
128 |
-
|
129 |
-
![bird_canny_out](./images/image_out.png)
|
130 |
-
|
131 |
-
## Other released checkpoints v1-1
|
132 |
-
|
133 |
-
The authors released 14 different checkpoints, each trained with [Stable Diffusion v1-5](https://huggingface.co/runwayml/stable-diffusion-v1-5)
|
134 |
-
on a different type of conditioning:
|
135 |
-
|
136 |
-
| Model Name | Control Image Overview| Control Image Example | Generated Image Example |
|
137 |
-
|---|---|---|---|
|
138 |
-
TODO
|
139 |
-
|
140 |
-
### Training
|
141 |
-
|
142 |
-
TODO
|
143 |
-
|
144 |
-
### Blog post
|
145 |
-
|
146 |
-
For more information, please also have a look at the [Diffusers ControlNet Blog Post](https://huggingface.co/blog/controlnet).
|
|
|
1 |
+
**This model has been deleted as it was incorrectly uploaded. The corrected model can be find under [this link](https://huggingface.co/lllyasviel/control_v11f1p_sd15_depth)**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|