Spaces:
Running on Zero
Running on Zero
Upload app.py
Browse files
app.py
CHANGED
|
@@ -2850,6 +2850,33 @@ def _retune_triggers(prompt_text, shortlist, picks):
|
|
| 2850 |
return _add_triggers(text, picks)
|
| 2851 |
|
| 2852 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2853 |
with gr.Blocks(title="MiniMax-H3 - Custom lora + CivitAI, structured prompts, GPU cost, profiles, stitching") as demo:
|
| 2854 |
gr.HTML(HERO)
|
| 2855 |
|
|
@@ -2894,6 +2921,7 @@ with gr.Blocks(title="MiniMax-H3 - Custom lora + CivitAI, structured prompts, GP
|
|
| 2894 |
info="Two at a time is the limit. Every tick refills the slots and "
|
| 2895 |
"puts the trigger words into the prompt.",
|
| 2896 |
)
|
|
|
|
| 2897 |
basic_shortlist = gr.State([])
|
| 2898 |
|
| 2899 |
with gr.Accordion("🎬 Structured prompt builder (what H3 was trained on)",
|
|
@@ -3392,7 +3420,7 @@ with gr.Blocks(title="MiniMax-H3 - Custom lora + CivitAI, structured prompts, GP
|
|
| 3392 |
return tuple(
|
| 3393 |
[gr.update(value=built), gr.update(choices=[], value=[], visible=False), [],
|
| 3394 |
f"✅ Prompt built — {note}. Nothing in the library matched these words."]
|
| 3395 |
-
+ _slot_updates([])
|
| 3396 |
)
|
| 3397 |
progress(0.8, desc="asking which loras fit")
|
| 3398 |
chosen = _ask_which_loras(space_id, built, shortlist) or [0]
|
|
@@ -3403,7 +3431,7 @@ with gr.Blocks(title="MiniMax-H3 - Custom lora + CivitAI, structured prompts, GP
|
|
| 3403 |
gr.update(choices=labels, value=[labels[i] for i in chosen], visible=True),
|
| 3404 |
shortlist,
|
| 3405 |
_basic_note(picks, f" Prompt {note}, picked out of {len(shortlist)} that matched.")]
|
| 3406 |
-
+ _slot_updates(picks)
|
| 3407 |
)
|
| 3408 |
|
| 3409 |
def _basic_swap(ticked, shortlist, prompt_text):
|
|
@@ -3414,7 +3442,7 @@ with gr.Blocks(title="MiniMax-H3 - Custom lora + CivitAI, structured prompts, GP
|
|
| 3414 |
return tuple(
|
| 3415 |
[gr.update(value=_retune_triggers(prompt_text, shortlist, picks)),
|
| 3416 |
_basic_note(picks, extra)]
|
| 3417 |
-
+ _slot_updates(picks)
|
| 3418 |
)
|
| 3419 |
|
| 3420 |
_BASIC_SLOTS = [field for pair in zip(lora_references, lora_scales) for field in pair]
|
|
@@ -3423,7 +3451,7 @@ with gr.Blocks(title="MiniMax-H3 - Custom lora + CivitAI, structured prompts, GP
|
|
| 3423 |
_basic_run,
|
| 3424 |
[prompt, basic_space, images[0], ir_shot, ir_camera, ir_sound, ir_music,
|
| 3425 |
ir_speaker, ir_dialogue, ir_references],
|
| 3426 |
-
[prompt, basic_pick, basic_shortlist, basic_status] + _BASIC_SLOTS,
|
| 3427 |
api_name=False,
|
| 3428 |
)
|
| 3429 |
|
|
@@ -3434,7 +3462,7 @@ with gr.Blocks(title="MiniMax-H3 - Custom lora + CivitAI, structured prompts, GP
|
|
| 3434 |
_tick_event(
|
| 3435 |
_basic_swap,
|
| 3436 |
[basic_pick, basic_shortlist, prompt],
|
| 3437 |
-
[prompt, basic_status] + _BASIC_SLOTS,
|
| 3438 |
api_name=False,
|
| 3439 |
)
|
| 3440 |
|
|
|
|
| 2850 |
return _add_triggers(text, picks)
|
| 2851 |
|
| 2852 |
|
| 2853 |
+
|
| 2854 |
+
|
| 2855 |
+
def _pick_links(shortlist, picks):
|
| 2856 |
+
"""A link to each candidate's own page, so a name can be read up on before it is
|
| 2857 |
+
ticked. The page is usually saved with the entry; when it is not, the download link
|
| 2858 |
+
on its own does not say which model it belongs to, so the version is resolved once
|
| 2859 |
+
through the API and remembered."""
|
| 2860 |
+
if not shortlist:
|
| 2861 |
+
return ""
|
| 2862 |
+
# Keyed on the link, falling back to the name: the built-in entries carry no link
|
| 2863 |
+
# at all, and keying those on a missing value ticks every one of them at once.
|
| 2864 |
+
chosen = {str(item.get("url") or item.get("name")) for item in (picks or [])}
|
| 2865 |
+
rows = []
|
| 2866 |
+
for index, item in enumerate(shortlist, start=1):
|
| 2867 |
+
name = str(item.get("name") or "").strip() or f"lora {index}"
|
| 2868 |
+
mark = "\u2705" if str(item.get("url") or item.get("name")) in chosen else "\u25ab\ufe0f"
|
| 2869 |
+
page = ""
|
| 2870 |
+
if not item.get("builtin"):
|
| 2871 |
+
try:
|
| 2872 |
+
page = lora_library._entry_page_url(item, resolve=True)
|
| 2873 |
+
except Exception: # noqa: BLE001
|
| 2874 |
+
page = str(item.get("page") or "").strip()
|
| 2875 |
+
rows.append(f"{mark} {index}. [{name}]({page})" if page
|
| 2876 |
+
else f"{mark} {index}. {name}")
|
| 2877 |
+
return "**\U0001f517 open a lora's own page** \n" + " \n".join(rows)
|
| 2878 |
+
|
| 2879 |
+
|
| 2880 |
with gr.Blocks(title="MiniMax-H3 - Custom lora + CivitAI, structured prompts, GPU cost, profiles, stitching") as demo:
|
| 2881 |
gr.HTML(HERO)
|
| 2882 |
|
|
|
|
| 2921 |
info="Two at a time is the limit. Every tick refills the slots and "
|
| 2922 |
"puts the trigger words into the prompt.",
|
| 2923 |
)
|
| 2924 |
+
basic_links = gr.Markdown("")
|
| 2925 |
basic_shortlist = gr.State([])
|
| 2926 |
|
| 2927 |
with gr.Accordion("🎬 Structured prompt builder (what H3 was trained on)",
|
|
|
|
| 3420 |
return tuple(
|
| 3421 |
[gr.update(value=built), gr.update(choices=[], value=[], visible=False), [],
|
| 3422 |
f"✅ Prompt built — {note}. Nothing in the library matched these words."]
|
| 3423 |
+
+ _slot_updates([]) + [gr.update(value="")]
|
| 3424 |
)
|
| 3425 |
progress(0.8, desc="asking which loras fit")
|
| 3426 |
chosen = _ask_which_loras(space_id, built, shortlist) or [0]
|
|
|
|
| 3431 |
gr.update(choices=labels, value=[labels[i] for i in chosen], visible=True),
|
| 3432 |
shortlist,
|
| 3433 |
_basic_note(picks, f" Prompt {note}, picked out of {len(shortlist)} that matched.")]
|
| 3434 |
+
+ _slot_updates(picks) + [gr.update(value=_pick_links(shortlist, picks))]
|
| 3435 |
)
|
| 3436 |
|
| 3437 |
def _basic_swap(ticked, shortlist, prompt_text):
|
|
|
|
| 3442 |
return tuple(
|
| 3443 |
[gr.update(value=_retune_triggers(prompt_text, shortlist, picks)),
|
| 3444 |
_basic_note(picks, extra)]
|
| 3445 |
+
+ _slot_updates(picks) + [gr.update(value=_pick_links(shortlist, picks))]
|
| 3446 |
)
|
| 3447 |
|
| 3448 |
_BASIC_SLOTS = [field for pair in zip(lora_references, lora_scales) for field in pair]
|
|
|
|
| 3451 |
_basic_run,
|
| 3452 |
[prompt, basic_space, images[0], ir_shot, ir_camera, ir_sound, ir_music,
|
| 3453 |
ir_speaker, ir_dialogue, ir_references],
|
| 3454 |
+
[prompt, basic_pick, basic_shortlist, basic_status] + _BASIC_SLOTS + [basic_links],
|
| 3455 |
api_name=False,
|
| 3456 |
)
|
| 3457 |
|
|
|
|
| 3462 |
_tick_event(
|
| 3463 |
_basic_swap,
|
| 3464 |
[basic_pick, basic_shortlist, prompt],
|
| 3465 |
+
[prompt, basic_status] + _BASIC_SLOTS + [basic_links],
|
| 3466 |
api_name=False,
|
| 3467 |
)
|
| 3468 |
|