Views
No views yet
1from optimum.intel.openvino import OVStableDiffusionXLPipeline
2from diffusers import (
3 EulerAncestralDiscreteScheduler,
4 DPMSolverMultistepScheduler
5)
6
7model_id = "CodeChris/AnimagineXL-v3-openvino"
8pipe = OVStableDiffusionXLPipeline.from_pretrained(model_model)
9# Fix output image size & batch_size for faster speed
10img_w, img_h = 832, 1216 # Example
11pipe.reshape(width=img_w, height=img_h,
12 batch_size=1, num_images_per_prompt=1)
13
14## Change scheduler
15# AnimagineXL recommand Euler A:
16# pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config)
17pipe.scheduler = DPMSolverMultistepScheduler.from_config(
18 pipe.scheduler.config,
19 use_karras_sigmas=True,
20 algorithm_type="dpmsolver++"
21) # I prefer DPM++ 2M Karras
22# Turn off the filter
23pipe.safety_checker = None
24
25# If run on a GPU, you need:
26# pipe.to('cuda')1prompt = "1girl, dress, day, masterpiece, best quality"
2negative_prompt = "lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry, artist name"
3
4images = pipe(
5 prompt,
6 negative_prompt,
7 # If reshaped, image size must equal the reshaped size
8 width=img_w, height=img_h,
9 guidance_scale=7,
10 num_inference_steps=20
11)
12img = images[0]
13img.save('sample.png')# Or their transpose
896 x 1152
832 x 1216
768 x 1344
640 x 1536
1024 x 1024pip install --upgrade-strategy eager optimum[openvino,nncf]optimum-cli export openvino --model 'cagliostrolab/animagine-xl-3.0' 'models/openvino/AnimagineXL-v3' --task 'stable-diffusion-xl'git lfs install
huggingface-cli lfs-enable-largefiles .
huggingface-cli upload --commit-message 'Upload model files' 'CodeChris/AnimagineXL-v3-openvino' .optimum==1.16.1 and openvino==2023.2.0.optimum-cli export openvino --help for more usage details.