Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -173,6 +173,7 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Soft()) as demo:
|
|
| 173 |
with gr.Column(elem_classes=["main-container"]):
|
| 174 |
gr.Markdown("# ✨ Fast 4 steps Wan 2.1 I2V (14B) with CausVid LoRA")
|
| 175 |
|
|
|
|
| 176 |
gr.HTML("""
|
| 177 |
<div class="badge-container">
|
| 178 |
<a href="https://huggingface.co/spaces/Heartsync/WAN2-1-fast-T2V-FusioniX" target="_blank">
|
|
@@ -186,8 +187,9 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Soft()) as demo:
|
|
| 186 |
</a>
|
| 187 |
</div>
|
| 188 |
""")
|
| 189 |
-
|
| 190 |
with gr.Row():
|
|
|
|
| 191 |
with gr.Column(elem_classes=["input-container"]):
|
| 192 |
input_image_component = gr.Image(
|
| 193 |
type="pil",
|
|
@@ -207,7 +209,7 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Soft()) as demo:
|
|
| 207 |
label="⏱️ Duration (seconds)",
|
| 208 |
info=f"Clamped to model's {MIN_FRAMES_MODEL}-{MAX_FRAMES_MODEL} frames at {FIXED_FPS}fps."
|
| 209 |
)
|
| 210 |
-
|
| 211 |
with gr.Accordion("⚙️ Advanced Settings", open=False):
|
| 212 |
negative_prompt_input = gr.Textbox(
|
| 213 |
label="❌ Negative Prompt",
|
|
@@ -219,13 +221,11 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Soft()) as demo:
|
|
| 219 |
minimum=0,
|
| 220 |
maximum=MAX_SEED,
|
| 221 |
step=1,
|
| 222 |
-
value=42
|
| 223 |
-
interactive=True
|
| 224 |
)
|
| 225 |
randomize_seed_checkbox = gr.Checkbox(
|
| 226 |
label="🔀 Randomize seed",
|
| 227 |
-
value=True
|
| 228 |
-
interactive=True
|
| 229 |
)
|
| 230 |
with gr.Row():
|
| 231 |
height_input = gr.Slider(
|
|
@@ -248,7 +248,7 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Soft()) as demo:
|
|
| 248 |
step=1,
|
| 249 |
value=4,
|
| 250 |
label="🚀 Inference Steps"
|
| 251 |
-
)
|
| 252 |
guidance_scale_input = gr.Slider(
|
| 253 |
minimum=0.0,
|
| 254 |
maximum=20.0,
|
|
@@ -258,67 +258,66 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Soft()) as demo:
|
|
| 258 |
visible=False
|
| 259 |
)
|
| 260 |
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
generate_button = gr.Button(
|
| 278 |
"🎬 Generate Video",
|
| 279 |
variant="primary",
|
| 280 |
elem_classes=["generate-btn"]
|
| 281 |
)
|
| 282 |
-
|
| 283 |
-
with gr.Column(elem_classes=["output-container"]):
|
| 284 |
-
video_output = gr.Video(
|
| 285 |
-
label="🎥 Generated Video",
|
| 286 |
-
autoplay=True,
|
| 287 |
-
interactive=False
|
| 288 |
-
)
|
| 289 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 290 |
input_image_component.upload(
|
| 291 |
fn=handle_image_upload_for_dims_wan,
|
| 292 |
inputs=[input_image_component, height_input, width_input],
|
| 293 |
outputs=[height_input, width_input]
|
| 294 |
)
|
| 295 |
-
|
| 296 |
-
input_image_component.clear(
|
| 297 |
fn=handle_image_upload_for_dims_wan,
|
| 298 |
inputs=[input_image_component, height_input, width_input],
|
| 299 |
outputs=[height_input, width_input]
|
| 300 |
)
|
| 301 |
-
|
|
|
|
| 302 |
ui_inputs = [
|
| 303 |
input_image_component, prompt_input, height_input, width_input,
|
| 304 |
negative_prompt_input, duration_seconds_input,
|
| 305 |
guidance_scale_input, steps_slider, seed_input, randomize_seed_checkbox,
|
| 306 |
optional_lora_dropdown, lora_strength_slider
|
| 307 |
-
input_image_component, prompt_input, height_input, width_input,
|
| 308 |
-
negative_prompt_input, duration_seconds_input,
|
| 309 |
-
guidance_scale_input, steps_slider, seed_input, randomize_seed_checkbox
|
| 310 |
]
|
| 311 |
generate_button.click(fn=generate_video, inputs=ui_inputs, outputs=[video_output, seed_input])
|
| 312 |
|
|
|
|
| 313 |
with gr.Column():
|
| 314 |
gr.Examples(
|
| 315 |
-
examples=[
|
| 316 |
["peng.png", "a penguin playfully dancing in the snow, Antarctica", 896, 896],
|
| 317 |
["forg.jpg", "the frog jumps around", 832, 832],
|
| 318 |
],
|
| 319 |
-
inputs=[input_image_component, prompt_input, height_input, width_input],
|
| 320 |
-
outputs=[video_output, seed_input],
|
| 321 |
-
fn=generate_video,
|
| 322 |
cache_examples="lazy",
|
| 323 |
label="🌟 Example Gallery"
|
| 324 |
)
|
|
|
|
| 173 |
with gr.Column(elem_classes=["main-container"]):
|
| 174 |
gr.Markdown("# ✨ Fast 4 steps Wan 2.1 I2V (14B) with CausVid LoRA")
|
| 175 |
|
| 176 |
+
# Badges
|
| 177 |
gr.HTML("""
|
| 178 |
<div class="badge-container">
|
| 179 |
<a href="https://huggingface.co/spaces/Heartsync/WAN2-1-fast-T2V-FusioniX" target="_blank">
|
|
|
|
| 187 |
</a>
|
| 188 |
</div>
|
| 189 |
""")
|
| 190 |
+
|
| 191 |
with gr.Row():
|
| 192 |
+
# Input Column
|
| 193 |
with gr.Column(elem_classes=["input-container"]):
|
| 194 |
input_image_component = gr.Image(
|
| 195 |
type="pil",
|
|
|
|
| 209 |
label="⏱️ Duration (seconds)",
|
| 210 |
info=f"Clamped to model's {MIN_FRAMES_MODEL}-{MAX_FRAMES_MODEL} frames at {FIXED_FPS}fps."
|
| 211 |
)
|
| 212 |
+
|
| 213 |
with gr.Accordion("⚙️ Advanced Settings", open=False):
|
| 214 |
negative_prompt_input = gr.Textbox(
|
| 215 |
label="❌ Negative Prompt",
|
|
|
|
| 221 |
minimum=0,
|
| 222 |
maximum=MAX_SEED,
|
| 223 |
step=1,
|
| 224 |
+
value=42
|
|
|
|
| 225 |
)
|
| 226 |
randomize_seed_checkbox = gr.Checkbox(
|
| 227 |
label="🔀 Randomize seed",
|
| 228 |
+
value=True
|
|
|
|
| 229 |
)
|
| 230 |
with gr.Row():
|
| 231 |
height_input = gr.Slider(
|
|
|
|
| 248 |
step=1,
|
| 249 |
value=4,
|
| 250 |
label="🚀 Inference Steps"
|
| 251 |
+
)
|
| 252 |
guidance_scale_input = gr.Slider(
|
| 253 |
minimum=0.0,
|
| 254 |
maximum=20.0,
|
|
|
|
| 258 |
visible=False
|
| 259 |
)
|
| 260 |
|
| 261 |
+
# LoRA controls
|
| 262 |
+
optional_lora_dropdown = gr.Dropdown(
|
| 263 |
+
choices=["None", "GEN", "INS"],
|
| 264 |
+
value="None",
|
| 265 |
+
label="🧩 Optional LoRA"
|
| 266 |
+
)
|
| 267 |
+
lora_strength_slider = gr.Slider(
|
| 268 |
+
minimum=0.0,
|
| 269 |
+
maximum=1.0,
|
| 270 |
+
step=0.05,
|
| 271 |
+
value=1.0,
|
| 272 |
+
label="⚡ LoRA Strength"
|
| 273 |
+
)
|
| 274 |
+
|
| 275 |
+
# Generate button
|
| 276 |
+
generate_button = gr.Button(
|
|
|
|
| 277 |
"🎬 Generate Video",
|
| 278 |
variant="primary",
|
| 279 |
elem_classes=["generate-btn"]
|
| 280 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 281 |
|
| 282 |
+
# Output Column
|
| 283 |
+
with gr.Column(elem_classes=["output-container"]):
|
| 284 |
+
video_output = gr.Video(
|
| 285 |
+
label="🎥 Generated Video",
|
| 286 |
+
autoplay=True,
|
| 287 |
+
interactive=False
|
| 288 |
+
)
|
| 289 |
+
|
| 290 |
+
# Image upload handlers
|
| 291 |
input_image_component.upload(
|
| 292 |
fn=handle_image_upload_for_dims_wan,
|
| 293 |
inputs=[input_image_component, height_input, width_input],
|
| 294 |
outputs=[height_input, width_input]
|
| 295 |
)
|
| 296 |
+
input_image_component.clear(
|
|
|
|
| 297 |
fn=handle_image_upload_for_dims_wan,
|
| 298 |
inputs=[input_image_component, height_input, width_input],
|
| 299 |
outputs=[height_input, width_input]
|
| 300 |
)
|
| 301 |
+
|
| 302 |
+
# Inputs list for generation
|
| 303 |
ui_inputs = [
|
| 304 |
input_image_component, prompt_input, height_input, width_input,
|
| 305 |
negative_prompt_input, duration_seconds_input,
|
| 306 |
guidance_scale_input, steps_slider, seed_input, randomize_seed_checkbox,
|
| 307 |
optional_lora_dropdown, lora_strength_slider
|
|
|
|
|
|
|
|
|
|
| 308 |
]
|
| 309 |
generate_button.click(fn=generate_video, inputs=ui_inputs, outputs=[video_output, seed_input])
|
| 310 |
|
| 311 |
+
# Example gallery
|
| 312 |
with gr.Column():
|
| 313 |
gr.Examples(
|
| 314 |
+
examples=[
|
| 315 |
["peng.png", "a penguin playfully dancing in the snow, Antarctica", 896, 896],
|
| 316 |
["forg.jpg", "the frog jumps around", 832, 832],
|
| 317 |
],
|
| 318 |
+
inputs=[input_image_component, prompt_input, height_input, width_input],
|
| 319 |
+
outputs=[video_output, seed_input],
|
| 320 |
+
fn=generate_video,
|
| 321 |
cache_examples="lazy",
|
| 322 |
label="🌟 Example Gallery"
|
| 323 |
)
|