Spaces:
Running
on
Zero
Running
on
Zero
Commit
•
8fe2fce
1
Parent(s):
24d15b9
Update app.py
Browse files
app.py
CHANGED
@@ -45,7 +45,7 @@ last_merged = False
|
|
45 |
def update_selection(selected_state: gr.SelectData):
|
46 |
lora_repo = sdxl_loras[selected_state.index][2]
|
47 |
instance_prompt = sdxl_loras[selected_state.index][3]
|
48 |
-
new_placeholder = "Type a prompt! This style works for all prompts without a trigger word" if instance_prompt == "Type a prompt to use your selected LoRA"
|
49 |
weight_name = sdxl_loras[selected_state.index][4]
|
50 |
updated_text = f"### Selected: [{lora_repo}](https://huggingface.co/{lora_repo}) ✨"
|
51 |
use_with_diffusers = f'''
|
@@ -89,14 +89,20 @@ def update_selection(selected_state: gr.SelectData):
|
|
89 |
)
|
90 |
|
91 |
|
|
|
|
|
|
|
|
|
92 |
def run_lora(prompt, negative, lora_scale, selected_state):
|
93 |
global last_lora, last_merged, pipe
|
94 |
-
|
|
|
|
|
|
|
95 |
if negative == "":
|
96 |
negative = None
|
97 |
|
98 |
-
|
99 |
-
raise gr.Error("You must select a LoRA")
|
100 |
repo_name = sdxl_loras[selected_state.index][2]
|
101 |
weight_name = sdxl_loras[selected_state.index][4]
|
102 |
full_path_lora = saved_names[selected_state.index]
|
@@ -225,15 +231,26 @@ with gr.Blocks(css="custom.css") as demo:
|
|
225 |
show_progress=False,
|
226 |
)
|
227 |
prompt.submit(
|
|
|
|
|
|
|
|
|
|
|
228 |
fn=run_lora,
|
229 |
inputs=[prompt, negative, weight, selected_state],
|
230 |
outputs=[result, share_group],
|
231 |
)
|
232 |
button.click(
|
|
|
|
|
|
|
|
|
|
|
233 |
fn=run_lora,
|
234 |
inputs=[prompt, negative, weight, selected_state],
|
235 |
outputs=[result, share_group],
|
236 |
)
|
237 |
share_button.click(None, [], [], _js=share_js)
|
238 |
|
|
|
239 |
demo.launch()
|
|
|
45 |
def update_selection(selected_state: gr.SelectData):
|
46 |
lora_repo = sdxl_loras[selected_state.index][2]
|
47 |
instance_prompt = sdxl_loras[selected_state.index][3]
|
48 |
+
new_placeholder = "Type a prompt! This style works for all prompts without a trigger word" if instance_prompt == "" else "Type a prompt to use your selected LoRA"
|
49 |
weight_name = sdxl_loras[selected_state.index][4]
|
50 |
updated_text = f"### Selected: [{lora_repo}](https://huggingface.co/{lora_repo}) ✨"
|
51 |
use_with_diffusers = f'''
|
|
|
89 |
)
|
90 |
|
91 |
|
92 |
+
def check_selected(selected_state):
|
93 |
+
if not selected_state:
|
94 |
+
raise gr.Error("You must select a LoRA")
|
95 |
+
|
96 |
def run_lora(prompt, negative, lora_scale, selected_state):
|
97 |
global last_lora, last_merged, pipe
|
98 |
+
|
99 |
+
if not selected_state:
|
100 |
+
raise gr.Error("You must select a LoRA")
|
101 |
+
|
102 |
if negative == "":
|
103 |
negative = None
|
104 |
|
105 |
+
|
|
|
106 |
repo_name = sdxl_loras[selected_state.index][2]
|
107 |
weight_name = sdxl_loras[selected_state.index][4]
|
108 |
full_path_lora = saved_names[selected_state.index]
|
|
|
231 |
show_progress=False,
|
232 |
)
|
233 |
prompt.submit(
|
234 |
+
fn=check_selected,
|
235 |
+
inputs=[selected_state],
|
236 |
+
queue=False,
|
237 |
+
show_progress=False
|
238 |
+
).then(
|
239 |
fn=run_lora,
|
240 |
inputs=[prompt, negative, weight, selected_state],
|
241 |
outputs=[result, share_group],
|
242 |
)
|
243 |
button.click(
|
244 |
+
fn=check_selected,
|
245 |
+
inputs=[selected_state],
|
246 |
+
queue=False,
|
247 |
+
show_progress=False
|
248 |
+
).then(
|
249 |
fn=run_lora,
|
250 |
inputs=[prompt, negative, weight, selected_state],
|
251 |
outputs=[result, share_group],
|
252 |
)
|
253 |
share_button.click(None, [], [], _js=share_js)
|
254 |
|
255 |
+
demo.queue(max_size=20)
|
256 |
demo.launch()
|