thankfulcarp commited on
Commit
ecf2c6b
Β·
1 Parent(s): 7ee7e08

Minor finalization changes.

Browse files
Files changed (1) hide show
  1. app.py +20 -7
app.py CHANGED
@@ -110,17 +110,19 @@ default_negative_prompt = "Static image, no motion, blurred details, overexposed
110
 
111
  # --- LoRA Preset Helper Functions ---
112
  def parse_lset_prompt(lset_prompt):
113
- """Parses a .lset prompt, resolving variables with their defaults."""
114
  # Find all variable declarations like ! {Subject}="woman"
115
  variables = dict(re.findall(r'! \{(\w+)\}="([^"]+)"', lset_prompt))
116
 
117
  # Remove the declaration lines to get the clean prompt template
118
  prompt_template = re.sub(r'! \{\w+\}="[^"]+"\n?', '', lset_prompt).strip()
119
 
120
- # Replace placeholders with their default values
121
  resolved_prompt = prompt_template
122
  for key, value in variables.items():
123
- resolved_prompt = resolved_prompt.replace(f"{{{key}}}", value)
 
 
124
 
125
  return resolved_prompt
126
 
@@ -152,8 +154,9 @@ def handle_lora_selection_change(preset_name, current_prompt):
152
  return gr.update()
153
 
154
  resolved_prompt = parse_lset_prompt(lset_prompt_raw)
155
- new_prompt = f"{current_prompt} {resolved_prompt}".strip()
156
- gr.Info(f"βœ… Appended prompt from '{lset_filename}'")
 
157
  return gr.update(value=new_prompt)
158
  except Exception as e:
159
  # This should be less common now, but good to keep for safety.
@@ -333,7 +336,17 @@ def generate_i2v_video(input_image, prompt, height, width,
333
  with gr.Blocks() as demo:
334
  with gr.Column(elem_classes=["main-container"]):
335
  i2v_aspect_ratio = gr.State(value=DEFAULT_W_SLIDER_VALUE / DEFAULT_H_SLIDER_VALUE)
336
- gr.Markdown("# ⚑ FusionX Enhanced Wan 2.1 Video Suite")
 
 
 
 
 
 
 
 
 
 
337
 
338
  with gr.Tabs(elem_classes=["gr-tabs"]):
339
  # --- Image-to-Video Tab ---
@@ -345,6 +358,7 @@ with gr.Blocks() as demo:
345
  label="πŸ–ΌοΈ Input Image (auto-resizes H/W sliders)",
346
  elem_classes=["image-upload"]
347
  )
 
