Spaces:
Sleeping
Sleeping
Restore the previous WAN sources
Browse files- README.md +1 -7
- app.py +16 -70
- economy_prompt.py +1 -1
- tests/test_economy_prompt.py +3 -18
README.md
CHANGED
|
@@ -37,12 +37,6 @@ sound descriptions; those AI tasks require Qwen3.8. There is no automatic retry
|
|
| 37 |
|
| 38 |
**🆕 AI Scene Planner · 🔒 Improved Identity Lock · 🔊 3 audio models · 🎞️ Up to 64 clips**
|
| 39 |
|
| 40 |
-
## Simple video controls
|
| 41 |
-
|
| 42 |
-
Choose **16 FPS · Economy** or **32 FPS · Smoother** beside the duration. The ZeroGPU requirement updates with the source, duration and smoothness. Higher FPS uses frame interpolation.
|
| 43 |
-
|
| 44 |
-
**Prepare prompt & LoRAs · Free CPU** adds a concise caption from the reference and runs the existing CPU LoRA picker against your original request. The resulting prompt is editable. The Qwen3.8 writer remains available for detailed rewriting.
|
| 45 |
-
|
| 46 |
## 🆕 LoRA preparation before GPU — size checks and complete downloads
|
| 47 |
|
| 48 |
All selected LoRA files, including built-in presets, Hugging Face files and CivitAI/direct
|
|
@@ -190,7 +184,7 @@ frame of the generated video.**
|
|
| 190 |
| Model | Purpose |
|
| 191 |
| --- | --- |
|
| 192 |
| **MMAudio NSFW — new default** | Specialized 44 kHz checkpoint |
|
| 193 |
-
| **MMAudio
|
| 194 |
| **HunyuanVideo-Foley** | Alternative Foley model with heavier processing |
|
| 195 |
|
| 196 |
Wan generates the video first; audio is a separate pass. Add sound to an existing clip or enable
|
|
|
|
| 37 |
|
| 38 |
**🆕 AI Scene Planner · 🔒 Improved Identity Lock · 🔊 3 audio models · 🎞️ Up to 64 clips**
|
| 39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
## 🆕 LoRA preparation before GPU — size checks and complete downloads
|
| 41 |
|
| 42 |
All selected LoRA files, including built-in presets, Hugging Face files and CivitAI/direct
|
|
|
|
| 184 |
| Model | Purpose |
|
| 185 |
| --- | --- |
|
| 186 |
| **MMAudio NSFW — new default** | Specialized 44 kHz checkpoint |
|
| 187 |
+
| **MMAudio** | Standard, lighter sound generation option |
|
| 188 |
| **HunyuanVideo-Foley** | Alternative Foley model with heavier processing |
|
| 189 |
|
| 190 |
Wan generates the video first; audio is a separate pass. Add sound to an existing clip or enable
|
app.py
CHANGED
|
@@ -3439,7 +3439,7 @@ FOLEY_ENGINES = {
|
|
| 3439 |
"HunyuanVideo-Foley — better sound, much slower": "hunyuan",
|
| 3440 |
"MMAudio NSFW — specialized 44 kHz": "mmaudio_nsfw",
|
| 3441 |
}
|
| 3442 |
-
FOLEY_DEFAULT =
|
| 3443 |
|
| 3444 |
FOLEY_INSTALL_HINT = (
|
| 3445 |
"The sound model could not be installed. Check the Space logs, or add these lines to "
|
|
@@ -7047,7 +7047,7 @@ HERO = """
|
|
| 7047 |
</div>
|
| 7048 |
<h1 id="hero-title">Wan 2.2 <span>Studio</span></h1>
|
| 7049 |
<p class="studio-lede">Bring a photo to life. Shape the motion, extend the scene and give it sound.</p>
|
| 7050 |
-
<div class="studio-highlights"><article class="studio-card"><div class="studio-card-top"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="5" y="10" width="14" height="11" rx="3"/><path d="M8 10V7a4 4 0 0 1 8 0v3M12 14v3"/></svg><span class="studio-badge">Improved</span></div><h2>Identity Lock</h2><p>Gentle start-frame correction with eye and mouth protection. Helps limit face drift between clips.</p></article><article class="studio-card"><div class="studio-card-top"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 10v4M7 6v12M12 3v18M17 6v12M21 10v4"/></svg><span class="studio-badge">3 models</span></div><h2>Audio Studio</h2><p>MMAudio, HunyuanVideo-Foley and the new MMAudio NSFW.
|
| 7051 |
<details class="studio-toolbox">
|
| 7052 |
<summary>Explore all tools <span>LoRA · Prompt Assist · Frame Control · Loops · JSON Profiles</span></summary>
|
| 7053 |
<div class="studio-tools"><div class="studio-tool"><h3>🎛️ LoRA & CivitAI</h3><p>Mix up to 3 built-in effects and use 5 custom slots. Search, import links and tune strengths.</p></div><div class="studio-tool"><h3>✨ Prompt Assist</h3><p>NEW: prepare prompts or split scenes, then refresh LoRA suggestions in groups of 5. Unavailable links are skipped.</p></div><div class="studio-tool"><h3>🏁 Frame Control</h3><p>Set a start and optional end image. Reuse a frame from the result to shape the next shot.</p></div><div class="studio-tool"><h3>⚡ Speed & Smoothness</h3><p>Choose speed presets and RIFE frame interpolation for smoother playback. See the GPU estimate before running.</p></div><div class="studio-tool"><h3>🔁 Loops & Joining</h3><p>Build a boomerang or join clips on the CPU, using no additional ZeroGPU time for these operations.</p></div><div class="studio-tool"><h3>💾 JSON Profiles</h3><p>Save a named setup or export JSON with your scene idea, clip prompts, individual timings, clip count and audio settings.</p></div></div>
|
|
@@ -8458,16 +8458,11 @@ with gr.Blocks(title="Wan 2.2 Studio | NEW AI Scene Planner · 64 Clips · 3 Aud
|
|
| 8458 |
label="Video length (seconds)",
|
| 8459 |
render=False)
|
| 8460 |
frame_multi = gr.Dropdown(
|
| 8461 |
-
choices=[
|
| 8462 |
-
("16 FPS · Economy", FIXED_FPS),
|
| 8463 |
-
("32 FPS · Smoother", FIXED_FPS * 2),
|
| 8464 |
-
("64 FPS · High interpolation", FIXED_FPS * 4),
|
| 8465 |
-
("128 FPS · Highest interpolation", FIXED_FPS * 8),
|
| 8466 |
-
],
|
| 8467 |
value=FIXED_FPS,
|
| 8468 |
-
label="
|
| 8469 |
-
info="Higher
|
| 8470 |
-
|
| 8471 |
)
|
| 8472 |
with gr.Row():
|
| 8473 |
aspect_mode = gr.Radio(
|
|
@@ -8964,7 +8959,7 @@ with gr.Blocks(title="Wan 2.2 Studio | NEW AI Scene Planner · 64 Clips · 3 Aud
|
|
| 8964 |
sound_engine = gr.Dropdown(
|
| 8965 |
choices=list(FOLEY_ENGINES.keys()), value=FOLEY_DEFAULT,
|
| 8966 |
label="🎧 Audio model · 3 choices",
|
| 8967 |
-
info="
|
| 8968 |
"HunyuanVideo-Foley are also available. The selected model "
|
| 8969 |
"downloads on first use; your choice is saved in JSON profiles. Hunyuan supports up to 15 seconds; choose MMAudio for longer videos.",
|
| 8970 |
)
|
|
@@ -9140,13 +9135,9 @@ with gr.Blocks(title="Wan 2.2 Studio | NEW AI Scene Planner · 64 Clips · 3 Aud
|
|
| 9140 |
with gr.Group(elem_classes="prompt-improvement", elem_id="studio-prompt-improvement"):
|
| 9141 |
gr.Markdown("### Prompt Improvement")
|
| 9142 |
gr.Markdown("Refine your idea with one click, then review the prompt.")
|
| 9143 |
-
|
| 9144 |
-
cpu_prepare = gr.Button("Prepare prompt & LoRAs · Free CPU", variant="secondary")
|
| 9145 |
-
basic_btn.render()
|
| 9146 |
simple_prompt_status = gr.Markdown("")
|
| 9147 |
-
|
| 9148 |
-
duration_seconds_input.render()
|
| 9149 |
-
frame_multi.render()
|
| 9150 |
cpu_lora = gr.Button("Pick LoRAs from prompt (Free · CPU)", size="sm", variant="secondary")
|
| 9151 |
cpu_lora_status = gr.Markdown("Matches names and trigger words in your LoRA library.")
|
| 9152 |
if all(os.environ.get(name) for name in (
|
|
@@ -9500,7 +9491,7 @@ with gr.Blocks(title="Wan 2.2 Studio | NEW AI Scene Planner · 64 Clips · 3 Aud
|
|
| 9500 |
# The speed preset carries steps, flow shift and scheduler with it, so the recipe sets
|
| 9501 |
# the preset and lets the existing handler fill those three in - one source of truth
|
| 9502 |
# rather than two lists that drift apart.
|
| 9503 |
-
|
| 9504 |
fn=_apply_starter,
|
| 9505 |
inputs=[starter_recipe],
|
| 9506 |
outputs=[duration_seconds_input, frame_multi, quality_slider, safe_mode_checkbox,
|
|
@@ -9511,7 +9502,7 @@ with gr.Blocks(title="Wan 2.2 Studio | NEW AI Scene Planner · 64 Clips · 3 Aud
|
|
| 9511 |
outputs=[steps_slider, flow_shift_slider, scheduler_dropdown],
|
| 9512 |
)
|
| 9513 |
|
| 9514 |
-
|
| 9515 |
fn=_apply_speed_preset,
|
| 9516 |
inputs=[speed_preset_dd],
|
| 9517 |
outputs=[steps_slider, flow_shift_slider, scheduler_dropdown],
|
|
@@ -9914,10 +9905,7 @@ with gr.Blocks(title="Wan 2.2 Studio | NEW AI Scene Planner · 64 Clips · 3 Aud
|
|
| 9914 |
headline = text.split(" \n", 1)[0].split("\n", 1)[0]
|
| 9915 |
reservation = re.search(r"Hardware-adjusted quota reservation: \*\*(.*?)\*\*", text)
|
| 9916 |
if reservation:
|
| 9917 |
-
headline += " \
|
| 9918 |
-
details_line = text.splitlines()[1:2]
|
| 9919 |
-
if details_line:
|
| 9920 |
-
headline += " \n" + details_line[0].strip()
|
| 9921 |
return headline
|
| 9922 |
|
| 9923 |
gpu_estimate.value = _gpu_estimate_text(*(component.value for component in _ESTIMATE_INPUTS))
|
|
@@ -9926,19 +9914,8 @@ with gr.Blocks(title="Wan 2.2 Studio | NEW AI Scene Planner · 64 Clips · 3 Aud
|
|
| 9926 |
queue=False, show_progress="hidden", api_name=False)
|
| 9927 |
demo.load(_gpu_estimate_text, _ESTIMATE_INPUTS, gpu_estimate,
|
| 9928 |
show_progress="hidden", api_name=False)
|
| 9929 |
-
#
|
| 9930 |
-
|
| 9931 |
-
sound_auto, sound_engine, scene_seconds):
|
| 9932 |
-
control.change(_gpu_estimate_text, _ESTIMATE_INPUTS, gpu_estimate, queue=False,
|
| 9933 |
-
show_progress="hidden", trigger_mode="always_last", api_name=False)
|
| 9934 |
-
for control in (duration_seconds_input, steps_slider, guidance_scale_input,
|
| 9935 |
-
guidance_scale_2_input, flow_shift_slider, chain_count, sound_steps):
|
| 9936 |
-
control.release(_gpu_estimate_text, _ESTIMATE_INPUTS, gpu_estimate, queue=False,
|
| 9937 |
-
show_progress="hidden", trigger_mode="always_last", api_name=False)
|
| 9938 |
-
for event in (_starter_speed_applied, _speed_preset_applied,
|
| 9939 |
-
_quick_lora_event, _quick_lora_submit_event, *_manual_lora_events):
|
| 9940 |
-
event.success(_gpu_estimate_text, _ESTIMATE_INPUTS, gpu_estimate, queue=False,
|
| 9941 |
-
show_progress="hidden", api_name=False)
|
| 9942 |
pb_button.click(
|
| 9943 |
fn=enhance_prompt,
|
| 9944 |
inputs=[prompt_input, pb_use_model, pb_camera, pb_framing, pb_lighting, pb_pace, pb_quality, pb_space, input_image_component],
|
|
@@ -10229,11 +10206,9 @@ with gr.Blocks(title="Wan 2.2 Studio | NEW AI Scene Planner · 64 Clips · 3 Aud
|
|
| 10229 |
*_show_active_loras(library, trigger_updates[2], *values)]
|
| 10230 |
|
| 10231 |
def _apply_cpu_loras(prompt_text, sheet_text, idea_text, library, state, base, identity_at,
|
| 10232 |
-
*adapter_values, scene=False, refresh=False, request=None
|
| 10233 |
-
match_prompt=None):
|
| 10234 |
state = copy.deepcopy(state or {})
|
| 10235 |
-
prompt_basis = _pick_clean(prompt_text
|
| 10236 |
-
state.get("prompt_added"))
|
| 10237 |
if scene:
|
| 10238 |
scene_basis = _pick_clean(sheet_text, state.get("sheet_added"))
|
| 10239 |
prompt_basis = "\n".join(value for value in (idea_text, scene_basis) if value).strip() or prompt_basis
|
|
@@ -10324,8 +10299,6 @@ with gr.Blocks(title="Wan 2.2 Studio | NEW AI Scene Planner · 64 Clips · 3 Aud
|
|
| 10324 |
notes.append("Found related LoRAs, but none fit the available slots, file checks and size limits.")
|
| 10325 |
else:
|
| 10326 |
notes.append("No clear LoRA match in the library for this prompt.")
|
| 10327 |
-
if match_prompt is not None:
|
| 10328 |
-
return [" ".join(notes), *_cpu_lora_result(prompt_text, sheet_text, library, state, values, updates)]
|
| 10329 |
trigger_updates = [gr.update() for _ in _TRIGGER_OUTPUTS]
|
| 10330 |
trigger_updates[2] = state
|
| 10331 |
return [" ".join(notes), gr.update(), *updates[3:], *trigger_updates,
|
|
@@ -10370,33 +10343,6 @@ with gr.Blocks(title="Wan 2.2 Studio | NEW AI Scene Planner · 64 Clips · 3 Aud
|
|
| 10370 |
|
| 10371 |
return run
|
| 10372 |
|
| 10373 |
-
def _prepare_prompt_and_loras_cpu(prompt_text, image, sheet_text, idea_text, library,
|
| 10374 |
-
state, base, identity_at, request: gr.Request, *adapter_values):
|
| 10375 |
-
state = copy.deepcopy(state or {})
|
| 10376 |
-
original = _pick_clean(prompt_text, state.get("prompt_added"))
|
| 10377 |
-
previous = state.get("cpu_caption_prompt") or {}
|
| 10378 |
-
if original == previous.get("written"):
|
| 10379 |
-
original = previous["original"]
|
| 10380 |
-
written, _ = _economy_wan_prompt(original, image)
|
| 10381 |
-
state["cpu_caption_prompt"] = dict(original=original, written=written)
|
| 10382 |
-
picked = _apply_cpu_loras(written, sheet_text, idea_text, library, state, base, identity_at,
|
| 10383 |
-
*adapter_values, request=request, match_prompt=original)
|
| 10384 |
-
summary = ("Reference described on CPU. Review the prompt above." if image is not None
|
| 10385 |
-
else "Original prompt kept. No caption model call was needed.")
|
| 10386 |
-
return [summary, *picked]
|
| 10387 |
-
|
| 10388 |
-
_cpu_prepared = cpu_prepare.click(
|
| 10389 |
-
_prepare_prompt_and_loras_cpu,
|
| 10390 |
-
[prompt_input, input_image_component, scene_prompts, scene_idea, lora_catalog_state,
|
| 10391 |
-
basic_shortlist, simple_lora_strength, identity_strength_slider, *_ACTIVE_LORA_FIELDS],
|
| 10392 |
-
[simple_prompt_status, cpu_lora_status, simple_lora, *_CPU_LORA_FIELDS,
|
| 10393 |
-
*_TRIGGER_OUTPUTS, *_ACTIVE_LORA_OUTPUTS],
|
| 10394 |
-
show_progress="minimal", concurrency_id="lora-picker", concurrency_limit=1,
|
| 10395 |
-
api_name="prepare_prompt_and_loras_cpu",
|
| 10396 |
-
)
|
| 10397 |
-
_cpu_prepared.success(_gpu_estimate_text, _ESTIMATE_INPUTS, gpu_estimate,
|
| 10398 |
-
queue=False, show_progress="hidden", api_name=False)
|
| 10399 |
-
|
| 10400 |
for _button, _refresh, _prompt, _status, _scene, _main in (
|
| 10401 |
(cpu_lora, cpu_refresh, prompt_input, cpu_lora_status, False, True),
|
| 10402 |
(extension_cpu_lora, extension_cpu_refresh, extension_prompt, extension_cpu_status, False, False),
|
|
|
|
| 3439 |
"HunyuanVideo-Foley — better sound, much slower": "hunyuan",
|
| 3440 |
"MMAudio NSFW — specialized 44 kHz": "mmaudio_nsfw",
|
| 3441 |
}
|
| 3442 |
+
FOLEY_DEFAULT = "MMAudio NSFW — specialized 44 kHz"
|
| 3443 |
|
| 3444 |
FOLEY_INSTALL_HINT = (
|
| 3445 |
"The sound model could not be installed. Check the Space logs, or add these lines to "
|
|
|
|
| 7047 |
</div>
|
| 7048 |
<h1 id="hero-title">Wan 2.2 <span>Studio</span></h1>
|
| 7049 |
<p class="studio-lede">Bring a photo to life. Shape the motion, extend the scene and give it sound.</p>
|
| 7050 |
+
<div class="studio-highlights"><article class="studio-card"><div class="studio-card-top"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="5" y="10" width="14" height="11" rx="3"/><path d="M8 10V7a4 4 0 0 1 8 0v3M12 14v3"/></svg><span class="studio-badge">Improved</span></div><h2>Identity Lock</h2><p>Gentle start-frame correction with eye and mouth protection. Helps limit face drift between clips.</p></article><article class="studio-card"><div class="studio-card-top"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 10v4M7 6v12M12 3v18M17 6v12M21 10v4"/></svg><span class="studio-badge">3 models</span></div><h2>Audio Studio</h2><p>MMAudio, HunyuanVideo-Foley and the new MMAudio NSFW. The new model is selected by default; sound is optional.</p></article><article class="studio-card"><div class="studio-card-top"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="3" width="18" height="18" rx="3"/><path d="M7 3v18M17 3v18M3 8h4M3 16h4M17 8h4M17 16h4"/></svg><span class="studio-badge">NEW · Simple</span></div><h2>AI Scene Planner</h2><p>One idea → a plan with one action per clip. Automatically choose clip count and timing, then generate and join up to 64 clips.</p></article></div>
|
| 7051 |
<details class="studio-toolbox">
|
| 7052 |
<summary>Explore all tools <span>LoRA · Prompt Assist · Frame Control · Loops · JSON Profiles</span></summary>
|
| 7053 |
<div class="studio-tools"><div class="studio-tool"><h3>🎛️ LoRA & CivitAI</h3><p>Mix up to 3 built-in effects and use 5 custom slots. Search, import links and tune strengths.</p></div><div class="studio-tool"><h3>✨ Prompt Assist</h3><p>NEW: prepare prompts or split scenes, then refresh LoRA suggestions in groups of 5. Unavailable links are skipped.</p></div><div class="studio-tool"><h3>🏁 Frame Control</h3><p>Set a start and optional end image. Reuse a frame from the result to shape the next shot.</p></div><div class="studio-tool"><h3>⚡ Speed & Smoothness</h3><p>Choose speed presets and RIFE frame interpolation for smoother playback. See the GPU estimate before running.</p></div><div class="studio-tool"><h3>🔁 Loops & Joining</h3><p>Build a boomerang or join clips on the CPU, using no additional ZeroGPU time for these operations.</p></div><div class="studio-tool"><h3>💾 JSON Profiles</h3><p>Save a named setup or export JSON with your scene idea, clip prompts, individual timings, clip count and audio settings.</p></div></div>
|
|
|
|
| 8458 |
label="Video length (seconds)",
|
| 8459 |
render=False)
|
| 8460 |
frame_multi = gr.Dropdown(
|
| 8461 |
+
choices=[FIXED_FPS, FIXED_FPS*2, FIXED_FPS*4, FIXED_FPS*8],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8462 |
value=FIXED_FPS,
|
| 8463 |
+
label="🎞️ Smoothness (frames per second)",
|
| 8464 |
+
info="Higher invents extra frames in between, so motion looks smoother. "
|
| 8465 |
+
"16 is the normal setting; try 32 if the movement looks jerky.",
|
| 8466 |
)
|
| 8467 |
with gr.Row():
|
| 8468 |
aspect_mode = gr.Radio(
|
|
|
|
| 8959 |
sound_engine = gr.Dropdown(
|
| 8960 |
choices=list(FOLEY_ENGINES.keys()), value=FOLEY_DEFAULT,
|
| 8961 |
label="🎧 Audio model · 3 choices",
|
| 8962 |
+
info="New default: MMAudio NSFW (44 kHz). Standard MMAudio and "
|
| 8963 |
"HunyuanVideo-Foley are also available. The selected model "
|
| 8964 |
"downloads on first use; your choice is saved in JSON profiles. Hunyuan supports up to 15 seconds; choose MMAudio for longer videos.",
|
| 8965 |
)
|
|
|
|
| 9135 |
with gr.Group(elem_classes="prompt-improvement", elem_id="studio-prompt-improvement"):
|
| 9136 |
gr.Markdown("### Prompt Improvement")
|
| 9137 |
gr.Markdown("Refine your idea with one click, then review the prompt.")
|
| 9138 |
+
basic_btn.render()
|
|
|
|
|
|
|
| 9139 |
simple_prompt_status = gr.Markdown("")
|
| 9140 |
+
duration_seconds_input.render()
|
|
|
|
|
|
|
| 9141 |
cpu_lora = gr.Button("Pick LoRAs from prompt (Free · CPU)", size="sm", variant="secondary")
|
| 9142 |
cpu_lora_status = gr.Markdown("Matches names and trigger words in your LoRA library.")
|
| 9143 |
if all(os.environ.get(name) for name in (
|
|
|
|
| 9491 |
# The speed preset carries steps, flow shift and scheduler with it, so the recipe sets
|
| 9492 |
# the preset and lets the existing handler fill those three in - one source of truth
|
| 9493 |
# rather than two lists that drift apart.
|
| 9494 |
+
starter_recipe.change(
|
| 9495 |
fn=_apply_starter,
|
| 9496 |
inputs=[starter_recipe],
|
| 9497 |
outputs=[duration_seconds_input, frame_multi, quality_slider, safe_mode_checkbox,
|
|
|
|
| 9502 |
outputs=[steps_slider, flow_shift_slider, scheduler_dropdown],
|
| 9503 |
)
|
| 9504 |
|
| 9505 |
+
speed_preset_dd.change(
|
| 9506 |
fn=_apply_speed_preset,
|
| 9507 |
inputs=[speed_preset_dd],
|
| 9508 |
outputs=[steps_slider, flow_shift_slider, scheduler_dropdown],
|
|
|
|
| 9905 |
headline = text.split(" \n", 1)[0].split("\n", 1)[0]
|
| 9906 |
reservation = re.search(r"Hardware-adjusted quota reservation: \*\*(.*?)\*\*", text)
|
| 9907 |
if reservation:
|
| 9908 |
+
headline += " \nAllowance reserved: **" + reservation.group(1) + "**."
|
|
|
|
|
|
|
|
|
|
| 9909 |
return headline
|
| 9910 |
|
| 9911 |
gpu_estimate.value = _gpu_estimate_text(*(component.value for component in _ESTIMATE_INPUTS))
|
|
|
|
| 9914 |
queue=False, show_progress="hidden", api_name=False)
|
| 9915 |
demo.load(_gpu_estimate_text, _ESTIMATE_INPUTS, gpu_estimate,
|
| 9916 |
show_progress="hidden", api_name=False)
|
| 9917 |
+
# Further recalculation is on demand and after preparation/Safe Mode changes;
|
| 9918 |
+
# no background polling or event for every slider movement.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9919 |
pb_button.click(
|
| 9920 |
fn=enhance_prompt,
|
| 9921 |
inputs=[prompt_input, pb_use_model, pb_camera, pb_framing, pb_lighting, pb_pace, pb_quality, pb_space, input_image_component],
|
|
|
|
| 10206 |
*_show_active_loras(library, trigger_updates[2], *values)]
|
| 10207 |
|
| 10208 |
def _apply_cpu_loras(prompt_text, sheet_text, idea_text, library, state, base, identity_at,
|
| 10209 |
+
*adapter_values, scene=False, refresh=False, request=None):
|
|
|
|
| 10210 |
state = copy.deepcopy(state or {})
|
| 10211 |
+
prompt_basis = _pick_clean(prompt_text, state.get("prompt_added"))
|
|
|
|
| 10212 |
if scene:
|
| 10213 |
scene_basis = _pick_clean(sheet_text, state.get("sheet_added"))
|
| 10214 |
prompt_basis = "\n".join(value for value in (idea_text, scene_basis) if value).strip() or prompt_basis
|
|
|
|
| 10299 |
notes.append("Found related LoRAs, but none fit the available slots, file checks and size limits.")
|
| 10300 |
else:
|
| 10301 |
notes.append("No clear LoRA match in the library for this prompt.")
|
|
|
|
|
|
|
| 10302 |
trigger_updates = [gr.update() for _ in _TRIGGER_OUTPUTS]
|
| 10303 |
trigger_updates[2] = state
|
| 10304 |
return [" ".join(notes), gr.update(), *updates[3:], *trigger_updates,
|
|
|
|
| 10343 |
|
| 10344 |
return run
|
| 10345 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10346 |
for _button, _refresh, _prompt, _status, _scene, _main in (
|
| 10347 |
(cpu_lora, cpu_refresh, prompt_input, cpu_lora_status, False, True),
|
| 10348 |
(extension_cpu_lora, extension_cpu_refresh, extension_prompt, extension_cpu_status, False, False),
|
economy_prompt.py
CHANGED
|
@@ -6,7 +6,7 @@ from __future__ import annotations
|
|
| 6 |
|
| 7 |
ECONOMY_SPACE = "amisima/Qwen3.5-Picture-Captioner"
|
| 8 |
ECONOMY_LABEL = "Super Economy - basic description"
|
| 9 |
-
ECONOMY_TOKENS =
|
| 10 |
ECONOMY_NOTE = (
|
| 11 |
"Super Economy describes reference images on CPU without using ZeroGPU quota. "
|
| 12 |
"It keeps your idea, LoRAs and strengths. With text alone it keeps your original "
|
|
|
|
| 6 |
|
| 7 |
ECONOMY_SPACE = "amisima/Qwen3.5-Picture-Captioner"
|
| 8 |
ECONOMY_LABEL = "Super Economy - basic description"
|
| 9 |
+
ECONOMY_TOKENS = 384
|
| 10 |
ECONOMY_NOTE = (
|
| 11 |
"Super Economy describes reference images on CPU without using ZeroGPU quota. "
|
| 12 |
"It keeps your idea, LoRAs and strengths. With text alone it keeps your original "
|
tests/test_economy_prompt.py
CHANGED
|
@@ -1,6 +1,5 @@
|
|
| 1 |
"""Offline routing checks: no weights, network calls, or inference are loaded."""
|
| 2 |
import ast
|
| 3 |
-
import copy
|
| 4 |
import inspect
|
| 5 |
import os
|
| 6 |
from pathlib import Path
|
|
@@ -22,7 +21,7 @@ def namespace(*names):
|
|
| 22 |
"economy_prompt", "economy_status")}
|
| 23 |
values.update(gr=types.SimpleNamespace(
|
| 24 |
update=lambda **kwargs: {"__type__": "update", **kwargs},
|
| 25 |
-
Error=ValueError,
|
| 26 |
_remote_ask=Mock(return_value="A woman in a red coat stands beside a window."))
|
| 27 |
nodes = [FUNCTIONS[name] for name in names]
|
| 28 |
exec(compile(ast.Module(nodes, type_ignores=[]), str(ROOT / "app.py"), "exec"), values)
|
|
@@ -52,7 +51,7 @@ class EconomyPromptTests(unittest.TestCase):
|
|
| 52 |
prompt, status = ns["_economy_wan_prompt"](idea, image)
|
| 53 |
ns["_remote_ask"].assert_called_once_with(
|
| 54 |
economy.ECONOMY_SPACE, economy.economy_instruction(), image,
|
| 55 |
-
temperature=0.0, max_new_tokens=
|
| 56 |
self.assertIn(idea, prompt)
|
| 57 |
self.assertIn("were kept", status)
|
| 58 |
self.assertNotIn(idea, ns["_remote_ask"].call_args.args[1])
|
|
@@ -142,23 +141,9 @@ class EconomyPromptTests(unittest.TestCase):
|
|
| 142 |
temperature=.9, max_new_tokens=4096)
|
| 143 |
client.submit.assert_called_once()
|
| 144 |
self.assertEqual(ns["_remote_plan"].call_args.kwargs,
|
| 145 |
-
{"max_new_tokens":
|
| 146 |
client.close.assert_called_once()
|
| 147 |
|
| 148 |
-
def test_combined_preparation_selects_from_original_idea_and_replaces_previous_caption(self):
|
| 149 |
-
ns = namespace("_prepare_prompt_and_loras_cpu")
|
| 150 |
-
ns.update(copy=copy, _pick_clean=lambda prompt, records: prompt,
|
| 151 |
-
_economy_wan_prompt=Mock(return_value=("A new caption. Original idea.", "")),
|
| 152 |
-
_apply_cpu_loras=Mock(return_value=["No match."]))
|
| 153 |
-
previous = {"cpu_caption_prompt": {"original": "Original idea.", "written": "Old caption. Original idea."}}
|
| 154 |
-
result = ns["_prepare_prompt_and_loras_cpu"](
|
| 155 |
-
"Old caption. Original idea.", "photo", "", "", {}, previous, 0.7, 0.45, None)
|
| 156 |
-
ns["_economy_wan_prompt"].assert_called_once_with("Original idea.", "photo")
|
| 157 |
-
self.assertEqual(ns["_apply_cpu_loras"].call_args.args[0], "A new caption. Original idea.")
|
| 158 |
-
self.assertEqual(ns["_apply_cpu_loras"].call_args.kwargs["match_prompt"], "Original idea.")
|
| 159 |
-
self.assertEqual(previous["cpu_caption_prompt"]["written"], "Old caption. Original idea.")
|
| 160 |
-
self.assertEqual(result[-1], "No match.")
|
| 161 |
-
|
| 162 |
|
| 163 |
if __name__ == "__main__":
|
| 164 |
unittest.main()
|
|
|
|
| 1 |
"""Offline routing checks: no weights, network calls, or inference are loaded."""
|
| 2 |
import ast
|
|
|
|
| 3 |
import inspect
|
| 4 |
import os
|
| 5 |
from pathlib import Path
|
|
|
|
| 21 |
"economy_prompt", "economy_status")}
|
| 22 |
values.update(gr=types.SimpleNamespace(
|
| 23 |
update=lambda **kwargs: {"__type__": "update", **kwargs},
|
| 24 |
+
Error=ValueError, Progress=lambda: (lambda *args, **kwargs: None)),
|
| 25 |
_remote_ask=Mock(return_value="A woman in a red coat stands beside a window."))
|
| 26 |
nodes = [FUNCTIONS[name] for name in names]
|
| 27 |
exec(compile(ast.Module(nodes, type_ignores=[]), str(ROOT / "app.py"), "exec"), values)
|
|
|
|
| 51 |
prompt, status = ns["_economy_wan_prompt"](idea, image)
|
| 52 |
ns["_remote_ask"].assert_called_once_with(
|
| 53 |
economy.ECONOMY_SPACE, economy.economy_instruction(), image,
|
| 54 |
+
temperature=0.0, max_new_tokens=384)
|
| 55 |
self.assertIn(idea, prompt)
|
| 56 |
self.assertIn("were kept", status)
|
| 57 |
self.assertNotIn(idea, ns["_remote_ask"].call_args.args[1])
|
|
|
|
| 141 |
temperature=.9, max_new_tokens=4096)
|
| 142 |
client.submit.assert_called_once()
|
| 143 |
self.assertEqual(ns["_remote_plan"].call_args.kwargs,
|
| 144 |
+
{"max_new_tokens": 384, "temperature": 0.0})
|
| 145 |
client.close.assert_called_once()
|
| 146 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 147 |
|
| 148 |
if __name__ == "__main__":
|
| 149 |
unittest.main()
|