Spaces:
Sleeping
Sleeping
Upload 8 files
Browse files- app.py +4 -11
- requirements.txt +0 -2
app.py
CHANGED
@@ -19,15 +19,12 @@ from optimum.intel.openvino.modeling_diffusion import OVModelVaeDecoder, OVBaseM
|
|
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,7 +32,7 @@ Distilled from [Dreamshaper v7](https://huggingface.co/Lykon/dreamshaper-7) fine
|
|
35 |
MAX_SEED = np.iinfo(np.int32).max
|
36 |
CACHE_EXAMPLES = os.getenv("CACHE_EXAMPLES") == "1"
|
37 |
|
38 |
-
model_id = "
|
39 |
batch_size = 1
|
40 |
width = int(os.getenv("IMAGE_WIDTH", "512"))
|
41 |
height = int(os.getenv("IMAGE_HEIGHT", "512"))
|
@@ -52,7 +49,7 @@ pipe = OVLatentConsistencyModelPipeline.from_pretrained(model_id, scheduler = sc
|
|
52 |
|
53 |
# Inject TAESD
|
54 |
|
55 |
-
taesd_dir = snapshot_download(repo_id="
|
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,7 +63,6 @@ def randomize_seed_fn(seed: int, randomize_seed: bool) -> int:
|
|
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,9 +153,6 @@ with gr.Blocks(css="style.css") as demo:
|
|
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,4 +182,4 @@ with gr.Blocks(css="style.css") as demo:
|
|
189 |
if __name__ == "__main__":
|
190 |
demo.queue(api_open=False)
|
191 |
# demo.queue(max_size=20).launch()
|
192 |
-
demo.launch()
|
|
|
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 |
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 |
|
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 |
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 |
step=1,
|
154 |
value=4,
|
155 |
)
|
|
|
|
|
|
|
156 |
|
157 |
gr.Examples(
|
158 |
examples=examples,
|
|
|
182 |
if __name__ == "__main__":
|
183 |
demo.queue(api_open=False)
|
184 |
# demo.queue(max_size=20).launch()
|
185 |
+
demo.launch()
|
requirements.txt
CHANGED
@@ -9,5 +9,3 @@ optimum==1.13.2
|
|
9 |
optimum-intel==1.11.0
|
10 |
onnx==1.14.1
|
11 |
transformers==4.31.0
|
12 |
-
|
13 |
-
git+https://huggingface.co/spaces/Wauplin/gradio-user-history
|
|
|
9 |
optimum-intel==1.11.0
|
10 |
onnx==1.14.1
|
11 |
transformers==4.31.0
|
|
|
|