Kano001 commited on
Commit
bfed75a
1 Parent(s): 2445191

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -4
app.py CHANGED
@@ -19,12 +19,15 @@ from optimum.intel.openvino.modeling_diffusion import OVModelVaeDecoder, OVBaseM
19
 
20
  import os
21
  from tqdm import tqdm
 
22
 
23
  from concurrent.futures import ThreadPoolExecutor
24
  import uuid
25
 
26
  DESCRIPTION = '''# Latent Consistency Model OpenVino CPU
27
- Based on [Latency Consistency Model](https://huggingface.co/spaces/SimianLuo/Latent_Consistency_Model) HF space
 
 
28
 
29
  <p>Running on CPU 🥶.</p>
30
  '''
@@ -32,7 +35,7 @@ Based on [Latency Consistency Model](https://huggingface.co/spaces/SimianLuo/Lat
32
  MAX_SEED = np.iinfo(np.int32).max
33
  CACHE_EXAMPLES = os.getenv("CACHE_EXAMPLES") == "1"
34
 
35
- model_id = "Kano001/Dreamshaper_v7-Openvino"
36
  batch_size = 1
37
  width = int(os.getenv("IMAGE_WIDTH", "512"))
38
  height = int(os.getenv("IMAGE_HEIGHT", "512"))
@@ -49,7 +52,7 @@ pipe = OVLatentConsistencyModelPipeline.from_pretrained(model_id, scheduler = sc
49
 
50
  # Inject TAESD
51
 
52
- taesd_dir = snapshot_download(repo_id="Kano001/taesd-openvino")
53
  pipe.vae_decoder = CustomOVModelVaeDecoder(model = OVBaseModel.load_model(f"{taesd_dir}/vae_decoder/openvino_model.xml"), parent_model = pipe, model_dir = taesd_dir)
54
 
55
  pipe.reshape(batch_size=batch_size, height=height, width=width, num_images_per_prompt=num_images)
@@ -63,6 +66,7 @@ def randomize_seed_fn(seed: int, randomize_seed: bool) -> int:
63
  def save_image(img, profile: gr.OAuthProfile | None, metadata: dict):
64
  unique_name = str(uuid.uuid4()) + '.png'
65
  img.save(unique_name)
 
66
  return unique_name
67
 
68
  def save_images(image_array, profile: gr.OAuthProfile | None, metadata: dict):
@@ -153,6 +157,9 @@ with gr.Blocks(css="style.css") as demo:
153
  step=1,
154
  value=4,
155
  )
 
 
 
156
 
157
  gr.Examples(
158
  examples=examples,
@@ -182,4 +189,4 @@ with gr.Blocks(css="style.css") as demo:
182
  if __name__ == "__main__":
183
  demo.queue(api_open=False)
184
  # demo.queue(max_size=20).launch()
185
- demo.launch()
 
19
 
20
  import os
21
  from tqdm import tqdm
22
+ import gradio_user_history as gr_user_history
23
 
24
  from concurrent.futures import ThreadPoolExecutor
25
  import uuid
26
 
27
  DESCRIPTION = '''# Latent Consistency Model OpenVino CPU
28
+ Based on [Latency Consistency Model](https://huggingface.co/spaces/SimianLuo/Latent_Consistency_Model) HF space
29
+
30
+ Distilled from [Dreamshaper v7](https://huggingface.co/Lykon/dreamshaper-7) fine-tune of [Stable Diffusion v1-5](https://huggingface.co/runwayml/stable-diffusion-v1-5) with only 4,000 training iterations (~32 A100 GPU Hours). [Project page](https://latent-consistency-models.github.io)
31
 
32
  <p>Running on CPU 🥶.</p>
33
  '''
 
35
  MAX_SEED = np.iinfo(np.int32).max
36
  CACHE_EXAMPLES = os.getenv("CACHE_EXAMPLES") == "1"
37
 
38
+ model_id = "deinferno/LCM_Dreamshaper_v7-openvino"
39
  batch_size = 1
40
  width = int(os.getenv("IMAGE_WIDTH", "512"))
41
  height = int(os.getenv("IMAGE_HEIGHT", "512"))
 
52
 
53
  # Inject TAESD
54
 
55
+ taesd_dir = snapshot_download(repo_id="deinferno/taesd-openvino")
56
  pipe.vae_decoder = CustomOVModelVaeDecoder(model = OVBaseModel.load_model(f"{taesd_dir}/vae_decoder/openvino_model.xml"), parent_model = pipe, model_dir = taesd_dir)
57
 
58
  pipe.reshape(batch_size=batch_size, height=height, width=width, num_images_per_prompt=num_images)
 
66
  def save_image(img, profile: gr.OAuthProfile | None, metadata: dict):
67
  unique_name = str(uuid.uuid4()) + '.png'
68
  img.save(unique_name)
69
+ gr_user_history.save_image(label=metadata["prompt"], image=img, profile=profile, metadata=metadata)
70
  return unique_name
71
 
72
  def save_images(image_array, profile: gr.OAuthProfile | None, metadata: dict):
 
157
  step=1,
158
  value=4,
159
  )
160
+
161
+ with gr.Accordion("Past generations", open=False):
162
+ gr_user_history.render()
163
 
164
  gr.Examples(
165
  examples=examples,
 
189
  if __name__ == "__main__":
190
  demo.queue(api_open=False)
191
  # demo.queue(max_size=20).launch()
192
+ demo.launch()