Instructions to use xinsir/controlnet-openpose-sdxl-1.0 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use xinsir/controlnet-openpose-sdxl-1.0 with Diffusers:
pip install -U diffusers transformers accelerate
from diffusers import ControlNetModel, StableDiffusionControlNetPipeline controlnet = ControlNetModel.from_pretrained("xinsir/controlnet-openpose-sdxl-1.0") pipe = StableDiffusionControlNetPipeline.from_pretrained( "fill-in-base-model", controlnet=controlnet ) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Draw Things
- DiffusionBee
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 |
+

|
| 6 |
+
|
| 7 |
+
### Examples
|
| 8 |
+

|
| 9 |
+

|
| 10 |
+

|
| 11 |
+

|
| 12 |
+

|
| 13 |
+

|
| 14 |
+

|
| 15 |
+

|
| 16 |
+

|
| 17 |
+

|
| 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 |
+
|