Spaces:
Running
on
Zero
Running
on
Zero
wanghaofan
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -50,13 +50,14 @@ class calculateDuration:
|
|
50 |
else:
|
51 |
print(f"Elapsed time: {self.elapsed_time:.6f} seconds")
|
52 |
|
53 |
-
def update_selection(evt: gr.SelectData, width, height):
|
54 |
selected_lora = loras[evt.index]
|
55 |
new_placeholder = f"Type a prompt for {selected_lora['title']}"
|
56 |
prompt = selected_lora["prompt"]
|
57 |
lora_repo = selected_lora["repo"]
|
58 |
updated_text = f"### Selected: [{lora_repo}](https://huggingface.co/{lora_repo}) ✨"
|
59 |
-
|
|
|
60 |
if "aspect" in selected_lora:
|
61 |
if selected_lora["aspect"] == "portrait":
|
62 |
width = 768
|
@@ -197,11 +198,13 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css) as app:
|
|
197 |
with gr.Row():
|
198 |
randomize_seed = gr.Checkbox(True, label="Randomize seed")
|
199 |
seed = gr.Slider(label="Seed", minimum=0, maximum=MAX_SEED, step=1, value=0, randomize=True)
|
200 |
-
|
|
|
|
|
201 |
|
202 |
gallery.select(
|
203 |
update_selection,
|
204 |
-
inputs=[width, height],
|
205 |
outputs=[prompt, selected_info, selected_index, width, height, lora_scale]
|
206 |
)
|
207 |
gr.on(
|
|
|
50 |
else:
|
51 |
print(f"Elapsed time: {self.elapsed_time:.6f} seconds")
|
52 |
|
53 |
+
def update_selection(evt: gr.SelectData, width, height, default_scale, lora_scale):
|
54 |
selected_lora = loras[evt.index]
|
55 |
new_placeholder = f"Type a prompt for {selected_lora['title']}"
|
56 |
prompt = selected_lora["prompt"]
|
57 |
lora_repo = selected_lora["repo"]
|
58 |
updated_text = f"### Selected: [{lora_repo}](https://huggingface.co/{lora_repo}) ✨"
|
59 |
+
if default_scale:
|
60 |
+
lora_scale = selected_lora["lora_scale"]
|
61 |
if "aspect" in selected_lora:
|
62 |
if selected_lora["aspect"] == "portrait":
|
63 |
width = 768
|
|
|
198 |
with gr.Row():
|
199 |
randomize_seed = gr.Checkbox(True, label="Randomize seed")
|
200 |
seed = gr.Slider(label="Seed", minimum=0, maximum=MAX_SEED, step=1, value=0, randomize=True)
|
201 |
+
|
202 |
+
default_scale = gr.Checkbox(True, label="Use default LoRA scale")
|
203 |
+
lora_scale = gr.Slider(label="LoRA Scale", minimum=0, maximum=3, step=0.01, value=0.95)
|
204 |
|
205 |
gallery.select(
|
206 |
update_selection,
|
207 |
+
inputs=[width, height, default_scale, lora_scale],
|
208 |
outputs=[prompt, selected_info, selected_index, width, height, lora_scale]
|
209 |
)
|
210 |
gr.on(
|