Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@ import gradio as gr
|
|
3 |
from huggingface_hub import hf_hub_download
|
4 |
import importlib
|
5 |
from functools import lru_cache
|
|
|
6 |
|
7 |
# Import TinyStyler
|
8 |
tinystyler_module = importlib.util.module_from_spec(
|
@@ -51,6 +52,7 @@ def run_tinystyler(source_text, target_texts, reranking, temperature, top_p):
|
|
51 |
200,
|
52 |
device=device,
|
53 |
seed=42,
|
|
|
54 |
)[0]
|
55 |
except Exception as e:
|
56 |
return f"Error: {e}"
|
@@ -101,12 +103,12 @@ with gr.Blocks(theme="ParityError/Interstellar@0.0.1") as demo:
|
|
101 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
102 |
|
103 |
# Immediately load models
|
104 |
-
print("Loading models...")
|
105 |
get_tinystyle_model(device)
|
106 |
get_style_embedding_model(device)
|
107 |
get_luar_model(device)
|
108 |
get_mis_model(device)
|
109 |
-
print("Done loading models.")
|
110 |
|
111 |
gr.Markdown("# TinyStyler Demo")
|
112 |
gr.Markdown(
|
@@ -164,10 +166,10 @@ with gr.Blocks(theme="ParityError/Interstellar@0.0.1") as demo:
|
|
164 |
)
|
165 |
|
166 |
# Pre-warm all examples
|
167 |
-
# print("Pre-warming...")
|
168 |
# for preset_example in preset_examples.values():
|
169 |
# run_tinystyler("A test.", preset_example["target_texts"], 1, 1.0, 1.0)
|
170 |
-
# print("Done pre-warming.")
|
171 |
|
172 |
# Initialize the fields with the first example
|
173 |
(
|
|
|
3 |
from huggingface_hub import hf_hub_download
|
4 |
import importlib
|
5 |
from functools import lru_cache
|
6 |
+
from time import time
|
7 |
|
8 |
# Import TinyStyler
|
9 |
tinystyler_module = importlib.util.module_from_spec(
|
|
|
52 |
200,
|
53 |
device=device,
|
54 |
seed=42,
|
55 |
+
log_timing=True,
|
56 |
)[0]
|
57 |
except Exception as e:
|
58 |
return f"Error: {e}"
|
|
|
103 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
104 |
|
105 |
# Immediately load models
|
106 |
+
print("Loading models...", time())
|
107 |
get_tinystyle_model(device)
|
108 |
get_style_embedding_model(device)
|
109 |
get_luar_model(device)
|
110 |
get_mis_model(device)
|
111 |
+
print("Done loading models.", time())
|
112 |
|
113 |
gr.Markdown("# TinyStyler Demo")
|
114 |
gr.Markdown(
|
|
|
166 |
)
|
167 |
|
168 |
# Pre-warm all examples
|
169 |
+
# print("Pre-warming...", time())
|
170 |
# for preset_example in preset_examples.values():
|
171 |
# run_tinystyler("A test.", preset_example["target_texts"], 1, 1.0, 1.0)
|
172 |
+
# print("Done pre-warming.", time())
|
173 |
|
174 |
# Initialize the fields with the first example
|
175 |
(
|