348
  i2v_prompt = gr.Textbox(
349
  label="✏️ Prompt",
350
  value=default_prompt_i2v, lines=3
@@ -359,7 +373,6 @@ with gr.Blocks() as demo:
359
  i2v_neg_prompt = gr.Textbox(label="❌ Negative Prompt", value=default_negative_prompt, lines=4)
360
  i2v_seed = gr.Slider(label="🎲 Seed", minimum=0, maximum=MAX_SEED, step=1, value=42, interactive=True)
361
  i2v_rand_seed = gr.Checkbox(label="πŸ”€ Randomize seed", value=True, interactive=True)
362
- i2v_preset_name = gr.Dropdown(label="🎨 LoRA Preset", choices=available_i2v_presets, value="None", info="Select a preset to apply a LoRA and a suggested prompt.", interactive=len(available_i2v_presets) > 1)
363
  i2v_lora_weight = gr.Slider(label="πŸ’ͺ LoRA Weight", minimum=0.0, maximum=2.0, step=0.1, value=0.8, interactive=True)
364
  with gr.Row():
365
  i2v_height = gr.Slider(minimum=SLIDER_MIN_H, maximum=SLIDER_MAX_H, step=MOD_VALUE, value=DEFAULT_H_SLIDER_VALUE, label=f"πŸ“ Height ({MOD_VALUE}px steps)")
 
110
 
111
  # --- LoRA Preset Helper Functions ---
112
  def parse_lset_prompt(lset_prompt):
113
+ """Parses a .lset prompt, resolving variables and highlighting them."""
114
  # Find all variable declarations like ! {Subject}="woman"
115
  variables = dict(re.findall(r'! \{(\w+)\}="([^"]+)"', lset_prompt))
116
 
117
  # Remove the declaration lines to get the clean prompt template
118
  prompt_template = re.sub(r'! \{\w+\}="[^"]+"\n?', '', lset_prompt).strip()
119
 
120
+ # Replace placeholders with their default values, highlighted with markdown
121
  resolved_prompt = prompt_template
122
  for key, value in variables.items():
123
+ # Highlight the default value to indicate it's a replaceable variable
124
+ highlighted_value = f"__{value}__"
125
+ resolved_prompt = resolved_prompt.replace(f"{{{key}}}", highlighted_value)
126
 
127
  return resolved_prompt
128
 
 
154
  return gr.update()
155
 
156
  resolved_prompt = parse_lset_prompt(lset_prompt_raw)
157
+ # Append with newlines for separation. If current prompt is empty, strip() handles it.
158
+ new_prompt = f"{current_prompt}\n\n{resolved_prompt}".strip()
159
+ gr.Info(f"βœ… Appended prompt from '{lset_filename}'. Replace highlighted text like __this__.")
160
  return gr.update(value=new_prompt)
161
  except Exception as e:
162
  # This should be less common now, but good to keep for safety.
 
336
  with gr.Blocks() as demo:
337
  with gr.Column(elem_classes=["main-container"]):
338
  i2v_aspect_ratio = gr.State(value=DEFAULT_W_SLIDER_VALUE / DEFAULT_H_SLIDER_VALUE)
339
+ gr.Markdown("# Wan 2.1 Video Suite with Dynamic LoRA Presets")
340
+ gr.Markdown(
341
+ """
342
+ Welcome! This space allows you to generate videos from images using the powerful Wan 2.1 model, enhanced with dynamic LoRA presets.
343
+
344
+ **How to use:**
345
+ 1. Start in the **Image-to-Video** tab and upload your starting image.
346
+ 2. Select a **LoRA Preset** from the dropdown to apply a unique style and automatically add a suggested prompt.
347
+ 3. Customize the prompt, adjust settings like duration and resolution, and click **Generate I2V**!
348
+ """
349
+ )
350
 
351
  with gr.Tabs(elem_classes=["gr-tabs"]):
352
  # --- Image-to-Video Tab ---
 
358
  label="πŸ–ΌοΈ Input Image (auto-resizes H/W sliders)",
359
  elem_classes=["image-upload"]
360
  )
361
+ i2v_preset_name = gr.Dropdown(label="🎨 LoRA Preset", choices=available_i2v_presets, value="None", info="Select a preset to apply a LoRA and a suggested prompt.", interactive=len(available_i2v_presets) > 1)
362
  i2v_prompt = gr.Textbox(
363
  label="✏️ Prompt",
364
  value=default_prompt_i2v, lines=3
 
373
  i2v_neg_prompt = gr.Textbox(label="❌ Negative Prompt", value=default_negative_prompt, lines=4)
374
  i2v_seed = gr.Slider(label="🎲 Seed", minimum=0, maximum=MAX_SEED, step=1, value=42, interactive=True)
375
  i2v_rand_seed = gr.Checkbox(label="πŸ”€ Randomize seed", value=True, interactive=True)
 
376
  i2v_lora_weight = gr.Slider(label="πŸ’ͺ LoRA Weight", minimum=0.0, maximum=2.0, step=0.1, value=0.8, interactive=True)
377
  with gr.Row():
378
  i2v_height = gr.Slider(minimum=SLIDER_MIN_H, maximum=SLIDER_MAX_H, step=MOD_VALUE, value=DEFAULT_H_SLIDER_VALUE, label=f"πŸ“ Height ({MOD_VALUE}px steps)")