Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,101 @@
|
|
1 |
-
---
|
2 |
-
license: apache-2.0
|
3 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
---
|
4 |
+
# ***State of the art ControlNet-openpose-sdxl-1.0 model, not limited to anime, just for show***
|
5 |
+
![images](./masonry0.webp)
|
6 |
+
|
7 |
+
### Examples
|
8 |
+
![images0](./000001_scribble_concat.webp)
|
9 |
+
![images1](./000003_scribble_concat.webp)
|
10 |
+
![images2](./000005_scribble_concat.webp)
|
11 |
+
![images3](./000008_scribble_concat.webpp)
|
12 |
+
![images4](./000015_scribble_concat.webp)
|
13 |
+
![images5](./000031_scribble_concat.webp)
|
14 |
+
![images6](./000042_scribble_concat.webp)
|
15 |
+
![images7](./000047_scribble_concat.webp)
|
16 |
+
![images8](./000048_scribble_concat.webp)
|
17 |
+
![images9](./000083_scribble_concat.webp)
|
18 |
+
|
19 |
+
## How to Get Started with the Model
|
20 |
+
|
21 |
+
Use the code below to get started with the model.
|
22 |
+
|
23 |
+
```python
|
24 |
+
from diffusers import ControlNetModel, StableDiffusionXLControlNetPipeline, AutoencoderKL
|
25 |
+
from diffusers import DDIMScheduler, EulerAncestralDiscreteScheduler
|
26 |
+
from controlnet_aux import OpenposeDetector
|
27 |
+
from PIL import Image
|
28 |
+
import torch
|
29 |
+
import numpy as np
|
30 |
+
import cv2
|
31 |
+
|
32 |
+
|
33 |
+
|
34 |
+
controlnet_conditioning_scale = 1.0
|
35 |
+
prompt = "your prompt, the longer the better, you can describe it as detail as possible"
|
36 |
+
negative_prompt = 'longbody, lowres, bad anatomy, bad hands, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality'
|
37 |
+
|
38 |
+
|
39 |
+
|
40 |
+
eulera_scheduler = EulerAncestralDiscreteScheduler.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", subfolder="scheduler")
|
41 |
+
|
42 |
+
|
43 |
+
controlnet = ControlNetModel.from_pretrained(
|
44 |
+
"xinsir/controlnet-openpose-sdxl-1.0",
|
45 |
+
torch_dtype=torch.float16
|
46 |
+
)
|
47 |
+
|
48 |
+
# when test with other base model, you need to change the vae also.
|
49 |
+
vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16)
|
50 |
+
|
51 |
+
|
52 |
+
pipe = StableDiffusionXLControlNetPipeline.from_pretrained(
|
53 |
+
"stabilityai/stable-diffusion-xl-base-1.0",
|
54 |
+
controlnet=controlnet,
|
55 |
+
vae=vae,
|
56 |
+
safety_checker=None,
|
57 |
+
torch_dtype=torch.float16,
|
58 |
+
scheduler=eulera_scheduler,
|
59 |
+
)
|
60 |
+
|
61 |
+
processor = OpenposeDetector.from_pretrained('lllyasviel/ControlNet')
|
62 |
+
|
63 |
+
|
64 |
+
controlnet_img = cv2.imread("your image path")
|
65 |
+
controlnet_img = processor(controlnet_img, hand_and_face=False, output_type='cv2')
|
66 |
+
|
67 |
+
|
68 |
+
# need to resize the image resolution to 1024 * 1024 or same bucket resolution to get the best performance
|
69 |
+
height, width, _ = controlnet_img.shape
|
70 |
+
ratio = np.sqrt(1024. * 1024. / (width * height))
|
71 |
+
new_width, new_height = int(width * ratio), int(height * ratio)
|
72 |
+
controlnet_img = cv2.resize(controlnet_img, (new_width, new_height))
|
73 |
+
controlnet_img = Image.fromarray(controlnet_img)
|
74 |
+
|
75 |
+
images = pipe(
|
76 |
+
prompt,
|
77 |
+
negative_prompt=negative_prompt,
|
78 |
+
image=controlnet_img,
|
79 |
+
controlnet_conditioning_scale=controlnet_conditioning_scale,
|
80 |
+
width=new_width,
|
81 |
+
height=new_height,
|
82 |
+
num_inference_steps=30,
|
83 |
+
).images
|
84 |
+
|
85 |
+
images[0].save(f"your image save path, png format is usually better than jpg or webp in terms of image quality but got much bigger")
|
86 |
+
```
|
87 |
+
|
88 |
+
|
89 |
+
## Evaluation Data
|
90 |
+
HumanArt [https://github.com/IDEA-Research/HumanArt], select 2000 images with ground truth pose annotations to generate images and calculate mAP.
|
91 |
+
|
92 |
+
|
93 |
+
|
94 |
+
## Quantitative Result
|
95 |
+
| metric | xinsir/controlnet-openpose-sdxl-1.0 | lllyasviel/control_v11p_sd15_openpose | thibaud/controlnet-openpose-sdxl-1.0 |
|
96 |
+
|-------|-------|-------|-------|
|
97 |
+
| mAP | **0.357** | 0.326 | 0.209 |
|
98 |
+
|
99 |
+
We are the SOTA openpose model compared with other opensource models.
|
100 |
+
|
101 |
+
|