Spaces:
Sleeping
Sleeping
Commit
·
0f2c19b
1
Parent(s):
4a9687c
Updates
Browse files
app.py
CHANGED
@@ -58,7 +58,7 @@ class calculateDuration:
|
|
58 |
|
59 |
def update_selection(evt: gr.SelectData, width, height):
|
60 |
selected_lora = loras[evt.index]
|
61 |
-
new_placeholder = f"
|
62 |
lora_repo = selected_lora["repo"]
|
63 |
updated_text = f"### Selected: [{lora_repo}](https://huggingface.co/{lora_repo}) ✨"
|
64 |
if "aspect" in selected_lora:
|
@@ -72,7 +72,7 @@ def update_selection(evt: gr.SelectData, width, height):
|
|
72 |
width = 1024
|
73 |
height = 1024
|
74 |
return (
|
75 |
-
gr.update(
|
76 |
updated_text,
|
77 |
evt.index,
|
78 |
width,
|
@@ -117,7 +117,7 @@ def generate_image_to_image(prompt_mash, image_input_path, image_strength, steps
|
|
117 |
).images[0]
|
118 |
return final_image
|
119 |
|
120 |
-
def run_lora(prompt,
|
121 |
if selected_index is None:
|
122 |
raise gr.Error("You must select a LoRA before proceeding.")
|
123 |
|
@@ -199,7 +199,6 @@ with gr.Blocks() as demo:
|
|
199 |
placeholder="Type your prompt here...",
|
200 |
show_label=True,
|
201 |
)
|
202 |
-
image_input = gr.Image(type="filepath", label="Image Input (Optional)")
|
203 |
|
204 |
with gr.Row():
|
205 |
generate = gr.Button("Generate", variant="primary")
|
@@ -215,11 +214,10 @@ with gr.Blocks() as demo:
|
|
215 |
with gr.Column():
|
216 |
steps = gr.Slider(minimum=1, maximum=100, value=28, step=1, label="Steps")
|
217 |
cfg_scale = gr.Slider(minimum=1, maximum=20, value=3.5, step=0.1, label="CFG Scale")
|
218 |
-
lora_scale = gr.Slider(minimum=0, maximum=
|
219 |
with gr.Column():
|
220 |
width = gr.Slider(minimum=256, maximum=1024, value=512, step=64, label="Width")
|
221 |
height = gr.Slider(minimum=256, maximum=1024, value=512, step=64, label="Height")
|
222 |
-
image_strength = gr.Slider(minimum=0, maximum=1, value=0.8, step=0.05, label="Image Strength")
|
223 |
|
224 |
with gr.Row():
|
225 |
randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
|
@@ -231,7 +229,7 @@ with gr.Blocks() as demo:
|
|
231 |
# Event handlers
|
232 |
gallery.select(update_selection, [width, height], [prompt, selected_lora, gr.State(), width, height])
|
233 |
randomize_seed.change(lambda x: gr.update(visible=not x), randomize_seed, seed_input)
|
234 |
-
generate_event = generate.click(run_lora, inputs=[prompt,
|
235 |
cancel.click(lambda: None, None, None, cancels=[generate_event])
|
236 |
|
237 |
demo.queue().launch()
|
|
|
58 |
|
59 |
def update_selection(evt: gr.SelectData, width, height):
|
60 |
selected_lora = loras[evt.index]
|
61 |
+
new_placeholder = f"{selected_lora['trigger_word']} {prompt.value}"
|
62 |
lora_repo = selected_lora["repo"]
|
63 |
updated_text = f"### Selected: [{lora_repo}](https://huggingface.co/{lora_repo}) ✨"
|
64 |
if "aspect" in selected_lora:
|
|
|
72 |
width = 1024
|
73 |
height = 1024
|
74 |
return (
|
75 |
+
gr.update(value=new_placeholder),
|
76 |
updated_text,
|
77 |
evt.index,
|
78 |
width,
|
|
|
117 |
).images[0]
|
118 |
return final_image
|
119 |
|
120 |
+
def run_lora(prompt, cfg_scale, steps, selected_index, randomize_seed, seed, width, height, lora_scale, progress=gr.Progress(track_tqdm=True)):
|
121 |
if selected_index is None:
|
122 |
raise gr.Error("You must select a LoRA before proceeding.")
|
123 |
|
|
|
199 |
placeholder="Type your prompt here...",
|
200 |
show_label=True,
|
201 |
)
|
|
|
202 |
|
203 |
with gr.Row():
|
204 |
generate = gr.Button("Generate", variant="primary")
|
|
|
214 |
with gr.Column():
|
215 |
steps = gr.Slider(minimum=1, maximum=100, value=28, step=1, label="Steps")
|
216 |
cfg_scale = gr.Slider(minimum=1, maximum=20, value=3.5, step=0.1, label="CFG Scale")
|
217 |
+
lora_scale = gr.Slider(minimum=0, maximum=2, value=1, step=0.1, label="LoRA Scale")
|
218 |
with gr.Column():
|
219 |
width = gr.Slider(minimum=256, maximum=1024, value=512, step=64, label="Width")
|
220 |
height = gr.Slider(minimum=256, maximum=1024, value=512, step=64, label="Height")
|
|
|
221 |
|
222 |
with gr.Row():
|
223 |
randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
|
|
|
229 |
# Event handlers
|
230 |
gallery.select(update_selection, [width, height], [prompt, selected_lora, gr.State(), width, height])
|
231 |
randomize_seed.change(lambda x: gr.update(visible=not x), randomize_seed, seed_input)
|
232 |
+
generate_event = generate.click(run_lora, inputs=[prompt, cfg_scale, steps, gr.State(), randomize_seed, seed_input, width, height, lora_scale], outputs=[result, seed_output, progress_bar])
|
233 |
cancel.click(lambda: None, None, None, cancels=[generate_event])
|
234 |
|
235 |
demo.queue().launch()
|