Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
|
3 |
+
TODO:
|
4 |
+
- The fp16 base model is converted to openvino in fp32, which is unnecessary.
|
5 |
+
|
6 |
+
|
7 |
+
```python
|
8 |
+
import torch
|
9 |
+
from diffusers import AutoPipelineForText2Image, LCMScheduler
|
10 |
+
from optimum.intel.openvino.modeling_diffusion import OVStableDiffusionPipeline
|
11 |
+
|
12 |
+
base_model_id = "Lykon/dreamshaper-8"
|
13 |
+
adapter_id = "latent-consistency/lcm-lora-sdv1-5"
|
14 |
+
save_torch_folder = './dreamshaper-8-lcm'
|
15 |
+
save_ov_folder = './dreamshaper-8-lcm-openvino'
|
16 |
+
|
17 |
+
torch_pipeline = AutoPipelineForText2Image.from_pretrained(
|
18 |
+
base_model_id, torch_dtype=torch.float16, variant="fp16")
|
19 |
+
torch_pipeline.scheduler = LCMScheduler.from_config(
|
20 |
+
torch_pipeline.scheduler.config)
|
21 |
+
# load and fuse lcm lora
|
22 |
+
torch_pipeline.load_lora_weights(adapter_id)
|
23 |
+
torch_pipeline.fuse_lora()
|
24 |
+
torch_pipeline.save_pretrained(save_torch_folder)
|
25 |
+
|
26 |
+
ov_pipeline = OVStableDiffusionPipeline.from_pretrained(
|
27 |
+
save_torch_folder,
|
28 |
+
device='CPU',
|
29 |
+
export=True,
|
30 |
+
)
|
31 |
+
ov_pipeline.save_pretrained(save_ov_folder)
|
32 |
+
```
|