Upload 2 files
Browse files
app.py
CHANGED
@@ -85,6 +85,19 @@ def change_base_model(repo_id: str, cn_on: bool):
|
|
85 |
|
86 |
change_base_model.zerogpu = True
|
87 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
class calculateDuration:
|
89 |
def __init__(self, activity_name=""):
|
90 |
self.activity_name = activity_name
|
@@ -502,7 +515,7 @@ with gr.Blocks(theme='Nymbo/Nymbo_Theme', fill_width=True, css=css) as app:
|
|
502 |
deselect_lora_button.click(deselect_lora, None, [prompt, selected_info, selected_index, width, height], queue=False, show_api=False)
|
503 |
gr.on(
|
504 |
triggers=[model_name.change, cn_on.change],
|
505 |
-
fn=
|
506 |
inputs=[model_name, cn_on],
|
507 |
outputs=[result],
|
508 |
queue=True,
|
|
|
85 |
|
86 |
change_base_model.zerogpu = True
|
87 |
|
88 |
+
def preload_base_model(repo_id: str, cn_on: bool, progress=gr.Progress(track_tqdm=True)):
|
89 |
+
global last_model
|
90 |
+
global last_cn_on
|
91 |
+
try:
|
92 |
+
if (repo_id == last_model and cn_on is last_cn_on) or not is_repo_name(repo_id) or not is_repo_exists(repo_id): yield gr.update(visible=True)
|
93 |
+
DiffusionPipeline.from_pretrained(repo_id, torch_dtype=dtype)
|
94 |
+
print(f"Caching Model")
|
95 |
+
except Exception as e:
|
96 |
+
print(f"Model cache Error: {e}")
|
97 |
+
yield gr.update(visible=True)
|
98 |
+
|
99 |
+
preload_base_model.zerogpu = True
|
100 |
+
|
101 |
class calculateDuration:
|
102 |
def __init__(self, activity_name=""):
|
103 |
self.activity_name = activity_name
|
|
|
515 |
deselect_lora_button.click(deselect_lora, None, [prompt, selected_info, selected_index, width, height], queue=False, show_api=False)
|
516 |
gr.on(
|
517 |
triggers=[model_name.change, cn_on.change],
|
518 |
+
fn=preload_base_model,
|
519 |
inputs=[model_name, cn_on],
|
520 |
outputs=[result],
|
521 |
queue=True,
|