UI polish: LoRA prompt, gallery, refs reorder, dual Generate
Browse files- Keep LoRA prompt box always visible; stop input/select race hiding it
- Taller output gallery without forced preview chrome/scrollbars
- Enter/Shift+Enter both insert newlines in multi-line prompt boxes
- Extra Generate button under Base image
- Deleting a ref packs remaining refs upward
- β/β reorder Base + Reference slots
Co-Authored-By: Oz <oz-agent@warp.dev>
- app.py +150 -53
- image_utils.py +131 -58
- lora_registry.py +7 -4
app.py
CHANGED
|
@@ -43,8 +43,13 @@ from image_utils import (
|
|
| 43 |
on_base_image_change,
|
| 44 |
collect_reference_images,
|
| 45 |
reference_info_text,
|
| 46 |
-
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
process_images,
|
| 49 |
reencode_upload,
|
| 50 |
send_editor_to_base,
|
|
@@ -490,12 +495,60 @@ def update_custom_prompt_display(selected_names, prompts_state):
|
|
| 490 |
# Keep this moderate β oversized Gallery CSS previously split the reference
|
| 491 |
# panel into a huge empty pane + tiny control strip.
|
| 492 |
_IMAGE_BOX_H = 320
|
|
|
|
| 493 |
|
| 494 |
css = f"""
|
| 495 |
#col-container {{ margin: 0 auto; max-width: 1100px; }}
|
| 496 |
#main-title h1 {{ font-size: 2.4em !important; }}
|
| 497 |
.lora-weight-row {{ background: var(--block-background-fill); border-radius: 8px; padding: 4px 12px; margin-bottom: 4px; }}
|
| 498 |
#used_seed textarea {{ min-height: 0 !important; height: 2.2rem !important; }}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 499 |
"""
|
| 500 |
|
| 501 |
# Gradio 6.0: theme/css go on launch(), not Blocks()
|
|
@@ -532,16 +585,26 @@ with gr.Blocks() as demo:
|
|
| 532 |
height=_IMAGE_BOX_H,
|
| 533 |
elem_id="base_image",
|
| 534 |
)
|
|
|
|
|
|
|
| 535 |
size_info = gr.Markdown("*No image uploaded yet*")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 536 |
|
| 537 |
# Progressive single-image refs (max 3). Ref2 appears after
|
| 538 |
-
# Ref1 is set; Ref3 after Ref2.
|
|
|
|
| 539 |
ref1 = gr.Image(
|
| 540 |
label="Reference 1 β optional", type="pil",
|
| 541 |
sources=["upload", "clipboard"],
|
| 542 |
height=_IMAGE_BOX_H,
|
| 543 |
elem_id="ref1",
|
| 544 |
)
|
|
|
|
|
|
|
|
|
|
| 545 |
ref2 = gr.Image(
|
| 546 |
label="Reference 2 β optional", type="pil",
|
| 547 |
sources=["upload", "clipboard"],
|
|
@@ -549,6 +612,9 @@ with gr.Blocks() as demo:
|
|
| 549 |
visible=False,
|
| 550 |
elem_id="ref2",
|
| 551 |
)
|
|
|
|
|
|
|
|
|
|
| 552 |
ref3 = gr.Image(
|
| 553 |
label="Reference 3 β optional", type="pil",
|
| 554 |
sources=["upload", "clipboard"],
|
|
@@ -556,29 +622,43 @@ with gr.Blocks() as demo:
|
|
| 556 |
visible=False,
|
| 557 |
elem_id="ref3",
|
| 558 |
)
|
|
|
|
|
|
|
| 559 |
reference_info = gr.Markdown("π· No reference images")
|
| 560 |
gr.Markdown(
|
| 561 |
"*Up to 3 reference images. Next box appears after you fill the previous one. "
|
|
|
|
| 562 |
"Face Swap uses Base + Reference 1 only.*"
|
| 563 |
)
|
| 564 |
|
| 565 |
-
prompt = gr.
|
| 566 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 567 |
lora_prompt_display = gr.Textbox(
|
| 568 |
label="LoRA prompts (auto-filled from selection β editable for this run)",
|
| 569 |
-
interactive=True,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 570 |
info="Filled when you tick LoRAs. Edit freely for the current generate; "
|
| 571 |
"does not change the stored catalog default.",
|
| 572 |
)
|
| 573 |
-
custom_prompt_display = gr.Textbox(
|
| 574 |
-
|
|
|
|
|
|
|
| 575 |
run_button = gr.Button("βΆ Generate", variant="primary", size="lg")
|
| 576 |
|
| 577 |
with gr.Column(scale=1):
|
| 578 |
output_gallery = gr.Gallery(
|
| 579 |
-
label="Output", type="filepath", columns=2, rows=
|
| 580 |
-
height=
|
| 581 |
-
allow_preview=True, preview=
|
| 582 |
object_fit="contain", show_label=True,
|
| 583 |
elem_id="output_gallery",
|
| 584 |
)
|
|
@@ -988,17 +1068,34 @@ with gr.Blocks() as demo:
|
|
| 988 |
base_image.upload(fn=reencode_upload, inputs=[base_image], outputs=[base_image], **_ui)
|
| 989 |
base_image.change(fn=on_base_image_change, inputs=[base_image], outputs=[size_info], **_ui)
|
| 990 |
|
| 991 |
-
# Progressive ref slots:
|
| 992 |
-
#
|
| 993 |
-
# the component that fired (avoids change-event loops).
|
| 994 |
for _ref in (ref1, ref2, ref3):
|
| 995 |
_ref.upload(fn=reencode_upload, inputs=[_ref], outputs=[_ref], **_ui)
|
| 996 |
-
|
| 997 |
-
|
| 998 |
-
|
| 999 |
-
|
| 1000 |
-
|
| 1001 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1002 |
|
| 1003 |
# Every browser open re-reads the bucket JSON and refreshes selector choices.
|
| 1004 |
# Without this, choices stay frozen at process start and newly saved LoRAs
|
|
@@ -1026,8 +1123,8 @@ with gr.Blocks() as demo:
|
|
| 1026 |
)
|
| 1027 |
|
| 1028 |
# update_weight_sliders is the one imported from lora_registry now.
|
| 1029 |
-
#
|
| 1030 |
-
#
|
| 1031 |
# Pass live slider/prompt values + memory so existing settings survive add/remove.
|
| 1032 |
_lora_slider_inputs = [
|
| 1033 |
lora_selector, dynamic_loras_state,
|
|
@@ -1047,23 +1144,6 @@ with gr.Blocks() as demo:
|
|
| 1047 |
show_progress="hidden",
|
| 1048 |
trigger_mode="once",
|
| 1049 |
)
|
| 1050 |
-
# Also fire on input/select where available so checkbox UI updates aren't missed.
|
| 1051 |
-
if hasattr(lora_selector, "input"):
|
| 1052 |
-
lora_selector.input(
|
| 1053 |
-
fn=update_weight_sliders,
|
| 1054 |
-
inputs=_lora_slider_inputs,
|
| 1055 |
-
outputs=_lora_slider_outputs,
|
| 1056 |
-
show_progress="hidden",
|
| 1057 |
-
trigger_mode="once",
|
| 1058 |
-
)
|
| 1059 |
-
if hasattr(lora_selector, "select"):
|
| 1060 |
-
lora_selector.select(
|
| 1061 |
-
fn=update_weight_sliders,
|
| 1062 |
-
inputs=_lora_slider_inputs,
|
| 1063 |
-
outputs=_lora_slider_outputs,
|
| 1064 |
-
show_progress="hidden",
|
| 1065 |
-
trigger_mode="once",
|
| 1066 |
-
)
|
| 1067 |
|
| 1068 |
# add_custom_lora is also imported from lora_registry.
|
| 1069 |
# Always session-only; optional persist / remove are separate explicit actions.
|
|
@@ -1164,20 +1244,32 @@ with gr.Blocks() as demo:
|
|
| 1164 |
# Reset any stale gallery selection before a new run starts, so SendβBase
|
| 1165 |
# / SendβRef after this run can't accidentally reuse a path from the
|
| 1166 |
# previous run's gallery contents.
|
| 1167 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1168 |
|
| 1169 |
run_event = run_button.click(
|
| 1170 |
fn=infer,
|
| 1171 |
-
inputs=
|
| 1172 |
-
lora_selector, seed, randomize_seed, guidance_scale, steps, upscale_factor,
|
| 1173 |
-
canvas_mode, custom_width, custom_height, canvas_fit_mode, pad_color,
|
| 1174 |
-
batch_count, batch_vary, sweep_min, sweep_max, project_name,
|
| 1175 |
-
dynamic_loras_state] + weight_sliders,
|
| 1176 |
# Download bundle on every generate yield β required because
|
| 1177 |
# gallery.change alone misses the first virgin-session result.
|
| 1178 |
-
outputs=
|
| 1179 |
-
|
| 1180 |
-
|
|
|
|
|
|
|
|
|
|
| 1181 |
)
|
| 1182 |
|
| 1183 |
# ββ Editor tab wiring ββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
@@ -1187,10 +1279,14 @@ with gr.Blocks() as demo:
|
|
| 1187 |
.then(fn=on_base_image_change, inputs=[base_image], outputs=[size_info]) \
|
| 1188 |
.then(fn=lambda: gr.Tabs(selected="tab_generate"), outputs=[main_tabs])
|
| 1189 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1190 |
send_to_ref_btn.click(
|
| 1191 |
fn=send_editor_to_reference,
|
| 1192 |
inputs=[editor, ref1, ref2, ref3],
|
| 1193 |
-
outputs=
|
| 1194 |
).then(fn=lambda: gr.Tabs(selected="tab_generate"), outputs=[main_tabs])
|
| 1195 |
|
| 1196 |
send_out_to_base_btn.click(
|
|
@@ -1202,7 +1298,7 @@ with gr.Blocks() as demo:
|
|
| 1202 |
send_out_to_ref_btn.click(
|
| 1203 |
fn=send_output_to_reference,
|
| 1204 |
inputs=[selected_output_state, output_gallery, ref1, ref2, ref3],
|
| 1205 |
-
outputs=
|
| 1206 |
)
|
| 1207 |
|
| 1208 |
# Extend-canvas wiring
|
|
@@ -1261,7 +1357,7 @@ with gr.Blocks() as demo:
|
|
| 1261 |
)
|
| 1262 |
|
| 1263 |
bulk_stop_btn.click(fn=lambda: gr.Info("Stop requested β finishing current image."),
|
| 1264 |
-
cancels=[bulk_event, run_event])
|
| 1265 |
|
| 1266 |
# ββ Depth / Pose tab wiring ββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1267 |
|
|
@@ -1398,7 +1494,7 @@ with gr.Blocks() as demo:
|
|
| 1398 |
|
| 1399 |
send_depth_ref_btn.click(
|
| 1400 |
fn=push_pil_to_reference, inputs=[depth_output, ref1, ref2, ref3],
|
| 1401 |
-
outputs=
|
| 1402 |
).then(fn=lambda: gr.Tabs(selected="tab_generate"), outputs=[main_tabs])
|
| 1403 |
|
| 1404 |
send_depth_base_btn.click(
|
|
@@ -1408,7 +1504,7 @@ with gr.Blocks() as demo:
|
|
| 1408 |
|
| 1409 |
send_pose_ref_btn.click(
|
| 1410 |
fn=push_pil_to_reference, inputs=[pose_clean, ref1, ref2, ref3],
|
| 1411 |
-
outputs=
|
| 1412 |
).then(fn=lambda: gr.Tabs(selected="tab_generate"), outputs=[main_tabs])
|
| 1413 |
|
| 1414 |
send_pose_base_btn.click(
|
|
@@ -1419,6 +1515,7 @@ with gr.Blocks() as demo:
|
|
| 1419 |
|
| 1420 |
if __name__ == "__main__":
|
| 1421 |
# Gradio 6.0: theme and css go on launch(), not Blocks()
|
|
|
|
| 1422 |
demo.queue().launch(css=css, theme=orange_red_theme,
|
| 1423 |
mcp_server=True, ssr_mode=False, show_error=True)
|
| 1424 |
|
|
|
|
| 43 |
on_base_image_change,
|
| 44 |
collect_reference_images,
|
| 45 |
reference_info_text,
|
| 46 |
+
compact_reference_slots,
|
| 47 |
+
move_base_down,
|
| 48 |
+
move_ref1_up,
|
| 49 |
+
move_ref1_down,
|
| 50 |
+
move_ref2_up,
|
| 51 |
+
move_ref2_down,
|
| 52 |
+
move_ref3_up,
|
| 53 |
process_images,
|
| 54 |
reencode_upload,
|
| 55 |
send_editor_to_base,
|
|
|
|
| 495 |
# Keep this moderate β oversized Gallery CSS previously split the reference
|
| 496 |
# panel into a huge empty pane + tiny control strip.
|
| 497 |
_IMAGE_BOX_H = 320
|
| 498 |
+
_OUTPUT_GALLERY_H = 520
|
| 499 |
|
| 500 |
css = f"""
|
| 501 |
#col-container {{ margin: 0 auto; max-width: 1100px; }}
|
| 502 |
#main-title h1 {{ font-size: 2.4em !important; }}
|
| 503 |
.lora-weight-row {{ background: var(--block-background-fill); border-radius: 8px; padding: 4px 12px; margin-bottom: 4px; }}
|
| 504 |
#used_seed textarea {{ min-height: 0 !important; height: 2.2rem !important; }}
|
| 505 |
+
/* Output gallery: avoid huge empty preview chrome / forced scrollbars */
|
| 506 |
+
#output_gallery {{ min-height: {_OUTPUT_GALLERY_H}px; }}
|
| 507 |
+
#output_gallery .grid-wrap,
|
| 508 |
+
#output_gallery .gallery-container,
|
| 509 |
+
#output_gallery .thumbnail-item,
|
| 510 |
+
#output_gallery .preview-image,
|
| 511 |
+
#output_gallery img {{
|
| 512 |
+
max-height: {_OUTPUT_GALLERY_H - 48}px !important;
|
| 513 |
+
object-fit: contain !important;
|
| 514 |
+
}}
|
| 515 |
+
#output_gallery .preview {{
|
| 516 |
+
max-height: {_OUTPUT_GALLERY_H - 24}px !important;
|
| 517 |
+
overflow: hidden !important;
|
| 518 |
+
}}
|
| 519 |
+
.slot-move-row button {{ min-width: 2.4rem !important; }}
|
| 520 |
+
"""
|
| 521 |
+
|
| 522 |
+
# Enter inserts newline in multi-line textboxes (Gradio default often submits).
|
| 523 |
+
# Shift+Enter also inserts newline for muscle-memory parity with chat UIs.
|
| 524 |
+
_TEXTBOX_NEWLINE_JS = """
|
| 525 |
+
() => {
|
| 526 |
+
const isMulti = (el) => {
|
| 527 |
+
if (!el || el.tagName !== 'TEXTAREA') return false;
|
| 528 |
+
if (el.closest('#used_seed') || el.closest('#project_name')) return false;
|
| 529 |
+
return true;
|
| 530 |
+
};
|
| 531 |
+
const onKey = (e) => {
|
| 532 |
+
if (e.key !== 'Enter' || e.isComposing) return;
|
| 533 |
+
const t = e.target;
|
| 534 |
+
if (!isMulti(t)) return;
|
| 535 |
+
// Always keep newline behaviour; never submit the form from a prompt box.
|
| 536 |
+
e.stopPropagation();
|
| 537 |
+
// Browser already inserts newline on plain Enter in textarea;
|
| 538 |
+
// for Shift+Enter some hosts swallow it β insert manually if needed.
|
| 539 |
+
if (e.shiftKey) {
|
| 540 |
+
e.preventDefault();
|
| 541 |
+
const start = t.selectionStart ?? t.value.length;
|
| 542 |
+
const end = t.selectionEnd ?? start;
|
| 543 |
+
const v = t.value;
|
| 544 |
+
t.value = v.slice(0, start) + '\\n' + v.slice(end);
|
| 545 |
+
const pos = start + 1;
|
| 546 |
+
t.selectionStart = t.selectionEnd = pos;
|
| 547 |
+
t.dispatchEvent(new Event('input', { bubbles: true }));
|
| 548 |
+
}
|
| 549 |
+
};
|
| 550 |
+
document.addEventListener('keydown', onKey, true);
|
| 551 |
+
}
|
| 552 |
"""
|
| 553 |
|
| 554 |
# Gradio 6.0: theme/css go on launch(), not Blocks()
|
|
|
|
| 585 |
height=_IMAGE_BOX_H,
|
| 586 |
elem_id="base_image",
|
| 587 |
)
|
| 588 |
+
with gr.Row(elem_classes="slot-move-row"):
|
| 589 |
+
base_down_btn = gr.Button("β Base β Ref1", size="sm")
|
| 590 |
size_info = gr.Markdown("*No image uploaded yet*")
|
| 591 |
+
run_button_top = gr.Button(
|
| 592 |
+
"βΆ Generate", variant="primary", size="lg",
|
| 593 |
+
elem_id="run_button_top",
|
| 594 |
+
)
|
| 595 |
|
| 596 |
# Progressive single-image refs (max 3). Ref2 appears after
|
| 597 |
+
# Ref1 is set; Ref3 after Ref2. Deleting a middle slot packs
|
| 598 |
+
# remaining refs upward. Reorder with β/β (includes Base).
|
| 599 |
ref1 = gr.Image(
|
| 600 |
label="Reference 1 β optional", type="pil",
|
| 601 |
sources=["upload", "clipboard"],
|
| 602 |
height=_IMAGE_BOX_H,
|
| 603 |
elem_id="ref1",
|
| 604 |
)
|
| 605 |
+
with gr.Row(elem_classes="slot-move-row"):
|
| 606 |
+
ref1_up_btn = gr.Button("β", size="sm", scale=0)
|
| 607 |
+
ref1_down_btn = gr.Button("β", size="sm", scale=0)
|
| 608 |
ref2 = gr.Image(
|
| 609 |
label="Reference 2 β optional", type="pil",
|
| 610 |
sources=["upload", "clipboard"],
|
|
|
|
| 612 |
visible=False,
|
| 613 |
elem_id="ref2",
|
| 614 |
)
|
| 615 |
+
with gr.Row(elem_classes="slot-move-row"):
|
| 616 |
+
ref2_up_btn = gr.Button("β", size="sm", scale=0, visible=False)
|
| 617 |
+
ref2_down_btn = gr.Button("β", size="sm", scale=0, visible=False)
|
| 618 |
ref3 = gr.Image(
|
| 619 |
label="Reference 3 β optional", type="pil",
|
| 620 |
sources=["upload", "clipboard"],
|
|
|
|
| 622 |
visible=False,
|
| 623 |
elem_id="ref3",
|
| 624 |
)
|
| 625 |
+
with gr.Row(elem_classes="slot-move-row"):
|
| 626 |
+
ref3_up_btn = gr.Button("β", size="sm", scale=0, visible=False)
|
| 627 |
reference_info = gr.Markdown("π· No reference images")
|
| 628 |
gr.Markdown(
|
| 629 |
"*Up to 3 reference images. Next box appears after you fill the previous one. "
|
| 630 |
+
"Clearing a slot shifts the others up. Use β/β to reorder Base + refs. "
|
| 631 |
"Face Swap uses Base + Reference 1 only.*"
|
| 632 |
)
|
| 633 |
|
| 634 |
+
prompt = gr.Textbox(
|
| 635 |
+
label="Prompt",
|
| 636 |
+
lines=3,
|
| 637 |
+
max_lines=12,
|
| 638 |
+
placeholder="Describe the edit, or leave blank for style-only LoRAs. Enter = new line.",
|
| 639 |
+
)
|
| 640 |
lora_prompt_display = gr.Textbox(
|
| 641 |
label="LoRA prompts (auto-filled from selection β editable for this run)",
|
| 642 |
+
interactive=True,
|
| 643 |
+
visible=True,
|
| 644 |
+
lines=3,
|
| 645 |
+
max_lines=16,
|
| 646 |
+
value="",
|
| 647 |
+
placeholder="Tick LoRAs above to auto-fill. Edits are kept when you change selection.",
|
| 648 |
info="Filled when you tick LoRAs. Edit freely for the current generate; "
|
| 649 |
"does not change the stored catalog default.",
|
| 650 |
)
|
| 651 |
+
custom_prompt_display = gr.Textbox(
|
| 652 |
+
label="Custom Prompts (auto-appended)",
|
| 653 |
+
interactive=False, visible=False, lines=3, max_lines=12,
|
| 654 |
+
)
|
| 655 |
run_button = gr.Button("βΆ Generate", variant="primary", size="lg")
|
| 656 |
|
| 657 |
with gr.Column(scale=1):
|
| 658 |
output_gallery = gr.Gallery(
|
| 659 |
+
label="Output", type="filepath", columns=2, rows=1,
|
| 660 |
+
height=_OUTPUT_GALLERY_H,
|
| 661 |
+
allow_preview=True, preview=False,
|
| 662 |
object_fit="contain", show_label=True,
|
| 663 |
elem_id="output_gallery",
|
| 664 |
)
|
|
|
|
| 1068 |
base_image.upload(fn=reencode_upload, inputs=[base_image], outputs=[base_image], **_ui)
|
| 1069 |
base_image.change(fn=on_base_image_change, inputs=[base_image], outputs=[size_info], **_ui)
|
| 1070 |
|
| 1071 |
+
# Progressive ref slots: pack non-empty images upward on any change so
|
| 1072 |
+
# deleting Ref1 shifts Ref2/3 up instead of wiping them.
|
|
|
|
| 1073 |
for _ref in (ref1, ref2, ref3):
|
| 1074 |
_ref.upload(fn=reencode_upload, inputs=[_ref], outputs=[_ref], **_ui)
|
| 1075 |
+
|
| 1076 |
+
_ref_compact_outputs = [
|
| 1077 |
+
ref1, ref2, ref3, reference_info,
|
| 1078 |
+
ref2_up_btn, ref2_down_btn, ref3_up_btn,
|
| 1079 |
+
]
|
| 1080 |
+
for _ref in (ref1, ref2, ref3):
|
| 1081 |
+
_ref.change(
|
| 1082 |
+
fn=compact_reference_slots,
|
| 1083 |
+
inputs=[ref1, ref2, ref3],
|
| 1084 |
+
outputs=_ref_compact_outputs,
|
| 1085 |
+
**_ui,
|
| 1086 |
+
)
|
| 1087 |
+
|
| 1088 |
+
_slot_inputs = [base_image, ref1, ref2, ref3]
|
| 1089 |
+
_move_outputs = [
|
| 1090 |
+
base_image, ref1, ref2, ref3, reference_info,
|
| 1091 |
+
ref2_up_btn, ref2_down_btn, ref3_up_btn,
|
| 1092 |
+
]
|
| 1093 |
+
base_down_btn.click(fn=move_base_down, inputs=_slot_inputs, outputs=_move_outputs, **_ui)
|
| 1094 |
+
ref1_up_btn.click(fn=move_ref1_up, inputs=_slot_inputs, outputs=_move_outputs, **_ui)
|
| 1095 |
+
ref1_down_btn.click(fn=move_ref1_down, inputs=_slot_inputs, outputs=_move_outputs, **_ui)
|
| 1096 |
+
ref2_up_btn.click(fn=move_ref2_up, inputs=_slot_inputs, outputs=_move_outputs, **_ui)
|
| 1097 |
+
ref2_down_btn.click(fn=move_ref2_down, inputs=_slot_inputs, outputs=_move_outputs, **_ui)
|
| 1098 |
+
ref3_up_btn.click(fn=move_ref3_up, inputs=_slot_inputs, outputs=_move_outputs, **_ui)
|
| 1099 |
|
| 1100 |
# Every browser open re-reads the bucket JSON and refreshes selector choices.
|
| 1101 |
# Without this, choices stay frozen at process start and newly saved LoRAs
|
|
|
|
| 1123 |
)
|
| 1124 |
|
| 1125 |
# update_weight_sliders is the one imported from lora_registry now.
|
| 1126 |
+
# Only wire .change β also binding .input/.select raced and could leave the
|
| 1127 |
+
# LoRA prompt box hidden/empty while still applying defaults at generate time.
|
| 1128 |
# Pass live slider/prompt values + memory so existing settings survive add/remove.
|
| 1129 |
_lora_slider_inputs = [
|
| 1130 |
lora_selector, dynamic_loras_state,
|
|
|
|
| 1144 |
show_progress="hidden",
|
| 1145 |
trigger_mode="once",
|
| 1146 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1147 |
|
| 1148 |
# add_custom_lora is also imported from lora_registry.
|
| 1149 |
# Always session-only; optional persist / remove are separate explicit actions.
|
|
|
|
| 1244 |
# Reset any stale gallery selection before a new run starts, so SendβBase
|
| 1245 |
# / SendβRef after this run can't accidentally reuse a path from the
|
| 1246 |
# previous run's gallery contents.
|
| 1247 |
+
_infer_inputs = [
|
| 1248 |
+
base_image, ref1, ref2, ref3, prompt, lora_prompt_display, custom_prompt_display,
|
| 1249 |
+
lora_selector, seed, randomize_seed, guidance_scale, steps, upscale_factor,
|
| 1250 |
+
canvas_mode, custom_width, custom_height, canvas_fit_mode, pad_color,
|
| 1251 |
+
batch_count, batch_vary, sweep_min, sweep_max, project_name,
|
| 1252 |
+
dynamic_loras_state,
|
| 1253 |
+
] + weight_sliders
|
| 1254 |
+
_infer_outputs = [
|
| 1255 |
+
output_gallery, used_seed,
|
| 1256 |
+
download_png_btn, download_webp_btn, download_prompt_btn,
|
| 1257 |
+
last_prompt_state,
|
| 1258 |
+
]
|
| 1259 |
+
for _run_btn in (run_button, run_button_top):
|
| 1260 |
+
_run_btn.click(fn=lambda: None, outputs=[selected_output_state])
|
| 1261 |
|
| 1262 |
run_event = run_button.click(
|
| 1263 |
fn=infer,
|
| 1264 |
+
inputs=_infer_inputs,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1265 |
# Download bundle on every generate yield β required because
|
| 1266 |
# gallery.change alone misses the first virgin-session result.
|
| 1267 |
+
outputs=_infer_outputs,
|
| 1268 |
+
)
|
| 1269 |
+
run_event_top = run_button_top.click(
|
| 1270 |
+
fn=infer,
|
| 1271 |
+
inputs=_infer_inputs,
|
| 1272 |
+
outputs=_infer_outputs,
|
| 1273 |
)
|
| 1274 |
|
| 1275 |
# ββ Editor tab wiring ββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
|
|
| 1279 |
.then(fn=on_base_image_change, inputs=[base_image], outputs=[size_info]) \
|
| 1280 |
.then(fn=lambda: gr.Tabs(selected="tab_generate"), outputs=[main_tabs])
|
| 1281 |
|
| 1282 |
+
_send_ref_outputs = [
|
| 1283 |
+
ref1, ref2, ref3, reference_info,
|
| 1284 |
+
ref2_up_btn, ref2_down_btn, ref3_up_btn,
|
| 1285 |
+
]
|
| 1286 |
send_to_ref_btn.click(
|
| 1287 |
fn=send_editor_to_reference,
|
| 1288 |
inputs=[editor, ref1, ref2, ref3],
|
| 1289 |
+
outputs=_send_ref_outputs,
|
| 1290 |
).then(fn=lambda: gr.Tabs(selected="tab_generate"), outputs=[main_tabs])
|
| 1291 |
|
| 1292 |
send_out_to_base_btn.click(
|
|
|
|
| 1298 |
send_out_to_ref_btn.click(
|
| 1299 |
fn=send_output_to_reference,
|
| 1300 |
inputs=[selected_output_state, output_gallery, ref1, ref2, ref3],
|
| 1301 |
+
outputs=_send_ref_outputs,
|
| 1302 |
)
|
| 1303 |
|
| 1304 |
# Extend-canvas wiring
|
|
|
|
| 1357 |
)
|
| 1358 |
|
| 1359 |
bulk_stop_btn.click(fn=lambda: gr.Info("Stop requested β finishing current image."),
|
| 1360 |
+
cancels=[bulk_event, run_event, run_event_top])
|
| 1361 |
|
| 1362 |
# ββ Depth / Pose tab wiring ββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1363 |
|
|
|
|
| 1494 |
|
| 1495 |
send_depth_ref_btn.click(
|
| 1496 |
fn=push_pil_to_reference, inputs=[depth_output, ref1, ref2, ref3],
|
| 1497 |
+
outputs=_send_ref_outputs,
|
| 1498 |
).then(fn=lambda: gr.Tabs(selected="tab_generate"), outputs=[main_tabs])
|
| 1499 |
|
| 1500 |
send_depth_base_btn.click(
|
|
|
|
| 1504 |
|
| 1505 |
send_pose_ref_btn.click(
|
| 1506 |
fn=push_pil_to_reference, inputs=[pose_clean, ref1, ref2, ref3],
|
| 1507 |
+
outputs=_send_ref_outputs,
|
| 1508 |
).then(fn=lambda: gr.Tabs(selected="tab_generate"), outputs=[main_tabs])
|
| 1509 |
|
| 1510 |
send_pose_base_btn.click(
|
|
|
|
| 1515 |
|
| 1516 |
if __name__ == "__main__":
|
| 1517 |
# Gradio 6.0: theme and css go on launch(), not Blocks()
|
| 1518 |
+
demo.load(fn=None, js=_TEXTBOX_NEWLINE_JS)
|
| 1519 |
demo.queue().launch(css=css, theme=orange_red_theme,
|
| 1520 |
mcp_server=True, ssr_mode=False, show_error=True)
|
| 1521 |
|
image_utils.py
CHANGED
|
@@ -136,16 +136,25 @@ def on_base_image_change(img) -> str:
|
|
| 136 |
|
| 137 |
|
| 138 |
MAX_REFERENCE_IMAGES = 3
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
|
| 140 |
|
| 141 |
def collect_reference_images(ref1=None, ref2=None, ref3=None) -> list:
|
| 142 |
-
"""Ordered non-empty reference slots (
|
| 143 |
-
|
| 144 |
-
for item in (ref1, ref2, ref3):
|
| 145 |
-
if item is None:
|
| 146 |
-
break
|
| 147 |
-
refs.append(item)
|
| 148 |
-
return refs
|
| 149 |
|
| 150 |
|
| 151 |
def reference_info_text(ref1=None, ref2=None, ref3=None) -> str:
|
|
@@ -155,7 +164,46 @@ def reference_info_text(ref1=None, ref2=None, ref3=None) -> str:
|
|
| 155 |
return f"π· {count} reference image{'s' if count != 1 else ''} (max {MAX_REFERENCE_IMAGES})"
|
| 156 |
|
| 157 |
|
| 158 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 159 |
def on_reference_change(images) -> str:
|
| 160 |
if not images:
|
| 161 |
return "π· No reference images"
|
|
@@ -169,41 +217,84 @@ def on_reference_change(images) -> str:
|
|
| 169 |
|
| 170 |
|
| 171 |
def on_ref1_change(ref1, ref2, ref3):
|
| 172 |
-
|
| 173 |
-
r2 = ref2 if ref1 is not None else None
|
| 174 |
-
r3 = ref3 if (ref1 is not None and r2 is not None) else None
|
| 175 |
-
return (
|
| 176 |
-
gr.update(value=r2, visible=(ref1 is not None)),
|
| 177 |
-
gr.update(value=r3, visible=(ref1 is not None and r2 is not None)),
|
| 178 |
-
reference_info_text(ref1, r2, r3),
|
| 179 |
-
)
|
| 180 |
|
| 181 |
|
| 182 |
def on_ref2_change(ref1, ref2, ref3):
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 191 |
return (
|
| 192 |
-
|
| 193 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 194 |
)
|
| 195 |
|
| 196 |
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 200 |
|
| 201 |
|
| 202 |
def _place_in_ref_slots(img, ref1, ref2, ref3):
|
| 203 |
"""Put `img` into the first empty reference slot (or replace ref3 if full).
|
| 204 |
|
| 205 |
-
Returns updates for (ref1, ref2, ref3, reference_info).
|
| 206 |
-
get gr.update() so we don't re-fire their change handlers unnecessarily.
|
| 207 |
"""
|
| 208 |
if img is None:
|
| 209 |
raise gr.Error("Nothing to send.")
|
|
@@ -214,37 +305,19 @@ def _place_in_ref_slots(img, ref1, ref2, ref3):
|
|
| 214 |
raise gr.Error(f"Could not open image: {e}")
|
| 215 |
img = fix_orientation(img).convert("RGB")
|
| 216 |
|
| 217 |
-
|
|
|
|
|
|
|
| 218 |
gr.Info("Sent to Reference 1")
|
| 219 |
-
return (
|
| 220 |
-
|
| 221 |
-
gr.update(value=None, visible=True),
|
| 222 |
-
gr.update(value=None, visible=False),
|
| 223 |
-
reference_info_text(img, None, None),
|
| 224 |
-
)
|
| 225 |
-
if ref2 is None:
|
| 226 |
gr.Info("Sent to Reference 2")
|
| 227 |
-
return (
|
| 228 |
-
|
| 229 |
-
gr.update(value=img, visible=True),
|
| 230 |
-
gr.update(value=None, visible=True),
|
| 231 |
-
reference_info_text(ref1, img, None),
|
| 232 |
-
)
|
| 233 |
-
if ref3 is None:
|
| 234 |
gr.Info("Sent to Reference 3")
|
| 235 |
-
return (
|
| 236 |
-
gr.update(),
|
| 237 |
-
gr.update(),
|
| 238 |
-
gr.update(value=img, visible=True),
|
| 239 |
-
reference_info_text(ref1, ref2, img),
|
| 240 |
-
)
|
| 241 |
gr.Warning("All 3 reference slots full β replaced Reference 3.")
|
| 242 |
-
return (
|
| 243 |
-
gr.update(),
|
| 244 |
-
gr.update(),
|
| 245 |
-
gr.update(value=img, visible=True),
|
| 246 |
-
reference_info_text(ref1, ref2, img),
|
| 247 |
-
)
|
| 248 |
|
| 249 |
|
| 250 |
# ββ Upload round-trip (fixes HEIC preview in main tab) ββββββββββββββββββββββ
|
|
|
|
| 136 |
|
| 137 |
|
| 138 |
MAX_REFERENCE_IMAGES = 3
|
| 139 |
+
# base + 3 refs β used by reorder helpers
|
| 140 |
+
MAX_IMAGE_SLOTS = 1 + MAX_REFERENCE_IMAGES
|
| 141 |
+
|
| 142 |
+
|
| 143 |
+
def _is_empty_image(img) -> bool:
|
| 144 |
+
return img is None
|
| 145 |
+
|
| 146 |
+
|
| 147 |
+
def _compact_refs(*refs) -> list:
|
| 148 |
+
"""Drop empty ref slots and pack remaining images upward."""
|
| 149 |
+
packed = [r for r in refs if not _is_empty_image(r)]
|
| 150 |
+
while len(packed) < MAX_REFERENCE_IMAGES:
|
| 151 |
+
packed.append(None)
|
| 152 |
+
return packed[:MAX_REFERENCE_IMAGES]
|
| 153 |
|
| 154 |
|
| 155 |
def collect_reference_images(ref1=None, ref2=None, ref3=None) -> list:
|
| 156 |
+
"""Ordered non-empty reference slots (gaps are compacted away)."""
|
| 157 |
+
return [r for r in _compact_refs(ref1, ref2, ref3) if r is not None]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 158 |
|
| 159 |
|
| 160 |
def reference_info_text(ref1=None, ref2=None, ref3=None) -> str:
|
|
|
|
| 164 |
return f"π· {count} reference image{'s' if count != 1 else ''} (max {MAX_REFERENCE_IMAGES})"
|
| 165 |
|
| 166 |
|
| 167 |
+
def _img_slot_update(new, old, *, visible=None):
|
| 168 |
+
"""Update a slot only when value identity or visibility actually changes.
|
| 169 |
+
|
| 170 |
+
Avoids re-writing the same image object into the component that fired
|
| 171 |
+
`.change`, which would loop forever.
|
| 172 |
+
"""
|
| 173 |
+
kw = {}
|
| 174 |
+
if new is not old:
|
| 175 |
+
kw["value"] = new
|
| 176 |
+
if visible is not None:
|
| 177 |
+
kw["visible"] = visible
|
| 178 |
+
return gr.update(**kw) if kw else gr.update()
|
| 179 |
+
|
| 180 |
+
|
| 181 |
+
def _ref_slot_updates(r1, r2, r3, *, old1=None, old2=None, old3=None):
|
| 182 |
+
"""Values + progressive visibility for the three ref boxes."""
|
| 183 |
+
show2 = r1 is not None
|
| 184 |
+
show3 = r1 is not None and r2 is not None
|
| 185 |
+
return (
|
| 186 |
+
_img_slot_update(r1, old1),
|
| 187 |
+
_img_slot_update(r2, old2, visible=show2),
|
| 188 |
+
_img_slot_update(r3, old3, visible=show3),
|
| 189 |
+
reference_info_text(r1, r2, r3),
|
| 190 |
+
gr.update(visible=show2), # ref2 up
|
| 191 |
+
gr.update(visible=show2), # ref2 down
|
| 192 |
+
gr.update(visible=show3), # ref3 up
|
| 193 |
+
)
|
| 194 |
+
|
| 195 |
+
|
| 196 |
+
def compact_reference_slots(ref1, ref2, ref3):
|
| 197 |
+
"""On any ref change: pack non-empty images into ref1..refN.
|
| 198 |
+
|
| 199 |
+
Deleting Reference 1 with 2/3 filled shifts them up instead of wiping all.
|
| 200 |
+
Returns (ref1, ref2, ref3, info, ref2_up_vis, ref2_down_vis, ref3_up_vis).
|
| 201 |
+
"""
|
| 202 |
+
r1, r2, r3 = _compact_refs(ref1, ref2, ref3)
|
| 203 |
+
return _ref_slot_updates(r1, r2, r3, old1=ref1, old2=ref2, old3=ref3)
|
| 204 |
+
|
| 205 |
+
|
| 206 |
+
# Back-compat names used by older call sites / imports
|
| 207 |
def on_reference_change(images) -> str:
|
| 208 |
if not images:
|
| 209 |
return "π· No reference images"
|
|
|
|
| 217 |
|
| 218 |
|
| 219 |
def on_ref1_change(ref1, ref2, ref3):
|
| 220 |
+
return compact_reference_slots(ref1, ref2, ref3)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 221 |
|
| 222 |
|
| 223 |
def on_ref2_change(ref1, ref2, ref3):
|
| 224 |
+
return compact_reference_slots(ref1, ref2, ref3)
|
| 225 |
+
|
| 226 |
+
|
| 227 |
+
def sync_reference_slots(ref1, ref2, ref3):
|
| 228 |
+
return compact_reference_slots(ref1, ref2, ref3)
|
| 229 |
+
|
| 230 |
+
|
| 231 |
+
def _slot_tuple(base, ref1, ref2, ref3):
|
| 232 |
+
return [base, ref1, ref2, ref3]
|
| 233 |
+
|
| 234 |
+
|
| 235 |
+
def _apply_slots(slots, *, old_slots=None):
|
| 236 |
+
"""Return base/ref updates + ref button visibility from a 4-slot list."""
|
| 237 |
+
old = list(old_slots) if old_slots is not None else [None, None, None, None]
|
| 238 |
+
base, r1, r2, r3 = slots[0], slots[1], slots[2], slots[3]
|
| 239 |
+
# Compact only the ref portion so base can be empty while refs remain.
|
| 240 |
+
r1, r2, r3 = _compact_refs(r1, r2, r3)
|
| 241 |
+
show2 = r1 is not None
|
| 242 |
+
show3 = r1 is not None and r2 is not None
|
| 243 |
return (
|
| 244 |
+
_img_slot_update(base, old[0]),
|
| 245 |
+
_img_slot_update(r1, old[1]),
|
| 246 |
+
_img_slot_update(r2, old[2], visible=show2),
|
| 247 |
+
_img_slot_update(r3, old[3], visible=show3),
|
| 248 |
+
reference_info_text(r1, r2, r3),
|
| 249 |
+
gr.update(visible=show2),
|
| 250 |
+
gr.update(visible=show2),
|
| 251 |
+
gr.update(visible=show3),
|
| 252 |
)
|
| 253 |
|
| 254 |
|
| 255 |
+
def move_image_slot(base, ref1, ref2, ref3, index: int, direction: int):
|
| 256 |
+
"""Swap base/ref slot `index` with neighbour (`direction` = -1 up / +1 down).
|
| 257 |
+
|
| 258 |
+
Slot indices: 0=base, 1=ref1, 2=ref2, 3=ref3.
|
| 259 |
+
Empty refs stay compacted after the move.
|
| 260 |
+
"""
|
| 261 |
+
old = _slot_tuple(base, ref1, ref2, ref3)
|
| 262 |
+
slots = list(old)
|
| 263 |
+
j = int(index) + int(direction)
|
| 264 |
+
if index < 0 or index >= len(slots) or j < 0 or j >= len(slots):
|
| 265 |
+
return _apply_slots(slots, old_slots=old)
|
| 266 |
+
slots[index], slots[j] = slots[j], slots[index]
|
| 267 |
+
return _apply_slots(slots, old_slots=old)
|
| 268 |
+
|
| 269 |
+
|
| 270 |
+
def move_base_down(base, ref1, ref2, ref3):
|
| 271 |
+
return move_image_slot(base, ref1, ref2, ref3, 0, +1)
|
| 272 |
+
|
| 273 |
+
|
| 274 |
+
def move_ref1_up(base, ref1, ref2, ref3):
|
| 275 |
+
return move_image_slot(base, ref1, ref2, ref3, 1, -1)
|
| 276 |
+
|
| 277 |
+
|
| 278 |
+
def move_ref1_down(base, ref1, ref2, ref3):
|
| 279 |
+
return move_image_slot(base, ref1, ref2, ref3, 1, +1)
|
| 280 |
+
|
| 281 |
+
|
| 282 |
+
def move_ref2_up(base, ref1, ref2, ref3):
|
| 283 |
+
return move_image_slot(base, ref1, ref2, ref3, 2, -1)
|
| 284 |
+
|
| 285 |
+
|
| 286 |
+
def move_ref2_down(base, ref1, ref2, ref3):
|
| 287 |
+
return move_image_slot(base, ref1, ref2, ref3, 2, +1)
|
| 288 |
+
|
| 289 |
+
|
| 290 |
+
def move_ref3_up(base, ref1, ref2, ref3):
|
| 291 |
+
return move_image_slot(base, ref1, ref2, ref3, 3, -1)
|
| 292 |
|
| 293 |
|
| 294 |
def _place_in_ref_slots(img, ref1, ref2, ref3):
|
| 295 |
"""Put `img` into the first empty reference slot (or replace ref3 if full).
|
| 296 |
|
| 297 |
+
Returns updates for (ref1, ref2, ref3, reference_info).
|
|
|
|
| 298 |
"""
|
| 299 |
if img is None:
|
| 300 |
raise gr.Error("Nothing to send.")
|
|
|
|
| 305 |
raise gr.Error(f"Could not open image: {e}")
|
| 306 |
img = fix_orientation(img).convert("RGB")
|
| 307 |
|
| 308 |
+
r1, r2, r3 = _compact_refs(ref1, ref2, ref3)
|
| 309 |
+
# Full update includes reorder-button visibility (ref2ββ, ref3β).
|
| 310 |
+
if r1 is None:
|
| 311 |
gr.Info("Sent to Reference 1")
|
| 312 |
+
return _ref_slot_updates(img, None, None, old1=ref1, old2=ref2, old3=ref3)
|
| 313 |
+
if r2 is None:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 314 |
gr.Info("Sent to Reference 2")
|
| 315 |
+
return _ref_slot_updates(r1, img, None, old1=ref1, old2=ref2, old3=ref3)
|
| 316 |
+
if r3 is None:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 317 |
gr.Info("Sent to Reference 3")
|
| 318 |
+
return _ref_slot_updates(r1, r2, img, old1=ref1, old2=ref2, old3=ref3)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 319 |
gr.Warning("All 3 reference slots full β replaced Reference 3.")
|
| 320 |
+
return _ref_slot_updates(r1, r2, img, old1=ref1, old2=ref2, old3=ref3)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 321 |
|
| 322 |
|
| 323 |
# ββ Upload round-trip (fixes HEIC preview in main tab) ββββββββββββββββββββββ
|
lora_registry.py
CHANGED
|
@@ -802,10 +802,13 @@ def update_weight_sliders(
|
|
| 802 |
combined, p_memory = _build_lora_prompt(
|
| 803 |
new_selected, p_memory, dynamic_loras, prev_titles=prev,
|
| 804 |
)
|
| 805 |
-
|
| 806 |
-
|
| 807 |
-
|
| 808 |
-
|
|
|
|
|
|
|
|
|
|
| 809 |
|
| 810 |
details = format_selected_lora_details(new_selected, dynamic_loras)
|
| 811 |
if not details:
|
|
|
|
| 802 |
combined, p_memory = _build_lora_prompt(
|
| 803 |
new_selected, p_memory, dynamic_loras, prev_titles=prev,
|
| 804 |
)
|
| 805 |
+
# Keep the box always visible so selection races can't hide it while the
|
| 806 |
+
# prompt is still applied at generate time. Empty when nothing selected.
|
| 807 |
+
lora_prompt_update = gr.update(
|
| 808 |
+
value=combined or "",
|
| 809 |
+
visible=True,
|
| 810 |
+
interactive=True,
|
| 811 |
+
)
|
| 812 |
|
| 813 |
details = format_selected_lora_details(new_selected, dynamic_loras)
|
| 814 |
if not details:
|