hsuwill000 commited on
Commit
3852617
·
verified ·
1 Parent(s): b0151ad

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -1
app.py CHANGED
@@ -1,6 +1,7 @@
1
  import gradio as gr
2
  import torch
3
- from optimum.intel.openvino.modeling_diffusion import OVStableDiffusionPipeline
 
4
 
5
  model_id = "hsuwill000/Fluently-v4-LCM-openvino"
6
 
@@ -9,6 +10,14 @@ WIDTH = 512
9
 
10
  batch_size = -1 # Or set it to a specific positive integer if needed
11
 
 
 
 
 
 
 
 
 
12
  pipe = OVStableDiffusionPipeline.from_pretrained(
13
  model_id,
14
  compile=False,
@@ -17,6 +26,13 @@ pipe = OVStableDiffusionPipeline.from_pretrained(
17
  safety_checker=None,
18
  use_safetensors=False,
19
  )
 
 
 
 
 
 
 
20
  print(pipe.scheduler.compatibles)
21
 
22
  pipe.reshape(batch_size=batch_size, height=HIGH, width=WIDTH, num_images_per_prompt=1)
 
1
  import gradio as gr
2
  import torch
3
+ from optimum.intel.openvino.modeling_diffusion import OVModelVaeDecoder, OVBaseModel, OVStableDiffusionPipeline
4
+ from huggingface_hub import snapshot_download
5
 
6
  model_id = "hsuwill000/Fluently-v4-LCM-openvino"
7
 
 
10
 
11
  batch_size = -1 # Or set it to a specific positive integer if needed
12
 
13
+ class CustomOVModelVaeDecoder(OVModelVaeDecoder):
14
+ def __init__(
15
+ self, model: ov.Model, parent_model: OVBaseModel, ov_config: Optional[Dict[str, str]] = None, model_dir: str = None,
16
+ ):
17
+ super(OVModelVaeDecoder, self).__init__(model, parent_model, ov_config, "vae_decoder", model_dir)
18
+
19
+
20
+
21
  pipe = OVStableDiffusionPipeline.from_pretrained(
22
  model_id,
23
  compile=False,
 
26
  safety_checker=None,
27
  use_safetensors=False,
28
  )
29
+
30
+ taesd_dir = snapshot_download(repo_id="deinferno/taesd-openvino")
31
+
32
+ pipe.vae_decoder = CustomOVModelVaeDecoder(model = OVBaseModel.load_model(f"{taesd_dir}/vae_decoder/openvino_model.xml"),
33
+ parent_model = pipe,
34
+
35
+
36
  print(pipe.scheduler.compatibles)
37
 
38
  pipe.reshape(batch_size=batch_size, height=HIGH, width=WIDTH, num_images_per_prompt=1)