Views
No views yet
| Run No. | Pytorch | OpenVino | Openvino w/reshape |
|---|---|---|---|
| 1 | 15.5841 | 18.0010 | 13.4928 |
| 2 | 12.4634 | 5.0208 | 3.6855 |
| 3 | 12.1551 | 4.9462 | 3.7228 |
| Run No. | Pytorch | OpenVino | Openvino w/reshape |
|---|---|---|---|
| 1 | 31.3666 | 33.1488 | 25.7044 |
| 2 | 33.4797 | 17.7456 | 12.8295 |
| 3 | 28.6561 | 17.9216 | 12.7198 |
pip install diffusers transformers accelerate optimum
pip install --upgrade-strategy eager optimum[openvino]git clone https://huggingface.co/deinferno/LCM_Dreamshaper_v7-openvino
cd LCM_Dreamshaper_v7-openvino1from lcm_ov_pipeline import OVLatentConsistencyModelPipeline
2from lcm_scheduler import LCMScheduler
3
4model_id = "deinferno/LCM_Dreamshaper_v7-openvino"
5
6scheduler = LCMScheduler.from_pretrained(model_id, subfolder = "scheduler")
7
8# Use "compile = True" if you don't plan to reshape and recompile model after loading
9# Don't forget to disable OpenVino cache via "ov_config = {"CACHE_DIR":""}" because optimum won't use it anyway and it will stay as dead weight in your RAM when loading pipeline again
10pipe = OVLatentConsistencyModelPipeline.from_pretrained(model_id, scheduler = scheduler, compile = False, ov_config = {"CACHE_DIR":""})
11
12prompt = "Self-portrait oil painting, a beautiful cyborg with golden hair, 8k"
13
14# Can be set to 1~50 steps. LCM support fast inference even <= 4 steps. Recommend: 1~8 steps.
15
16width = 512
17height = 512
18num_images = 1
19batch_size = 1
20num_inference_steps = 4
21
22# Reshape and recompile for inference speed
23
24pipe.reshape(batch_size=batch_size, height=height, width=width, num_images_per_prompt=num_images)
25pipe.compile()
26
27images = pipe(prompt=prompt, width=width, height=height, num_inference_steps=num_inference_steps, guidance_scale=8.0, output_type="pil").images