File size: 972 Bytes
69c5ed3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from PIL import Image
import numpy as np
from diffusers import DEISMultistepScheduler
from pipeline_onnx_stable_diffusion_controlnet import OnnxStableDiffusionControlNetPipeline
import onnxruntime as ort

pose_image = Image.open(r"dance_pose.png")

opts = ort.SessionOptions()
opts.enable_cpu_mem_arena = False
opts.enable_mem_pattern = False

pipe = OnnxStableDiffusionControlNetPipeline.from_pretrained(
    "model/anyv3-fp16-autoslicing-cn_openpose",
    sess_options=opts, 
    provider="DmlExecutionProvider",
)

pipe.scheduler = DEISMultistepScheduler.from_config(pipe.scheduler.config)
prompt = "1girl, blonde, long dress, dancing, best quality"
seed=25
generator = np.random.RandomState(seed)

images = pipe(    
    prompt,
    pose_image,
    width=512,
    height=512,
    negative_prompt="monochrome, lowres, bad anatomy, worst quality, low quality",
    num_inference_steps=30,
    generator=generator,
).images[0]
images.save("controlnet-openpose-test.png")