thankfulcarp commited on
Commit
5760e26
Β·
1 Parent(s): 66d63b7
Files changed (2) hide show
  1. app.py +506 -0
  2. requirements.txt +9 -0
app.py ADDED
@@ -0,0 +1,506 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import spaces
2
+ import torch
3
+ from diffusers import AutoencoderKLWan, WanImageToVideoPipeline, UniPCMultistepScheduler
4
+ from diffusers.utils import export_to_video
5
+ from transformers import CLIPVisionModel
6
+ import gradio as gr
7
+ import tempfile
8
+
9
+ from huggingface_hub import hf_hub_download
10
+ import numpy as np
11
+ from PIL import Image
12
+ import random
13
+
14
+ # Base MODEL_ID (using original Wan model that's compatible with diffusers)
15
+ MODEL_ID = "Wan-AI/Wan2.1-I2V-14B-480P-Diffusers"
16
+
17
+ # FusionX enhancement LoRAs (based on FusionX composition)
18
+ LORA_REPO_ID = "Kijai/WanVideo_comfy"
19
+ LORA_FILENAME = "Wan21_CausVid_14B_T2V_lora_rank32.safetensors"
20
+
21
+ # Additional enhancement LoRAs for FusionX-like quality
22
+ ACCVIDEO_LORA_REPO = "alibaba-pai/Wan2.1-Fun-Reward-LoRAs"
23
+ MPS_LORA_FILENAME = "Wan2.1-MPS-Reward-LoRA.safetensors"
24
+
25
+ # Load enhanced model components
26
+ print("πŸš€ Loading FusionX Enhanced Wan2.1 I2V Model...")
27
+ image_encoder = CLIPVisionModel.from_pretrained(MODEL_ID, subfolder="image_encoder", torch_dtype=torch.float32)
28
+ vae = AutoencoderKLWan.from_pretrained(MODEL_ID, subfolder="vae", torch_dtype=torch.float32)
29
+ pipe = WanImageToVideoPipeline.from_pretrained(
30
+ MODEL_ID, vae=vae, image_encoder=image_encoder, torch_dtype=torch.bfloat16
31
+ )
32
+
33
+ # FusionX optimized scheduler settings
34
+ pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config, flow_shift=8.0)
35
+ pipe.to("cuda")
36
+
37
+ # Load FusionX enhancement LoRAs
38
+ lora_adapters = []
39
+ lora_weights = []
40
+
41
+ try:
42
+ # Load CausVid LoRA (strength 1.0 as per FusionX)
43
+ causvid_path = hf_hub_download(repo_id=LORA_REPO_ID, filename=LORA_FILENAME)
44
+ pipe.load_lora_weights(causvid_path, adapter_name="causvid_lora")
45
+ lora_adapters.append("causvid_lora")
46
+ lora_weights.append(1.0) # FusionX uses 1.0 for CausVid
47
+ print("βœ… CausVid LoRA loaded (strength: 1.0)")
48
+ except Exception as e:
49
+ print(f"⚠️ CausVid LoRA not loaded: {e}")
50
+
51
+ try:
52
+ # Load MPS Rewards LoRA (strength 0.7 as per FusionX)
53
+ mps_path = hf_hub_download(repo_id=ACCVIDEO_LORA_REPO, filename=MPS_LORA_FILENAME)
54
+ pipe.load_lora_weights(mps_path, adapter_name="mps_lora")
55
+ lora_adapters.append("mps_lora")
56
+ lora_weights.append(0.7) # FusionX uses 0.7 for MPS
57
+ print("βœ… MPS Rewards LoRA loaded (strength: 0.7)")
58
+ except Exception as e:
59
+ print(f"⚠️ MPS LoRA not loaded: {e}")
60
+
61
+ # Apply LoRA adapters if any were loaded
62
+ if lora_adapters:
63
+ pipe.set_adapters(lora_adapters, adapter_weights=lora_weights)
64
+ pipe.fuse_lora()
65
+ print(f"πŸ”₯ FusionX Enhancement Applied: {len(lora_adapters)} LoRAs fused")
66
+ else:
67
+ print("πŸ“ No LoRAs loaded - using base Wan model")
68
+
69
+ MOD_VALUE = 32
70
+ DEFAULT_H_SLIDER_VALUE = 576 # FusionX optimized default
71
+ DEFAULT_W_SLIDER_VALUE = 1024 # FusionX optimized default
72
+ NEW_FORMULA_MAX_AREA = 576.0 * 1024.0 # Updated for FusionX
73
+
74
+ SLIDER_MIN_H, SLIDER_MAX_H = 128, 1080
75
+ SLIDER_MIN_W, SLIDER_MAX_W = 128, 1920
76
+ MAX_SEED = np.iinfo(np.int32).max
77
+
78
+ FIXED_FPS = 24
79
+ MIN_FRAMES_MODEL = 8
80
+ MAX_FRAMES_MODEL = 121 # FusionX supports up to 121 frames
81
+
82
+ # Enhanced prompts for FusionX-style output
83
+ default_prompt_i2v = "Cinematic motion, smooth animation, detailed textures, dynamic lighting, professional cinematography"
84
+ default_negative_prompt = "Static image, no motion, blurred details, overexposed, underexposed, low quality, worst quality, JPEG artifacts, ugly, incomplete, extra fingers, poorly drawn hands, poorly drawn faces, deformed, disfigured, misshapen limbs, fused fingers, still picture, messy background, watermark, text, signature, three legs, many people in the background, walking backwards"
85
+
86
+ # Enhanced CSS for FusionX theme
87
+ custom_css = """
88
+ /* Enhanced FusionX theme with cinematic styling */
89
+ .gradio-container {
90
+ font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;
91
+ background: linear-gradient(135deg, #1a1a2e 0%, #16213e 25%, #0f3460 50%, #533a7d 75%, #6a4c93 100%) !important;
92
+ background-size: 400% 400% !important;
93
+ animation: cinematicShift 20s ease infinite !important;
94
+ }
95
+ @keyframes cinematicShift {
96
+ 0% { background-position: 0% 50%; }
97
+ 25% { background-position: 100% 50%; }
98
+ 50% { background-position: 100% 100%; }
99
+ 75% { background-position: 0% 100%; }
100
+ 100% { background-position: 0% 50%; }
101
+ }
102
+ /* Main container with cinematic glass effect */
103
+ .main-container {
104
+ backdrop-filter: blur(15px);
105
+ background: rgba(255, 255, 255, 0.08) !important;
106
+ border-radius: 25px !important;
107
+ padding: 35px !important;
108
+ box-shadow: 0 12px 40px 0 rgba(31, 38, 135, 0.4) !important;
109
+ border: 1px solid rgba(255, 255, 255, 0.15) !important;
110
+ position: relative;
111
+ overflow: hidden;
112
+ }
113
+ .main-container::before {
114
+ content: '';
115
+ position: absolute;
116
+ top: 0;
117
+ left: 0;
118
+ right: 0;
119
+ bottom: 0;
120
+ background: linear-gradient(45deg, rgba(255,255,255,0.1) 0%, transparent 50%, rgba(255,255,255,0.05) 100%);
121
+ pointer-events: none;
122
+ }
123
+ /* Enhanced header with FusionX branding */
124
+ h1 {
125
+ background: linear-gradient(45deg, #ffffff, #f0f8ff, #e6e6fa) !important;
126
+ -webkit-background-clip: text !important;
127
+ -webkit-text-fill-color: transparent !important;
128
+ background-clip: text !important;
129
+ font-weight: 900 !important;
130
+ font-size: 2.8rem !important;
131
+ text-align: center !important;
132
+ margin-bottom: 2.5rem !important;
133
+ text-shadow: 2px 2px 8px rgba(0,0,0,0.3) !important;
134
+ position: relative;
135
+ }
136
+ h1::after {
137
+ content: '🎬 FusionX Enhanced';
138
+ display: block;
139
+ font-size: 1rem;
140
+ color: #6a4c93;
141
+ margin-top: 0.5rem;
142
+ font-weight: 500;
143
+ }
144
+ /* Enhanced component containers */
145
+ .input-container, .output-container {
146
+ background: rgba(255, 255, 255, 0.06) !important;
147
+ border-radius: 20px !important;
148
+ padding: 25px !important;
149
+ margin: 15px 0 !important;
150
+ backdrop-filter: blur(10px) !important;
151
+ border: 1px solid rgba(255, 255, 255, 0.12) !important;
152
+ box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1) !important;
153
+ }
154
+ /* Cinematic input styling */
155
+ input, textarea, .gr-box {
156
+ background: rgba(255, 255, 255, 0.95) !important;
157
+ border: 1px solid rgba(106, 76, 147, 0.3) !important;
158
+ border-radius: 12px !important;
159
+ color: #1a1a2e !important;
160
+ transition: all 0.4s ease !important;
161
+ box-shadow: 0 2px 8px rgba(106, 76, 147, 0.1) !important;
162
+ }
163
+ input:focus, textarea:focus {
164
+ background: rgba(255, 255, 255, 1) !important;
165
+ border-color: #6a4c93 !important;
166
+ box-shadow: 0 0 0 3px rgba(106, 76, 147, 0.15) !important;
167
+ transform: translateY(-1px) !important;
168
+ }
169
+ /* Enhanced FusionX button */
170
+ .generate-btn {
171
+ background: linear-gradient(135deg, #6a4c93 0%, #533a7d 50%, #0f3460 100%) !important;
172
+ color: white !important;
173
+ font-weight: 700 !important;
174
+ font-size: 1.2rem !important;
175
+ padding: 15px 40px !important;
176
+ border-radius: 60px !important;
177
+ border: none !important;
178
+ cursor: pointer !important;
179
+ transition: all 0.4s ease !important;
180
+ box-shadow: 0 6px 20px rgba(106, 76, 147, 0.4) !important;
181
+ position: relative;
182
+ overflow: hidden;
183
+ }
184
+ .generate-btn::before {
185
+ content: '';
186
+ position: absolute;
187
+ top: 0;
188
+ left: -100%;
189
+ width: 100%;
190
+ height: 100%;
191
+ background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
192
+ transition: left 0.5s ease;
193
+ }
194
+ .generate-btn:hover::before {
195
+ left: 100%;
196
+ }
197
+ .generate-btn:hover {
198
+ transform: translateY(-3px) scale(1.02) !important;
199
+ box-shadow: 0 8px 25px rgba(106, 76, 147, 0.6) !important;
200
+ }
201
+ /* Enhanced slider styling */
202
+ input[type="range"] {
203
+ background: transparent !important;
204
+ }
205
+ input[type="range"]::-webkit-slider-track {
206
+ background: linear-gradient(90deg, rgba(106, 76, 147, 0.3), rgba(83, 58, 125, 0.5)) !important;
207
+ border-radius: 8px !important;
208
+ height: 8px !important;
209
+ }
210
+ input[type="range"]::-webkit-slider-thumb {
211
+ background: linear-gradient(135deg, #6a4c93, #533a7d) !important;
212
+ border: 3px solid white !important;
213
+ border-radius: 50% !important;
214
+ cursor: pointer !important;
215
+ width: 22px !important;
216
+ height: 22px !important;
217
+ -webkit-appearance: none !important;
218
+ box-shadow: 0 2px 8px rgba(106, 76, 147, 0.3) !important;
219
+ }
220
+ /* Enhanced accordion */
221
+ .gr-accordion {
222
+ background: rgba(255, 255, 255, 0.04) !important;
223
+ border-radius: 15px !important;
224
+ border: 1px solid rgba(255, 255, 255, 0.08) !important;
225
+ margin: 20px 0 !important;
226
+ backdrop-filter: blur(5px) !important;
227
+ }
228
+ /* Enhanced labels */
229
+ label {
230
+ color: #ffffff !important;
231
+ font-weight: 600 !important;
232
+ font-size: 1rem !important;
233
+ margin-bottom: 8px !important;
234
+ text-shadow: 1px 1px 2px rgba(0,0,0,0.5) !important;
235
+ }
236
+ /* Enhanced image upload */
237
+ .image-upload {
238
+ border: 3px dashed rgba(106, 76, 147, 0.4) !important;
239
+ border-radius: 20px !important;
240
+ background: rgba(255, 255, 255, 0.03) !important;
241
+ transition: all 0.4s ease !important;
242
+ position: relative;
243
+ }
244
+ .image-upload:hover {
245
+ border-color: rgba(106, 76, 147, 0.7) !important;
246
+ background: rgba(255, 255, 255, 0.08) !important;
247
+ transform: scale(1.01) !important;
248
+ }
249
+ /* Enhanced video output */
250
+ video {
251
+ border-radius: 20px !important;
252
+ box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4) !important;
253
+ border: 2px solid rgba(106, 76, 147, 0.3) !important;
254
+ }
255
+ /* Enhanced examples section */
256
+ .gr-examples {
257
+ background: rgba(255, 255, 255, 0.04) !important;
258
+ border-radius: 20px !important;
259
+ padding: 25px !important;
260
+ margin-top: 25px !important;
261
+ border: 1px solid rgba(255, 255, 255, 0.1) !important;
262
+ }
263
+ /* Enhanced checkbox */
264
+ input[type="checkbox"] {
265
+ accent-color: #6a4c93 !important;
266
+ transform: scale(1.2) !important;
267
+ }
268
+ /* Responsive enhancements */
269
+ @media (max-width: 768px) {
270
+ h1 { font-size: 2.2rem !important; }
271
+ .main-container { padding: 25px !important; }
272
+ .generate-btn { padding: 12px 30px !important; font-size: 1.1rem !important; }
273
+ }
274
+ /* Badge container styling */
275
+ .badge-container {
276
+ display: flex;
277
+ justify-content: center;
278
+ gap: 15px;
279
+ margin: 20px 0;
280
+ flex-wrap: wrap;
281
+ }
282
+ .badge-container img {
283
+ border-radius: 8px;
284
+ transition: transform 0.3s ease;
285
+ }
286
+ .badge-container img:hover {
287
+ transform: scale(1.05);
288
+ }
289
+ """
290
+
291
+ def _calculate_new_dimensions_wan(pil_image, mod_val, calculation_max_area,
292
+ min_slider_h, max_slider_h,
293
+ min_slider_w, max_slider_w,
294
+ default_h, default_w):
295
+ orig_w, orig_h = pil_image.size
296
+ if orig_w <= 0 or orig_h <= 0:
297
+ return default_h, default_w
298
+
299
+ aspect_ratio = orig_h / orig_w
300
+
301
+ calc_h = round(np.sqrt(calculation_max_area * aspect_ratio))
302
+ calc_w = round(np.sqrt(calculation_max_area / aspect_ratio))
303
+
304
+ calc_h = max(mod_val, (calc_h // mod_val) * mod_val)
305
+ calc_w = max(mod_val, (calc_w // mod_val) * mod_val)
306
+
307
+ new_h = int(np.clip(calc_h, min_slider_h, (max_slider_h // mod_val) * mod_val))
308
+ new_w = int(np.clip(calc_w, min_slider_w, (max_slider_w // mod_val) * mod_val))
309
+
310
+ return new_h, new_w
311
+
312
+ def handle_image_upload_for_dims_wan(uploaded_pil_image, current_h_val, current_w_val):
313
+ if uploaded_pil_image is None:
314
+ return gr.update(value=DEFAULT_H_SLIDER_VALUE), gr.update(value=DEFAULT_W_SLIDER_VALUE)
315
+ try:
316
+ new_h, new_w = _calculate_new_dimensions_wan(
317
+ uploaded_pil_image, MOD_VALUE, NEW_FORMULA_MAX_AREA,
318
+ SLIDER_MIN_H, SLIDER_MAX_H, SLIDER_MIN_W, SLIDER_MAX_W,
319
+ DEFAULT_H_SLIDER_VALUE, DEFAULT_W_SLIDER_VALUE
320
+ )
321
+ return gr.update(value=new_h), gr.update(value=new_w)
322
+ except Exception as e:
323
+ gr.Warning("Error attempting to calculate new dimensions")
324
+ return gr.update(value=DEFAULT_H_SLIDER_VALUE), gr.update(value=DEFAULT_W_SLIDER_VALUE)
325
+
326
+ def get_duration(input_image, prompt, height, width,
327
+ negative_prompt, duration_seconds,
328
+ guidance_scale, steps,
329
+ seed, randomize_seed,
330
+ progress):
331
+ # FusionX optimized duration calculation
332
+ if steps > 8 and duration_seconds > 3:
333
+ return 100
334
+ elif steps > 8 or duration_seconds > 3:
335
+ return 80
336
+ else:
337
+ return 65
338
+
339
+ @spaces.GPU(duration=get_duration)
340
+ def generate_video(input_image, prompt, height, width,
341
+ negative_prompt=default_negative_prompt, duration_seconds=3,
342
+ guidance_scale=1, steps=8, # FusionX optimized default
343
+ seed=42, randomize_seed=False,
344
+ progress=gr.Progress(track_tqdm=True)):
345
+
346
+ if input_image is None:
347
+ raise gr.Error("Please upload an input image.")
348
+
349
+ target_h = max(MOD_VALUE, (int(height) // MOD_VALUE) * MOD_VALUE)
350
+ target_w = max(MOD_VALUE, (int(width) // MOD_VALUE) * MOD_VALUE)
351
+
352
+ num_frames = np.clip(int(round(duration_seconds * FIXED_FPS)), MIN_FRAMES_MODEL, MAX_FRAMES_MODEL)
353
+
354
+ current_seed = random.randint(0, MAX_SEED) if randomize_seed else int(seed)
355
+
356
+ resized_image = input_image.resize((target_w, target_h))
357
+
358
+ # Enhanced prompt for FusionX-style output
359
+ enhanced_prompt = f"{prompt}, cinematic quality, smooth motion, detailed animation, dynamic lighting"
360
+
361
+ with torch.inference_mode():
362
+ output_frames_list = pipe(
363
+ image=resized_image,
364
+ prompt=enhanced_prompt,
365
+ negative_prompt=negative_prompt,
366
+ height=target_h,
367
+ width=target_w,
368
+ num_frames=num_frames,
369
+ guidance_scale=float(guidance_scale),
370
+ num_inference_steps=int(steps),
371
+ generator=torch.Generator(device="cuda").manual_seed(current_seed)
372
+ ).frames[0]
373
+
374
+ with tempfile.NamedTemporaryFile(suffix=".mp4", delete=False) as tmpfile:
375
+ video_path = tmpfile.name
376
+ export_to_video(output_frames_list, video_path, fps=FIXED_FPS)
377
+ return video_path, current_seed
378
+
379
+ with gr.Blocks() as demo:
380
+ with gr.Column(elem_classes=["main-container"]):
381
+ gr.Markdown("# ⚑ FusionX Enhanced Wan 2.1 I2V (14B)")
382
+
383
+
384
+
385
+
386
+
387
+ with gr.Row():
388
+ with gr.Column(elem_classes=["input-container"]):
389
+ input_image_component = gr.Image(
390
+ type="pil",
391
+ label="πŸ–ΌοΈ Input Image (auto-resized to target H/W)",
392
+ elem_classes=["image-upload"]
393
+ )
394
+ prompt_input = gr.Textbox(
395
+ label="✏️ Enhanced Prompt (FusionX-style enhancements applied)",
396
+ value=default_prompt_i2v,
397
+ lines=3
398
+ )
399
+ duration_seconds_input = gr.Slider(
400
+ minimum=round(MIN_FRAMES_MODEL/FIXED_FPS,1),
401
+ maximum=round(MAX_FRAMES_MODEL/FIXED_FPS,1),
402
+ step=0.1,
403
+ value=2,
404
+ label="⏱️ Duration (seconds)",
405
+ info=f"FusionX Enhanced supports {MIN_FRAMES_MODEL}-{MAX_FRAMES_MODEL} frames at {FIXED_FPS}fps. Recommended: 2-5 seconds"
406
+ )
407
+
408
+ with gr.Accordion("βš™οΈ Advanced FusionX Settings", open=False):
409
+ negative_prompt_input = gr.Textbox(
410
+ label="❌ Negative Prompt (FusionX Enhanced)",
411
+ value=default_negative_prompt,
412
+ lines=4
413
+ )
414
+ seed_input = gr.Slider(
415
+ label="🎲 Seed",
416
+ minimum=0,
417
+ maximum=MAX_SEED,
418
+ step=1,
419
+ value=42,
420
+ interactive=True
421
+ )
422
+ randomize_seed_checkbox = gr.Checkbox(
423
+ label="πŸ”€ Randomize seed",
424
+ value=True,
425
+ interactive=True
426
+ )
427
+ with gr.Row():
428
+ height_input = gr.Slider(
429
+ minimum=SLIDER_MIN_H,
430
+ maximum=SLIDER_MAX_H,
431
+ step=MOD_VALUE,
432
+ value=DEFAULT_H_SLIDER_VALUE,
433
+ label=f"πŸ“ Output Height (FusionX optimized: {MOD_VALUE} multiples)"
434
+ )
435
+ width_input = gr.Slider(
436
+ minimum=SLIDER_MIN_W,
437
+ maximum=SLIDER_MAX_W,
438
+ step=MOD_VALUE,
439
+ value=DEFAULT_W_SLIDER_VALUE,
440
+ label=f"πŸ“ Output Width (FusionX optimized: {MOD_VALUE} multiples)"
441
+ )
442
+ steps_slider = gr.Slider(
443
+ minimum=1,
444
+ maximum=20,
445
+ step=1,
446
+ value=8, # FusionX optimized
447
+ label="πŸš€ Inference Steps (FusionX Enhanced: 8-10 recommended)",
448
+ info="FusionX Enhanced delivers excellent results in just 8-10 steps!"
449
+ )
450
+ guidance_scale_input = gr.Slider(
451
+ minimum=0.0,
452
+ maximum=20.0,
453
+ step=0.5,
454
+ value=1.0,
455
+ label="🎯 Guidance Scale (FusionX optimized)",
456
+ visible=False
457
+ )
458
+
459
+ generate_button = gr.Button(
460
+ "🎬 Generate FusionX Enhanced Video",
461
+ variant="primary",
462
+ elem_classes=["generate-btn"]
463
+ )
464
+
465
+ with gr.Column(elem_classes=["output-container"]):
466
+ video_output = gr.Video(
467
+ label="πŸŽ₯ FusionX Enhanced Generated Video",
468
+ autoplay=True,
469
+ interactive=False
470
+ )
471
+
472
+ input_image_component.upload(
473
+ fn=handle_image_upload_for_dims_wan,
474
+ inputs=[input_image_component, height_input, width_input],
475
+ outputs=[height_input, width_input]
476
+ )
477
+
478
+ input_image_component.clear(
479
+ fn=handle_image_upload_for_dims_wan,
480
+ inputs=[input_image_component, height_input, width_input],
481
+ outputs=[height_input, width_input]
482
+ )
483
+
484
+ ui_inputs = [
485
+ input_image_component, prompt_input, height_input, width_input,
486
+ negative_prompt_input, duration_seconds_input,
487
+ guidance_scale_input, steps_slider, seed_input, randomize_seed_checkbox
488
+ ]
489
+ generate_button.click(fn=generate_video, inputs=ui_inputs, outputs=[video_output, seed_input])
490
+
491
+ with gr.Column():
492
+ gr.Examples(
493
+ examples=[
494
+ ["peng.png", "a penguin gracefully dancing in the pristine snow, cinematic motion with detailed feathers", 576, 576],
495
+ ["frog.jpg", "the frog jumps energetically with smooth, lifelike motion and detailed texture", 576, 576],
496
+ ],
497
+ inputs=[input_image_component, prompt_input, height_input, width_input],
498
+ outputs=[video_output, seed_input],
499
+ fn=generate_video,
500
+ cache_examples="lazy",
501
+ label="🌟 FusionX Enhanced Example Gallery"
502
+ )
503
+
504
+
505
+ if __name__ == "__main__":
506
+ demo.queue().launch()
requirements.txt ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ git+https://github.com/huggingface/diffusers.git
2
+ transformers
3
+ accelerate
4
+ safetensors
5
+ sentencepiece
6
+ peft
7
+ ftfy
8
+ imageio-ffmpeg
9
+ opencv-python