amisima commited on
Commit
ab3da84
·
verified ·
1 Parent(s): 39f0389

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +83 -1
app.py CHANGED
@@ -6264,6 +6264,17 @@ with gr.Blocks(title="Wan 2.2 Studio | NEW AI Scene Planner · 64 Clips · 3 Aud
6264
  "<div class='status-idle'>Uses the selected Big model Space to plan from your "
6265
  "idea and photo. Planning uses that Space's allowance; no video is generated yet.</div>"
6266
  )
 
 
 
 
 
 
 
 
 
 
 
6267
  with gr.Row():
6268
  chain_count = gr.Slider(
6269
  1, MAX_SCENE_CLIPS, value=3, step=1, label="How many clips in a row",
@@ -7014,7 +7025,7 @@ with gr.Blocks(title="Wan 2.2 Studio | NEW AI Scene Planner · 64 Clips · 3 Aud
7014
  settings_export_btn.click(export_settings, _SETTINGS_FIELDS, settings_download)
7015
  settings_upload.upload(import_settings, settings_upload, _SETTINGS_FIELDS).success(
7016
  lambda: 1, None, chain_from)
7017
- scene_plan_btn.click(
7018
  plan_scene,
7019
  [scene_idea, prompt_input, scene_auto_count, chain_count, duration_seconds_input,
7020
  pb_space, input_image_component, scene_auto_seconds],
@@ -7148,6 +7159,77 @@ with gr.Blocks(title="Wan 2.2 Studio | NEW AI Scene Planner · 64 Clips · 3 Aud
7148
  fn=_read_effects, inputs=_LORA_READ_IN, outputs=_LORA_READ_OUT,
7149
  )
7150
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7151
  _PRO_ONLY = [pro_promptbuilder, pro_chips, pro_speed, pro_advanced,
7152
  pro_soundset, pro_loop]
7153
 
 
6264
  "<div class='status-idle'>Uses the selected Big model Space to plan from your "
6265
  "idea and photo. Planning uses that Space's allowance; no video is generated yet.</div>"
6266
  )
6267
+ scene_pick_status = gr.HTML(
6268
+ "<div class='status-idle'>Effects for the scene appear here once it is split.</div>"
6269
+ )
6270
+ scene_pick = gr.CheckboxGroup(
6271
+ choices=[], value=[], visible=False,
6272
+ label="Effects chosen for this scene — tick another one to swap",
6273
+ info="Two at a time is the limit. Every tick refills the slots and writes "
6274
+ "the trigger words into every clip prompt.",
6275
+ )
6276
+ scene_links = gr.Markdown("")
6277
+ scene_shortlist = gr.State([])
6278
  with gr.Row():
6279
  chain_count = gr.Slider(
6280
  1, MAX_SCENE_CLIPS, value=3, step=1, label="How many clips in a row",
 
7025
  settings_export_btn.click(export_settings, _SETTINGS_FIELDS, settings_download)
7026
  settings_upload.upload(import_settings, settings_upload, _SETTINGS_FIELDS).success(
7027
  lambda: 1, None, chain_from)
7028
+ _scene_plan_event = scene_plan_btn.click(
7029
  plan_scene,
7030
  [scene_idea, prompt_input, scene_auto_count, chain_count, duration_seconds_input,
7031
  pb_space, input_image_component, scene_auto_seconds],
 
7159
  fn=_read_effects, inputs=_LORA_READ_IN, outputs=_LORA_READ_OUT,
7160
  )
7161
 
7162
+ # ------------------------------------------------ effects for a planned scene
7163
+ # The planner writes one line per clip, and a lora whose trigger word is not in the
7164
+ # line it belongs to does nothing for that clip. So the same search the simple page
7165
+ # runs on a single prompt is run on the finished sheet, and the words are written
7166
+ # into every line rather than into the main prompt.
7167
+
7168
+ def _retune_sheet(sheet_text, shortlist, picks):
7169
+ lines = str(sheet_text or "").splitlines()
7170
+ if not any(line.strip() for line in lines):
7171
+ return str(sheet_text or "")
7172
+ return "\n".join(
7173
+ _retune_triggers(line, shortlist, picks) if line.strip() else line
7174
+ for line in lines
7175
+ )
7176
+
7177
+ def _scene_choose(sheet_text, idea_text, space_id, progress=gr.Progress()):
7178
+ basis = "\n".join(part for part in (str(idea_text or "").strip(),
7179
+ str(sheet_text or "").strip()) if part)
7180
+ progress(0.2, desc="searching the library")
7181
+ shortlist = _shortlist_loras(basis, _library_pool())
7182
+ if not shortlist:
7183
+ return tuple(
7184
+ [gr.update(choices=[], value=[], visible=False), [],
7185
+ "<div class='status-idle'>Nothing in the built-in list or the library "
7186
+ "matched this scene. The clip prompts are unchanged.</div>",
7187
+ gr.update(), gr.update(value=[])]
7188
+ + _slot_updates([]) + [gr.update(value="")]
7189
+ )
7190
+ progress(0.6, desc="asking which of them fits the scene")
7191
+ chosen = _ask_which_loras(space_id, basis, shortlist) or [0]
7192
+ picks = [shortlist[index] for index in chosen]
7193
+ built, linked = _split_picks(picks)
7194
+ labels = [_pick_label(index, item) for index, item in enumerate(shortlist)]
7195
+ return tuple(
7196
+ [gr.update(choices=labels, value=[labels[i] for i in chosen], visible=True),
7197
+ shortlist,
7198
+ _basic_note(picks, f" Picked out of {len(shortlist)} that matched, and their "
7199
+ f"words were written into every clip line."),
7200
+ gr.update(value=_retune_sheet(sheet_text, shortlist, linked)),
7201
+ gr.update(value=built)]
7202
+ + _slot_updates(linked) + [gr.update(value=_pick_links(shortlist, picks))]
7203
+ )
7204
+
7205
+ def _scene_swap(ticked, shortlist, sheet_text):
7206
+ labels = [_pick_label(index, item) for index, item in enumerate(shortlist or [])]
7207
+ wanted = [labels.index(label) for label in (ticked or []) if label in labels]
7208
+ extra = " Two at a time is the limit, so the rest were left out." if len(wanted) > 2 else ""
7209
+ picks = [shortlist[index] for index in wanted[:2]]
7210
+ built, linked = _split_picks(picks)
7211
+ return tuple(
7212
+ [_basic_note(picks, extra),
7213
+ gr.update(value=_retune_sheet(sheet_text, shortlist, linked)),
7214
+ gr.update(value=built)]
7215
+ + _slot_updates(linked) + [gr.update(value=_pick_links(shortlist, picks))]
7216
+ )
7217
+
7218
+ _scene_plan_event.success(
7219
+ fn=_scene_choose,
7220
+ inputs=[scene_prompts, scene_idea, pb_space],
7221
+ outputs=([scene_pick, scene_shortlist, scene_pick_status, scene_prompts, simple_lora]
7222
+ + _BASIC_SLOTS + [scene_links]),
7223
+ )
7224
+
7225
+ _scene_tick_event = getattr(scene_pick, "input", None) or scene_pick.change
7226
+ _scene_tick_event(
7227
+ fn=_scene_swap,
7228
+ inputs=[scene_pick, scene_shortlist, scene_prompts],
7229
+ outputs=([scene_pick_status, scene_prompts, simple_lora]
7230
+ + _BASIC_SLOTS + [scene_links]),
7231
+ )
7232
+
7233
  _PRO_ONLY = [pro_promptbuilder, pro_chips, pro_speed, pro_advanced,
7234
  pro_soundset, pro_loop]
7235