Update app.py
Browse files
app.py
CHANGED
@@ -9,9 +9,10 @@ import openvino.runtime as ov
|
|
9 |
from typing import Optional, Dict
|
10 |
from diffusers import EulerAncestralDiscreteScheduler, LCMScheduler, DDIMScheduler
|
11 |
|
12 |
-
|
|
|
13 |
#EulerDiscreteScheduler 尚可
|
14 |
-
#EulerAncestralDiscreteScheduler
|
15 |
|
16 |
|
17 |
model_id = "hsuwill000/LCM-absolutereality-openvino-8bit"
|
@@ -19,12 +20,20 @@ model_id = "hsuwill000/LCM-absolutereality-openvino-8bit"
|
|
19 |
#model_id = "spamsoms/LCM-anything-v5-openvino2"
|
20 |
#adapter_id = "latent-consistency/lcm-lora-sdv1-5"
|
21 |
|
22 |
-
|
23 |
HIGH=1024
|
24 |
-
WIDTH=
|
25 |
|
26 |
batch_size = -1
|
27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
pipe = OVStableDiffusionPipeline.from_pretrained(
|
29 |
model_id,
|
30 |
compile = False,
|
@@ -36,11 +45,19 @@ pipe = OVStableDiffusionPipeline.from_pretrained(
|
|
36 |
use_safetensors=False,
|
37 |
)
|
38 |
print(pipe.scheduler.compatibles)
|
|
|
39 |
#pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config)
|
40 |
#pipe.scheduler = DDIMScheduler.from_config(pipe.scheduler.config)
|
41 |
|
42 |
#pipe.load_lora_weights(adapter_id)
|
43 |
#pipe.fuse_lora()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
|
45 |
|
46 |
pipe.reshape( batch_size=-1, height=HIGH, width=WIDTH, num_images_per_prompt=1)
|
@@ -93,7 +110,7 @@ with gr.Blocks(css=css) as demo:
|
|
93 |
|
94 |
with gr.Column(elem_id="col-container"):
|
95 |
gr.Markdown(f"""
|
96 |
-
#
|
97 |
Currently running on {power_device}.
|
98 |
""")
|
99 |
|
|
|
9 |
from typing import Optional, Dict
|
10 |
from diffusers import EulerAncestralDiscreteScheduler, LCMScheduler, DDIMScheduler
|
11 |
|
12 |
+
|
13 |
+
|
14 |
#EulerDiscreteScheduler 尚可
|
15 |
+
#EulerAncestralDiscreteScheduler
|
16 |
|
17 |
|
18 |
model_id = "hsuwill000/LCM-absolutereality-openvino-8bit"
|
|
|
20 |
#model_id = "spamsoms/LCM-anything-v5-openvino2"
|
21 |
#adapter_id = "latent-consistency/lcm-lora-sdv1-5"
|
22 |
|
23 |
+
|
24 |
HIGH=1024
|
25 |
+
WIDTH=1024
|
26 |
|
27 |
batch_size = -1
|
28 |
|
29 |
+
class CustomOVModelVaeDecoder(OVModelVaeDecoder):
|
30 |
+
def __init__(
|
31 |
+
self, model: ov.Model, parent_model: OVBaseModel, ov_config: Optional[Dict[str, str]] = None, model_dir: str = None,
|
32 |
+
):
|
33 |
+
super(OVModelVaeDecoder, self).__init__(model, parent_model, ov_config, "vae_decoder", model_dir)
|
34 |
+
|
35 |
+
|
36 |
+
|
37 |
pipe = OVStableDiffusionPipeline.from_pretrained(
|
38 |
model_id,
|
39 |
compile = False,
|
|
|
45 |
use_safetensors=False,
|
46 |
)
|
47 |
print(pipe.scheduler.compatibles)
|
48 |
+
|
49 |
#pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config)
|
50 |
#pipe.scheduler = DDIMScheduler.from_config(pipe.scheduler.config)
|
51 |
|
52 |
#pipe.load_lora_weights(adapter_id)
|
53 |
#pipe.fuse_lora()
|
54 |
+
taesd_dir = snapshot_download(repo_id="deinferno/taesd-openvino")
|
55 |
+
|
56 |
+
pipe.vae_decoder = CustomOVModelVaeDecoder(model = OVBaseModel.load_model(f"{taesd_dir}/vae_decoder/openvino_model.xml"),
|
57 |
+
parent_model = pipe,
|
58 |
+
model_dir = taesd_dir
|
59 |
+
)
|
60 |
+
|
61 |
|
62 |
|
63 |
pipe.reshape( batch_size=-1, height=HIGH, width=WIDTH, num_images_per_prompt=1)
|
|
|
110 |
|
111 |
with gr.Column(elem_id="col-container"):
|
112 |
gr.Markdown(f"""
|
113 |
+
# {model_id.split('/')[1]} {WIDTH}x{HIGH}
|
114 |
Currently running on {power_device}.
|
115 |
""")
|
116 |
|