Upload 4 files
Browse files- FlowFacade.py +4 -7
- VideoEngine_optimized.py +12 -18
- prompt_examples.py +14 -14
- ui_manager.py +35 -11
FlowFacade.py
CHANGED
|
@@ -29,7 +29,7 @@ class FlowFacade:
|
|
| 29 |
def _calculate_gpu_duration(self, image: Image.Image, duration_seconds: float,
|
| 30 |
num_inference_steps: int, enable_prompt_expansion: bool, **kwargs) -> int:
|
| 31 |
BASE_FRAMES_HEIGHT_WIDTH = 81 * 832 * 624
|
| 32 |
-
BASE_STEP_DURATION = 8
|
| 33 |
|
| 34 |
resized_image = self.video_engine.resize_image(image)
|
| 35 |
width, height = resized_image.width, resized_image.height
|
|
@@ -39,15 +39,13 @@ class FlowFacade:
|
|
| 39 |
step_duration = BASE_STEP_DURATION * factor ** 1.5
|
| 40 |
total_duration = int(num_inference_steps) * step_duration
|
| 41 |
|
| 42 |
-
# Add overhead for first-time model loading
|
| 43 |
if not self.video_engine.is_loaded:
|
| 44 |
-
total_duration += 150
|
| 45 |
|
| 46 |
if enable_prompt_expansion:
|
| 47 |
total_duration += 40
|
| 48 |
|
| 49 |
-
# Conservative minimum: 240 seconds (4 minutes) for first run with all optimizations
|
| 50 |
-
# Subsequent runs will be much faster (~60-80s)
|
| 51 |
return max(int(total_duration), 240)
|
| 52 |
|
| 53 |
@spaces.GPU(duration=_calculate_gpu_duration)
|
|
@@ -136,8 +134,7 @@ class FlowFacade:
|
|
| 136 |
"quantization": quantization_type,
|
| 137 |
"optimizations": [
|
| 138 |
"Lightning LoRA (4-8 steps)",
|
| 139 |
-
f"{quantization_type} Quantization"
|
| 140 |
-
"AoT Compilation (if available)"
|
| 141 |
]
|
| 142 |
}
|
| 143 |
|
|
|
|
| 29 |
def _calculate_gpu_duration(self, image: Image.Image, duration_seconds: float,
|
| 30 |
num_inference_steps: int, enable_prompt_expansion: bool, **kwargs) -> int:
|
| 31 |
BASE_FRAMES_HEIGHT_WIDTH = 81 * 832 * 624
|
| 32 |
+
BASE_STEP_DURATION = 8
|
| 33 |
|
| 34 |
resized_image = self.video_engine.resize_image(image)
|
| 35 |
width, height = resized_image.width, resized_image.height
|
|
|
|
| 39 |
step_duration = BASE_STEP_DURATION * factor ** 1.5
|
| 40 |
total_duration = int(num_inference_steps) * step_duration
|
| 41 |
|
| 42 |
+
# Add overhead for first-time model loading
|
| 43 |
if not self.video_engine.is_loaded:
|
| 44 |
+
total_duration += 150
|
| 45 |
|
| 46 |
if enable_prompt_expansion:
|
| 47 |
total_duration += 40
|
| 48 |
|
|
|
|
|
|
|
| 49 |
return max(int(total_duration), 240)
|
| 50 |
|
| 51 |
@spaces.GPU(duration=_calculate_gpu_duration)
|
|
|
|
| 134 |
"quantization": quantization_type,
|
| 135 |
"optimizations": [
|
| 136 |
"Lightning LoRA (4-8 steps)",
|
| 137 |
+
f"{quantization_type} Quantization"
|
|
|
|
| 138 |
]
|
| 139 |
}
|
| 140 |
|
VideoEngine_optimized.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
"""
|
| 2 |
-
DeltaFlow - Video Engine (FP8
|
| 3 |
Ultra-fast Image-to-Video generation using Wan2.2-I2V-A14B
|
| 4 |
-
Features: Lightning LoRA + FP8 Quantization
|
| 5 |
-
~
|
| 6 |
"""
|
| 7 |
|
| 8 |
import warnings
|
|
@@ -31,8 +31,8 @@ from diffusers.utils.export_utils import export_to_video
|
|
| 31 |
|
| 32 |
class VideoEngine:
|
| 33 |
"""
|
| 34 |
-
Ultra-fast video generation with FP8 quantization
|
| 35 |
-
|
| 36 |
"""
|
| 37 |
|
| 38 |
MODEL_ID = "Wan-AI/Wan2.2-I2V-A14B-Diffusers"
|
|
@@ -75,7 +75,7 @@ class VideoEngine:
|
|
| 75 |
|
| 76 |
try:
|
| 77 |
print("=" * 60)
|
| 78 |
-
print("Loading Wan2.2 I2V Engine with FP8
|
| 79 |
print("=" * 60)
|
| 80 |
|
| 81 |
# Stage 1: Load base pipeline to CPU
|
|
@@ -131,7 +131,7 @@ class VideoEngine:
|
|
| 131 |
int8_weight_only
|
| 132 |
)
|
| 133 |
|
| 134 |
-
# Quantize text encoder (INT8)
|
| 135 |
quantize_(self.pipeline.text_encoder, int8_weight_only())
|
| 136 |
|
| 137 |
# Quantize transformers (FP8)
|
|
@@ -149,12 +149,10 @@ class VideoEngine:
|
|
| 149 |
print(f"⚠ Quantization failed: {e}")
|
| 150 |
raise RuntimeError("FP8 quantization required for this optimized version")
|
| 151 |
|
| 152 |
-
# Stage 4: AOTI
|
| 153 |
-
print("→ [4/5] Skipping AOTI
|
| 154 |
-
# AOTI can cause runtime errors with certain PyTorch versions
|
| 155 |
-
# FP8 quantization alone provides excellent performance
|
| 156 |
self.use_aoti = False
|
| 157 |
-
print("✓ Using FP8 quantization only
|
| 158 |
|
| 159 |
# Stage 5: Move to GPU and enable optimizations
|
| 160 |
print("→ [5/5] Moving to GPU...")
|
|
@@ -188,13 +186,10 @@ class VideoEngine:
|
|
| 188 |
pass
|
| 189 |
|
| 190 |
self.is_loaded = True
|
| 191 |
-
mode = "FP8 + AOTI" if self.use_aoti else "FP8 only"
|
| 192 |
print("=" * 60)
|
| 193 |
-
print(
|
| 194 |
print(f" • Device: {self.device}")
|
| 195 |
print(f" • Quantization: FP8 (50% memory reduction)")
|
| 196 |
-
print(f" • AOTI: {'Enabled (1.5-1.8x speedup)' if self.use_aoti else 'Disabled'}")
|
| 197 |
-
print(f" • Expected inference: {'~30-40s' if self.use_aoti else '~60-70s'}")
|
| 198 |
print("=" * 60)
|
| 199 |
|
| 200 |
except Exception as e:
|
|
@@ -264,7 +259,7 @@ class VideoEngine:
|
|
| 264 |
guidance_scale_2: float = 1.0,
|
| 265 |
seed: int = 42,
|
| 266 |
) -> str:
|
| 267 |
-
"""Generate video from image with FP8
|
| 268 |
if not self.is_loaded:
|
| 269 |
raise RuntimeError("VideoEngine not loaded. Call load_model() first.")
|
| 270 |
|
|
@@ -277,7 +272,6 @@ class VideoEngine:
|
|
| 277 |
print(f" • Resolution: {resized_image.width}x{resized_image.height}")
|
| 278 |
print(f" • Frames: {num_frames} ({duration_seconds}s @ {self.FIXED_FPS}fps)")
|
| 279 |
print(f" • Steps: {num_inference_steps}")
|
| 280 |
-
print(f" • Mode: {'FP8 + AOTI' if self.use_aoti else 'FP8 only'}")
|
| 281 |
|
| 282 |
# Memory cleanup
|
| 283 |
gc.collect()
|
|
|
|
| 1 |
"""
|
| 2 |
+
DeltaFlow - Video Engine (FP8 Optimized)
|
| 3 |
Ultra-fast Image-to-Video generation using Wan2.2-I2V-A14B
|
| 4 |
+
Features: Lightning LoRA + FP8 Quantization
|
| 5 |
+
~70-90s inference (vs 150s baseline)
|
| 6 |
"""
|
| 7 |
|
| 8 |
import warnings
|
|
|
|
| 31 |
|
| 32 |
class VideoEngine:
|
| 33 |
"""
|
| 34 |
+
Ultra-fast video generation with FP8 quantization.
|
| 35 |
+
70-90s inference time (compared to 150s baseline).
|
| 36 |
"""
|
| 37 |
|
| 38 |
MODEL_ID = "Wan-AI/Wan2.2-I2V-A14B-Diffusers"
|
|
|
|
| 75 |
|
| 76 |
try:
|
| 77 |
print("=" * 60)
|
| 78 |
+
print("Loading Wan2.2 I2V Engine with FP8 Quantization")
|
| 79 |
print("=" * 60)
|
| 80 |
|
| 81 |
# Stage 1: Load base pipeline to CPU
|
|
|
|
| 131 |
int8_weight_only
|
| 132 |
)
|
| 133 |
|
| 134 |
+
# Quantize text encoder (INT8)
|
| 135 |
quantize_(self.pipeline.text_encoder, int8_weight_only())
|
| 136 |
|
| 137 |
# Quantize transformers (FP8)
|
|
|
|
| 149 |
print(f"⚠ Quantization failed: {e}")
|
| 150 |
raise RuntimeError("FP8 quantization required for this optimized version")
|
| 151 |
|
| 152 |
+
# Stage 4: AOTI compilation (disabled for stability)
|
| 153 |
+
print("→ [4/5] Skipping AOTI compilation...")
|
|
|
|
|
|
|
| 154 |
self.use_aoti = False
|
| 155 |
+
print("✓ Using FP8 quantization only")
|
| 156 |
|
| 157 |
# Stage 5: Move to GPU and enable optimizations
|
| 158 |
print("→ [5/5] Moving to GPU...")
|
|
|
|
| 186 |
pass
|
| 187 |
|
| 188 |
self.is_loaded = True
|
|
|
|
| 189 |
print("=" * 60)
|
| 190 |
+
print("✓ VideoEngine Ready")
|
| 191 |
print(f" • Device: {self.device}")
|
| 192 |
print(f" • Quantization: FP8 (50% memory reduction)")
|
|
|
|
|
|
|
| 193 |
print("=" * 60)
|
| 194 |
|
| 195 |
except Exception as e:
|
|
|
|
| 259 |
guidance_scale_2: float = 1.0,
|
| 260 |
seed: int = 42,
|
| 261 |
) -> str:
|
| 262 |
+
"""Generate video from image with FP8 quantization."""
|
| 263 |
if not self.is_loaded:
|
| 264 |
raise RuntimeError("VideoEngine not loaded. Call load_model() first.")
|
| 265 |
|
|
|
|
| 272 |
print(f" • Resolution: {resized_image.width}x{resized_image.height}")
|
| 273 |
print(f" • Frames: {num_frames} ({duration_seconds}s @ {self.FIXED_FPS}fps)")
|
| 274 |
print(f" • Steps: {num_inference_steps}")
|
|
|
|
| 275 |
|
| 276 |
# Memory cleanup
|
| 277 |
gc.collect()
|
prompt_examples.py
CHANGED
|
@@ -1,20 +1,16 @@
|
|
| 1 |
PROMPT_EXAMPLES = {
|
| 2 |
-
"Fashion / Beauty
|
| 3 |
"Hair flows elegantly, model gazes confidently at camera, studio lighting highlights facial features, high-fashion editorial",
|
| 4 |
-
"Dramatic hair whip in slow motion, fierce eye contact with camera, wind
|
| 5 |
"Model's head tilts back with confidence, hair cascades like waterfall, powerful gaze intensifies, editorial vogue style",
|
| 6 |
"Explosive hair toss left to right, eyes lock onto camera seductively, strobe lighting flashes, high-energy fashion film",
|
| 7 |
-
"Hand gracefully sweeps through hair, fingers run through strands, sultry gaze follows movement, intimate beauty moment",
|
| 8 |
-
"Model touches hair delicately, hand brushes cheek softly, eyes sparkle with emotion, romantic close-up shot",
|
| 9 |
-
"Hair flips dramatically to one side, hand catches falling strands, confident smile emerges, dynamic fashion energy",
|
| 10 |
-
"Slow-motion head turn reveals profile, hand tucks hair behind ear elegantly, studio lights create dramatic shadows",
|
| 11 |
"Subtle wink emerges slowly, one eye closes playfully, lips curve into flirty smile, head tilts coyly, seductive charm",
|
| 12 |
"Radiant smile spreads across face, eyes sparkle with joy, cheeks lift naturally, warm genuine happiness radiates",
|
| 13 |
"Seductive gaze intensifies, eyes narrow alluringly, lips part slightly, slow blink follows, smoldering fashion intensity",
|
| 14 |
"Playful wink with knowing smile, eyebrow raises suggestively, head turns to camera confidently, charismatic energy",
|
| 15 |
],
|
| 16 |
|
| 17 |
-
"Portrait
|
| 18 |
"Subject turns head sharply to camera, eyes widen with surprise, hair swings dramatically, emotional close-up",
|
| 19 |
"Person laughs heartily, head tilts back, genuine joy radiates, natural lighting shifts warmly",
|
| 20 |
"Character looks around curiously, head movements follow unseen object, eyes track motion, engaging storytelling",
|
|
@@ -25,10 +21,14 @@ PROMPT_EXAMPLES = {
|
|
| 25 |
"Quick wink and friendly smile, eyebrows lift playfully, natural cheerful expression, approachable energy",
|
| 26 |
],
|
| 27 |
|
| 28 |
-
"Portrait
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
"Hand waves enthusiastically in front of camera, fingers spread wide, big smile accompanies gesture, friendly greeting",
|
| 30 |
"Subject raises hand to forehead dramatically, gasps in realization, eyes widen, theatrical reaction shot",
|
| 31 |
-
"Hand brushes hair back confidently, head tilts to side, playful wink follows, charismatic personality
|
| 32 |
"Person covers mouth while laughing, shoulders shake, hand gestures expressively, genuine candid moment",
|
| 33 |
"Subject points at camera playfully, leans forward, grin widens, interactive engaging energy",
|
| 34 |
"Hand touches chin thoughtfully, eyes look upward pondering, subtle head tilt, contemplative character study",
|
|
@@ -36,7 +36,7 @@ PROMPT_EXAMPLES = {
|
|
| 36 |
"Person adjusts glasses with one hand, smirks confidently, eyebrow raises, smart intellectual vibe",
|
| 37 |
],
|
| 38 |
|
| 39 |
-
"Animals - Lively": [
|
| 40 |
"Dog's head tilts adorably, ears perk up alert, tail wags enthusiastically, playful curious energy",
|
| 41 |
"Cat stretches luxuriously, yawns showing teeth, blinks slowly then gazes directly at camera, feline grace",
|
| 42 |
"Bird fluffs feathers, hops energetically, head bobs rhythmically, chirping motion implied, vibrant life",
|
|
@@ -47,7 +47,7 @@ PROMPT_EXAMPLES = {
|
|
| 47 |
"Squirrel's cheeks puff while chewing, tiny paws hold food, tail flicks nervously, adorable wild moment",
|
| 48 |
],
|
| 49 |
|
| 50 |
-
"Landscape / Nature": [
|
| 51 |
"Camera swoops down from sky to ground, clouds race overhead, wind rushes through trees violently, epic establishing shot",
|
| 52 |
"Waves crash powerfully against rocks, water explodes upward in slow motion, dramatic sunset colors intensify",
|
| 53 |
"Time-lapse effect: clouds rush across sky rapidly, shadows race across landscape, day transforms to golden hour",
|
|
@@ -58,7 +58,7 @@ PROMPT_EXAMPLES = {
|
|
| 58 |
"Ocean tide rushes in, foam spreads across sand, seagulls take flight, peaceful coastal rhythm",
|
| 59 |
],
|
| 60 |
|
| 61 |
-
"Animation / Cartoon": [
|
| 62 |
"Character jumps high with exaggerated stretch, lands with bouncy squash, eyes pop out comically, cartoony physics",
|
| 63 |
"Magical transformation sequence, sparkles explode everywhere, character spins rapidly, colors shift vibrantly, anime style",
|
| 64 |
"Character does double-take, eyes bulge hugely, jaw drops to floor, classic cartoon reaction shot",
|
|
@@ -69,7 +69,7 @@ PROMPT_EXAMPLES = {
|
|
| 69 |
"Fighting pose sequence: character winds up punch, muscles flex, impact lines radiate, shonen battle energy",
|
| 70 |
],
|
| 71 |
|
| 72 |
-
"Product / Object": [
|
| 73 |
"Product explodes into component parts, pieces float and rotate individually, reassembles dramatically, technical showcase",
|
| 74 |
"360-degree rotation accelerates into fast spin, dramatic lighting sweeps across surface, particle effects add premium feel",
|
| 75 |
"Camera dive-bombs toward product, extreme close-up reveals texture details, pulls back to reveal full item dramatically",
|
|
@@ -80,7 +80,7 @@ PROMPT_EXAMPLES = {
|
|
| 80 |
"Product materializes from particles, glowing assembly process, high-tech materialization effect, sci-fi showcase",
|
| 81 |
],
|
| 82 |
|
| 83 |
-
"Abstract / Artistic": [
|
| 84 |
"Explosion of colors radiates from center, patterns fractal outward infinitely, hypnotic kaleidoscope effect intensifies",
|
| 85 |
"Liquid paint flows and swirls violently, colors blend and separate, organic fluid simulation, mesmerizing motion",
|
| 86 |
"Geometric shapes shatter and reform, pieces scatter then snap back together, glitch art aesthetic",
|
|
|
|
| 1 |
PROMPT_EXAMPLES = {
|
| 2 |
+
"💃 Fashion / Beauty (Facial Only)": [
|
| 3 |
"Hair flows elegantly, model gazes confidently at camera, studio lighting highlights facial features, high-fashion editorial",
|
| 4 |
+
"Dramatic hair whip in slow motion, fierce eye contact with camera, wind effect, hair flies dynamically across frame",
|
| 5 |
"Model's head tilts back with confidence, hair cascades like waterfall, powerful gaze intensifies, editorial vogue style",
|
| 6 |
"Explosive hair toss left to right, eyes lock onto camera seductively, strobe lighting flashes, high-energy fashion film",
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
"Subtle wink emerges slowly, one eye closes playfully, lips curve into flirty smile, head tilts coyly, seductive charm",
|
| 8 |
"Radiant smile spreads across face, eyes sparkle with joy, cheeks lift naturally, warm genuine happiness radiates",
|
| 9 |
"Seductive gaze intensifies, eyes narrow alluringly, lips part slightly, slow blink follows, smoldering fashion intensity",
|
| 10 |
"Playful wink with knowing smile, eyebrow raises suggestively, head turns to camera confidently, charismatic energy",
|
| 11 |
],
|
| 12 |
|
| 13 |
+
"🎭 Portrait - Subtle Expressions": [
|
| 14 |
"Subject turns head sharply to camera, eyes widen with surprise, hair swings dramatically, emotional close-up",
|
| 15 |
"Person laughs heartily, head tilts back, genuine joy radiates, natural lighting shifts warmly",
|
| 16 |
"Character looks around curiously, head movements follow unseen object, eyes track motion, engaging storytelling",
|
|
|
|
| 21 |
"Quick wink and friendly smile, eyebrows lift playfully, natural cheerful expression, approachable energy",
|
| 22 |
],
|
| 23 |
|
| 24 |
+
"🙌 Portrait - Dynamic (Hands Visible Required)": [
|
| 25 |
+
"Hair flows elegantly, hand gracefully sweeps through strands, fingers run softly, sultry gaze follows movement, beauty close-up",
|
| 26 |
+
"Model touches hair delicately, hand brushes cheek softly, eyes sparkle with emotion, romantic intimate shot",
|
| 27 |
+
"Dramatic hair flip to side, hand catches falling strands, confident smile emerges, dynamic fashion energy",
|
| 28 |
+
"Slow-motion head turn reveals profile, hand tucks hair behind ear elegantly, studio lights create dramatic shadows",
|
| 29 |
"Hand waves enthusiastically in front of camera, fingers spread wide, big smile accompanies gesture, friendly greeting",
|
| 30 |
"Subject raises hand to forehead dramatically, gasps in realization, eyes widen, theatrical reaction shot",
|
| 31 |
+
"Hand brushes hair back confidently, head tilts to side, playful wink follows, charismatic personality shines",
|
| 32 |
"Person covers mouth while laughing, shoulders shake, hand gestures expressively, genuine candid moment",
|
| 33 |
"Subject points at camera playfully, leans forward, grin widens, interactive engaging energy",
|
| 34 |
"Hand touches chin thoughtfully, eyes look upward pondering, subtle head tilt, contemplative character study",
|
|
|
|
| 36 |
"Person adjusts glasses with one hand, smirks confidently, eyebrow raises, smart intellectual vibe",
|
| 37 |
],
|
| 38 |
|
| 39 |
+
"🐾 Animals - Lively": [
|
| 40 |
"Dog's head tilts adorably, ears perk up alert, tail wags enthusiastically, playful curious energy",
|
| 41 |
"Cat stretches luxuriously, yawns showing teeth, blinks slowly then gazes directly at camera, feline grace",
|
| 42 |
"Bird fluffs feathers, hops energetically, head bobs rhythmically, chirping motion implied, vibrant life",
|
|
|
|
| 47 |
"Squirrel's cheeks puff while chewing, tiny paws hold food, tail flicks nervously, adorable wild moment",
|
| 48 |
],
|
| 49 |
|
| 50 |
+
"🌄 Landscape / Nature": [
|
| 51 |
"Camera swoops down from sky to ground, clouds race overhead, wind rushes through trees violently, epic establishing shot",
|
| 52 |
"Waves crash powerfully against rocks, water explodes upward in slow motion, dramatic sunset colors intensify",
|
| 53 |
"Time-lapse effect: clouds rush across sky rapidly, shadows race across landscape, day transforms to golden hour",
|
|
|
|
| 58 |
"Ocean tide rushes in, foam spreads across sand, seagulls take flight, peaceful coastal rhythm",
|
| 59 |
],
|
| 60 |
|
| 61 |
+
"✨ Animation / Cartoon": [
|
| 62 |
"Character jumps high with exaggerated stretch, lands with bouncy squash, eyes pop out comically, cartoony physics",
|
| 63 |
"Magical transformation sequence, sparkles explode everywhere, character spins rapidly, colors shift vibrantly, anime style",
|
| 64 |
"Character does double-take, eyes bulge hugely, jaw drops to floor, classic cartoon reaction shot",
|
|
|
|
| 69 |
"Fighting pose sequence: character winds up punch, muscles flex, impact lines radiate, shonen battle energy",
|
| 70 |
],
|
| 71 |
|
| 72 |
+
"📦 Product / Object": [
|
| 73 |
"Product explodes into component parts, pieces float and rotate individually, reassembles dramatically, technical showcase",
|
| 74 |
"360-degree rotation accelerates into fast spin, dramatic lighting sweeps across surface, particle effects add premium feel",
|
| 75 |
"Camera dive-bombs toward product, extreme close-up reveals texture details, pulls back to reveal full item dramatically",
|
|
|
|
| 80 |
"Product materializes from particles, glowing assembly process, high-tech materialization effect, sci-fi showcase",
|
| 81 |
],
|
| 82 |
|
| 83 |
+
"🎨 Abstract / Artistic": [
|
| 84 |
"Explosion of colors radiates from center, patterns fractal outward infinitely, hypnotic kaleidoscope effect intensifies",
|
| 85 |
"Liquid paint flows and swirls violently, colors blend and separate, organic fluid simulation, mesmerizing motion",
|
| 86 |
"Geometric shapes shatter and reform, pieces scatter then snap back together, glitch art aesthetic",
|
ui_manager.py
CHANGED
|
@@ -40,6 +40,12 @@ class UIManager:
|
|
| 40 |
height=320
|
| 41 |
)
|
| 42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
prompt_input = gr.Textbox(
|
| 44 |
label="Motion Instruction",
|
| 45 |
placeholder="Describe camera movements (zoom, pan, orbit) and subject actions (head turn, hair flow, expression change). Be specific and cinematic! Example: 'Camera slowly zooms in, subject's eyes sparkle, hair flows gently in wind'",
|
|
@@ -51,24 +57,24 @@ class UIManager:
|
|
| 51 |
category_dropdown = gr.Dropdown(
|
| 52 |
choices=list(PROMPT_EXAMPLES.keys()),
|
| 53 |
label="💡 Quick Prompt Category",
|
| 54 |
-
value="Fashion / Beauty
|
| 55 |
interactive=True
|
| 56 |
)
|
| 57 |
|
| 58 |
example_dropdown = gr.Dropdown(
|
| 59 |
-
choices=PROMPT_EXAMPLES["Fashion / Beauty
|
| 60 |
label="Example Prompts (click to use)",
|
| 61 |
-
value=None,
|
| 62 |
interactive=True
|
| 63 |
)
|
| 64 |
|
| 65 |
# Quality tips banner (blue)
|
| 66 |
gr.HTML("""
|
| 67 |
<div class="quality-banner">
|
| 68 |
-
<strong>💡
|
| 69 |
-
• <strong
|
| 70 |
-
• <strong
|
| 71 |
-
• <strong
|
| 72 |
</div>
|
| 73 |
""")
|
| 74 |
|
|
@@ -131,12 +137,14 @@ class UIManager:
|
|
| 131 |
value=42,
|
| 132 |
precision=0,
|
| 133 |
minimum=0,
|
| 134 |
-
maximum=2147483647
|
|
|
|
| 135 |
)
|
| 136 |
|
| 137 |
randomize_seed = gr.Checkbox(
|
| 138 |
label="Randomize Seed",
|
| 139 |
-
value=True
|
|
|
|
| 140 |
)
|
| 141 |
|
| 142 |
enable_ai_prompt = gr.Checkbox(
|
|
@@ -186,8 +194,10 @@ class UIManager:
|
|
| 186 |
gr.HTML("""
|
| 187 |
<div class="footer">
|
| 188 |
<p style="font-size: 0.9rem;">
|
| 189 |
-
<strong>Powered by:</strong>
|
| 190 |
-
Wan2.2-I2V-A14B
|
|
|
|
|
|
|
| 191 |
</p>
|
| 192 |
</div>
|
| 193 |
""")
|
|
@@ -198,10 +208,24 @@ class UIManager:
|
|
| 198 |
def fill_prompt(selected_example):
|
| 199 |
return selected_example if selected_example else ""
|
| 200 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 201 |
category_dropdown.change(fn=update_examples, inputs=[category_dropdown],
|
| 202 |
outputs=[example_dropdown])
|
| 203 |
example_dropdown.change(fn=fill_prompt, inputs=[example_dropdown],
|
| 204 |
outputs=[prompt_input])
|
|
|
|
|
|
|
| 205 |
|
| 206 |
generate_btn.click(
|
| 207 |
fn=self._handle_generation,
|
|
|
|
| 40 |
height=320
|
| 41 |
)
|
| 42 |
|
| 43 |
+
resolution_info = gr.Markdown(
|
| 44 |
+
value="",
|
| 45 |
+
visible=False,
|
| 46 |
+
elem_classes="info-text"
|
| 47 |
+
)
|
| 48 |
+
|
| 49 |
prompt_input = gr.Textbox(
|
| 50 |
label="Motion Instruction",
|
| 51 |
placeholder="Describe camera movements (zoom, pan, orbit) and subject actions (head turn, hair flow, expression change). Be specific and cinematic! Example: 'Camera slowly zooms in, subject's eyes sparkle, hair flows gently in wind'",
|
|
|
|
| 57 |
category_dropdown = gr.Dropdown(
|
| 58 |
choices=list(PROMPT_EXAMPLES.keys()),
|
| 59 |
label="💡 Quick Prompt Category",
|
| 60 |
+
value="💃 Fashion / Beauty (Facial Only)",
|
| 61 |
interactive=True
|
| 62 |
)
|
| 63 |
|
| 64 |
example_dropdown = gr.Dropdown(
|
| 65 |
+
choices=PROMPT_EXAMPLES["💃 Fashion / Beauty (Facial Only)"],
|
| 66 |
label="Example Prompts (click to use)",
|
| 67 |
+
value=None,
|
| 68 |
interactive=True
|
| 69 |
)
|
| 70 |
|
| 71 |
# Quality tips banner (blue)
|
| 72 |
gr.HTML("""
|
| 73 |
<div class="quality-banner">
|
| 74 |
+
<strong>💡 Choose the Right Prompt Category:</strong><br>
|
| 75 |
+
• <strong>💃 Facial Only:</strong> Safe for headshots and portraits without visible hands<br>
|
| 76 |
+
• <strong>🙌 Hands Visible Required:</strong> Only use if hands are fully visible in your image (prevents artifacts)<br>
|
| 77 |
+
• <strong>🌄 Scenery/Objects:</strong> For landscapes, products, and abstract content
|
| 78 |
</div>
|
| 79 |
""")
|
| 80 |
|
|
|
|
| 137 |
value=42,
|
| 138 |
precision=0,
|
| 139 |
minimum=0,
|
| 140 |
+
maximum=2147483647,
|
| 141 |
+
info="Use same seed for reproducible results"
|
| 142 |
)
|
| 143 |
|
| 144 |
randomize_seed = gr.Checkbox(
|
| 145 |
label="Randomize Seed",
|
| 146 |
+
value=True,
|
| 147 |
+
info="Generate different results each time"
|
| 148 |
)
|
| 149 |
|
| 150 |
enable_ai_prompt = gr.Checkbox(
|
|
|
|
| 194 |
gr.HTML("""
|
| 195 |
<div class="footer">
|
| 196 |
<p style="font-size: 0.9rem;">
|
| 197 |
+
<strong>Powered by:</strong><br>
|
| 198 |
+
<a href="https://huggingface.co/Wan-AI/Wan2.2-I2V-A14B-Diffusers" target="_blank" style="color: #6366f1; text-decoration: none;">Wan2.2-I2V-A14B</a> (Wan-AI, optimized by <a href="https://huggingface.co/cbensimon" target="_blank" style="color: #6366f1; text-decoration: none;">cbensimon</a>)
|
| 199 |
+
· Lightning LoRA (<a href="https://huggingface.co/Kijai/WanVideo_comfy" target="_blank" style="color: #6366f1; text-decoration: none;">Lightx2v</a>)
|
| 200 |
+
· <a href="https://huggingface.co/Qwen/Qwen2.5-0.5B-Instruct" target="_blank" style="color: #6366f1; text-decoration: none;">Qwen2.5-0.5B</a>
|
| 201 |
</p>
|
| 202 |
</div>
|
| 203 |
""")
|
|
|
|
| 208 |
def fill_prompt(selected_example):
|
| 209 |
return selected_example if selected_example else ""
|
| 210 |
|
| 211 |
+
def show_resolution_info(image):
|
| 212 |
+
if image is None:
|
| 213 |
+
return "", False
|
| 214 |
+
|
| 215 |
+
from PIL import Image
|
| 216 |
+
original_w, original_h = image.size
|
| 217 |
+
resized_image = self.facade.video_engine.resize_image(image)
|
| 218 |
+
output_w, output_h = resized_image.width, resized_image.height
|
| 219 |
+
|
| 220 |
+
info = f"**📐 Resolution:** Input: {original_w}×{original_h} → Output: {output_w}×{output_h}"
|
| 221 |
+
return info, True
|
| 222 |
+
|
| 223 |
category_dropdown.change(fn=update_examples, inputs=[category_dropdown],
|
| 224 |
outputs=[example_dropdown])
|
| 225 |
example_dropdown.change(fn=fill_prompt, inputs=[example_dropdown],
|
| 226 |
outputs=[prompt_input])
|
| 227 |
+
image_input.change(fn=show_resolution_info, inputs=[image_input],
|
| 228 |
+
outputs=[resolution_info, resolution_info])
|
| 229 |
|
| 230 |
generate_btn.click(
|
| 231 |
fn=self._handle_generation,
|