viccpoes commited on
Commit
21dddc3
1 Parent(s): e0ba08a

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +66 -0
README.md ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: openrail++
3
+ tags:
4
+ - stable-diffusion
5
+ - stable-diffusion-diffusers
6
+ - text-to-image
7
+ - controlnet
8
+ ---
9
+
10
+ # Aesthetic ControlNet
11
+
12
+ ControlNet is a method that can be used to condition diffusion models on arbitrary input features, such as image edges, segmentation maps, or human poses.
13
+ For more information about ControlNet, please have a look at this [thread](https://twitter.com/krea_ai/status/1626672218477559809) or at the original [work](https://arxiv.org/pdf/2302.05543.pdf) by Lvmin Zhang and Maneesh Agrawala.
14
+
15
+ Aesthetic ControlNet is a version of this technique that uses image features extracted using a [Canny edge detector](https://docs.opencv.org/4.x/da/d22/tutorial_py_canny.html) to guide a text-to-image diffusion model trained with aesthetic data.
16
+
17
+ ![Example](./examples.jpg)
18
+
19
+
20
+ ### Diffusers
21
+ Install the following dependencies and then run the code below:
22
+
23
+ ```bash
24
+ pip install opencv-python numpy git+https://github.com/huggingface/diffusers.git
25
+ ```
26
+
27
+
28
+ ```py
29
+ import cv2
30
+ import numpy as np
31
+ from diffusers import StableDiffusionControlNetPipeline, EulerAncestralDiscreteScheduler
32
+ from diffusers.utils import load_image
33
+
34
+ image = load_image("https://huggingface.co/krea/aesthetic-controlnet/resolve/main/krea.jpg")
35
+
36
+ image = np.array(image)
37
+
38
+ low_threshold = 100
39
+ high_threshold = 200
40
+
41
+ image = cv2.Canny(image, low_threshold, high_threshold)
42
+ image = image[:, :, None]
43
+ image = np.concatenate([image, image, image], axis=2)
44
+ canny_image = Image.fromarray(image)
45
+
46
+ pipe = StableDiffusionControlNetPipeline.from_pretrained("krea/aesthetic-controlnet").to("cuda")
47
+ pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config)
48
+
49
+ output = pipe(
50
+ "fantasy flowers",
51
+ canny_image,
52
+ num_inference_steps=20,
53
+ guidance_scale=4,
54
+ width=768,
55
+ height=768,
56
+ )
57
+
58
+ result = output.images[0]
59
+ result.save("result.png")
60
+ ```
61
+
62
+ ## Misuse and Malicious Use
63
+ The model should not be used to intentionally create or disseminate images that create hostile or alienating environments for people. This includes generating images that people would foreseeably find disturbing, distressing, or offensive; or content that propagates historical or current stereotypes.
64
+
65
+ ## Sout-outs
66
+ Thanks to [@thibaudz](https://twitter.com/thibaudz) for creating a version of controlnet compatible with Stable Diffusion 2.1.