Update README.md
Browse files
README.md
CHANGED
@@ -68,12 +68,14 @@ Let's have a look at a simple example using the [Canny Adapter](https://huggingf
|
|
68 |
```py
|
69 |
from diffusers import StableDiffusionXLAdapterPipeline, T2IAdapter, EulerAncestralDiscreteScheduler, AutoencoderKL
|
70 |
from diffusers.utils import load_image, make_image_grid
|
71 |
-
from controlnet_aux
|
72 |
import torch
|
|
|
|
|
73 |
|
74 |
# load adapter
|
75 |
adapter = T2IAdapter.from_pretrained(
|
76 |
-
"TencentARC/t2i-adapter-
|
77 |
).to("cuda")
|
78 |
|
79 |
# load euler_a scheduler
|
@@ -85,24 +87,22 @@ pipe = StableDiffusionXLAdapterPipeline.from_pretrained(
|
|
85 |
).to("cuda")
|
86 |
pipe.enable_xformers_memory_efficient_attention()
|
87 |
|
88 |
-
|
89 |
-
"valhalla/t2iadapter-aux-models", filename="dpt_large_384.pt", model_type="dpt_large"
|
90 |
-
).to("cuda")
|
91 |
```
|
92 |
|
93 |
- Condition Image
|
94 |
```py
|
95 |
-
url = "https://huggingface.co/Adapter/t2iadapter/resolve/main/
|
96 |
image = load_image(url)
|
97 |
-
image =
|
98 |
-
|
99 |
-
)
|
100 |
```
|
101 |
-
<a href="https://huggingface.co/Adapter/t2iadapter/resolve/main/
|
102 |
|
103 |
- Generation
|
104 |
```py
|
105 |
-
prompt = "A
|
106 |
negative_prompt = "anime, cartoon, graphic, text, painting, crayon, graphite, abstract, glitch, deformed, mutated, ugly, disfigured"
|
107 |
|
108 |
gen_images = pipe(
|
@@ -113,9 +113,9 @@ gen_images = pipe(
|
|
113 |
adapter_conditioning_scale=1,
|
114 |
guidance_scale=7.5,
|
115 |
).images[0]
|
116 |
-
gen_images.save('
|
117 |
```
|
118 |
-
<a href="https://huggingface.co/Adapter/t2iadapter/resolve/main/
|
119 |
|
120 |
### Training
|
121 |
|
|
|
68 |
```py
|
69 |
from diffusers import StableDiffusionXLAdapterPipeline, T2IAdapter, EulerAncestralDiscreteScheduler, AutoencoderKL
|
70 |
from diffusers.utils import load_image, make_image_grid
|
71 |
+
from controlnet_aux import OpenposeDetector
|
72 |
import torch
|
73 |
+
import numpy as np
|
74 |
+
from PIL import Image
|
75 |
|
76 |
# load adapter
|
77 |
adapter = T2IAdapter.from_pretrained(
|
78 |
+
"TencentARC/t2i-adapter-openpose-sdxl-1.0", torch_dtype=torch.float16
|
79 |
).to("cuda")
|
80 |
|
81 |
# load euler_a scheduler
|
|
|
87 |
).to("cuda")
|
88 |
pipe.enable_xformers_memory_efficient_attention()
|
89 |
|
90 |
+
open_pose = OpenposeDetector.from_pretrained("lllyasviel/Annotators")
|
|
|
|
|
91 |
```
|
92 |
|
93 |
- Condition Image
|
94 |
```py
|
95 |
+
url = "https://huggingface.co/Adapter/t2iadapter/resolve/main/people.jpg"
|
96 |
image = load_image(url)
|
97 |
+
image = open_pose(image, detect_resolution=512, image_resolution=1024)
|
98 |
+
image = np.array(image)[:, :, ::-1]
|
99 |
+
image = Image.fromarray(np.uint8(image))
|
100 |
```
|
101 |
+
<a href="https://huggingface.co/Adapter/t2iadapter/resolve/main/openpose.png"><img width="480" style="margin:0;padding:0;" src="https://huggingface.co/Adapter/t2iadapter/resolve/main/openpose.png"/></a>
|
102 |
|
103 |
- Generation
|
104 |
```py
|
105 |
+
prompt = "A couple, 4k photo, highly detailed"
|
106 |
negative_prompt = "anime, cartoon, graphic, text, painting, crayon, graphite, abstract, glitch, deformed, mutated, ugly, disfigured"
|
107 |
|
108 |
gen_images = pipe(
|
|
|
113 |
adapter_conditioning_scale=1,
|
114 |
guidance_scale=7.5,
|
115 |
).images[0]
|
116 |
+
gen_images.save('out_pose.png')
|
117 |
```
|
118 |
+
<a href="https://huggingface.co/Adapter/t2iadapter/resolve/main/res_pose.png"><img width="480" style="margin:0;padding:0;" src="https://huggingface.co/Adapter/t2iadapter/resolve/main/res_pose.png"/></a>
|
119 |
|
120 |
### Training
|
121 |
|