Fabrice-TIERCELIN commited on
Commit
b8cffc5
·
verified ·
1 Parent(s): 2986897

Parameters

Browse files
Files changed (1) hide show
  1. app.py +141 -2
app.py CHANGED
@@ -164,6 +164,14 @@ from controlnet_aux import CannyDetector, MidasDetector
164
  from dwpose import DwposeDetector
165
 
166
 
 
 
 
 
 
 
 
 
167
  # HuggingFace Hub defaults
168
  DEFAULT_REPO_ID = "Lightricks/LTX-2"
169
  DEFAULT_GEMMA_REPO_ID = "unsloth/gemma-3-12b-it-qat-bnb-4bit"
@@ -1091,6 +1099,14 @@ class CameraDropdown(gr.HTML):
1091
 
1092
  def generate_video_example(input_image, prompt, camera_lora, resolution, radioanimated_mode, input_video, input_audio, progress=gr.Progress(track_tqdm=True)):
1093
 
 
 
 
 
 
 
 
 
1094
  w, h = apply_resolution(resolution)
1095
 
1096
  with timer(f'generating with video path:{input_video} with duration:{duration} and LoRA:{camera_lora} in {w}x{h}'):
@@ -2249,9 +2265,131 @@ with gr.Blocks(title="LTX-2 Video Distilled 🎥🔈") as demo:
2249
  ],
2250
  outputs=[output_video]
2251
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2252
 
2253
  gr.Examples(
2254
- elem_id="default_examples",
2255
  examples=[
2256
  [
2257
  "supergirl-2.png",
@@ -2321,7 +2459,8 @@ with gr.Blocks(title="LTX-2 Video Distilled ����🔈") as demo:
2321
  inputs=[input_image, prompt_ui, camera_ui, resolution_ui, radioanimated_mode, input_video, audio_input],
2322
  outputs = [output_video],
2323
  label="Examples",
2324
- cache_examples=True,
 
2325
  )
2326
 
2327
 
 
164
  from dwpose import DwposeDetector
165
 
166
 
167
+ input_image_debug_value = [None]
168
+ input_video_debug_value = [None]
169
+ prompt_debug_value = [None]
170
+ total_second_length_debug_value = [None]
171
+ resolution_debug_value = [None]
172
+ factor_debug_value = [None]
173
+ allocation_time_debug_value = [None]
174
+
175
  # HuggingFace Hub defaults
176
  DEFAULT_REPO_ID = "Lightricks/LTX-2"
177
  DEFAULT_GEMMA_REPO_ID = "unsloth/gemma-3-12b-it-qat-bnb-4bit"
 
1099
 
1100
  def generate_video_example(input_image, prompt, camera_lora, resolution, radioanimated_mode, input_video, input_audio, progress=gr.Progress(track_tqdm=True)):
1101
 
1102
+ if input_image_debug_value[0] is not None or end_image_debug_value[0] is not None or prompt_debug_value[0] is not None or total_second_length_debug_value[0] is not None or allocation_time_debug_value[0] is not None or resolution_debug_value[0] is not None or factor_debug_value[0] is not None:
1103
+ input_image = input_image_debug_value[0]
1104
+ input_video = input_video_debug_value[0]
1105
+ prompt = prompt_debug_value[0]
1106
+ duration = total_second_length_debug_value[0]
1107
+ resolution = resolution_debug_value[0]
1108
+ allocation_time = allocation_time_debug_value[0]
1109
+
1110
  w, h = apply_resolution(resolution)
1111
 
1112
  with timer(f'generating with video path:{input_video} with duration:{duration} and LoRA:{camera_lora} in {w}x{h}'):
 
2265
  ],
2266
  outputs=[output_video]
2267
  )
2268
+
2269
+ with gr.Row(elem_id="default_examples"):
2270
+ gr.Examples(
2271
+ examples=[
2272
+ [
2273
+ "supergirl-2.png",
2274
+ "A fuzzy puppet superhero character resembling a female puppet with blonde hair and a blue superhero suit sleeping in bed and just waking up, she gradually gets up, rubbing her eyes and looking at her dog that just popped on the bed. the scene feels chaotic, comedic, and emotional with expressive puppet reactions, cinematic lighting, smooth camera motion, shallow depth of field, and high-quality puppet-style animation",
2275
+ "Static",
2276
+ "16:9",
2277
+ "Image-to-Video",
2278
+ None,
2279
+ "supergirl.m4a"
2280
+ ],
2281
+ [
2282
+ "supergirl.png",
2283
+ "A fuzzy puppet superhero character resembling a female puppet with blonde hair and a blue superhero suit stands inside an icy cave made of frozen walls and icicles, she looks panicked and frantic, rapidly turning her head left and right and scanning the cave while waving her arms and shouting angrily and desperately, mouthing the words “where the hell is my dog,” her movements exaggerated and puppet-like with high energy and urgency, suddenly a second puppet dog bursts into frame from the side, jumping up excitedly and tackling her affectionately while licking her face repeatedly, she freezes in surprise and then breaks into relief and laughter as the dog continues licking her, the scene feels chaotic, comedic, and emotional with expressive puppet reactions, cinematic lighting, smooth camera motion, shallow depth of field, and high-quality puppet-style animation",
2284
+ "No LoRA",
2285
+ "16:9",
2286
+ "Image-to-Video",
2287
+ None,
2288
+ None,
2289
+ ],
2290
+ [
2291
+ "clay.png",
2292
+ "a character doing a tiktok dance by moving their heads side to side with dramatic lighting and cinematic effects and singing",
2293
+ "No LoRA",
2294
+ "9:16",
2295
+ "Motion Control",
2296
+ "tiktok.mp4",
2297
+ None,
2298
+ ],
2299
+ [
2300
+ "paint.png",
2301
+ "a character doing a tiktok dance by moving their heads side to side with dramatic lighting and cinematic effects and singing",
2302
+ "No LoRA",
2303
+ "9:16",
2304
+ "Motion Control",
2305
+ "tiktok.mp4",
2306
+ None,
2307
+ ],
2308
+ [
2309
+ "highland.png",
2310
+ "Realistic POV selfie-style video in a snowy, foggy field. Two shaggy Highland cows with long curved horns stand ahead. The camera is handheld and slightly shaky. The woman filming talks nervously and excitedly in a vlog tone: \"Oh my god guys… look how big those horns are… I’m kinda scared.\" The cow on the left walks toward the camera in a cute, bouncy, hopping way, curious and gentle. Snow crunches under its hooves, breath visible in the cold air. The horns look massive from the POV. As the cow gets very close, its wet nose with slight dripping fills part of the frame. She laughs nervously but reaches out and pets the cow. The cow makes deep, soft, interesting mooing and snorting sounds, calm and friendly. Ultra-realistic, natural lighting, immersive audio, documentary-style realism.",
2311
+ "No LoRA",
2312
+ "16:9",
2313
+ "Image-to-Video",
2314
+ None,
2315
+ None,
2316
+ ],
2317
+ [
2318
+ "wednesday.png",
2319
+ "A cinematic dolly out of Wednesday Addams frozen mid-dance on a dark, blue-lit ballroom floor as students move indistinctly behind her, their footsteps and muffled music reduced to a distant, underwater thrum; the audio foregrounds her steady breathing and the faint rustle of fabric as she slowly raises one arm, never breaking eye contact with the camera, then after a deliberately long silence she speaks in a flat, dry, perfectly controlled voice, “I don’t dance… I vibe code,” each word crisp and unemotional, followed by an abrupt cutoff of her voice as the background sound swells slightly, reinforcing the deadpan humor, with precise lip sync, minimal facial movement, stark gothic lighting, and cinematic realism.",
2320
+ "Zoom Out",
2321
+ "16:9",
2322
+ "Image-to-Video",
2323
+ None,
2324
+ None,
2325
+ ],
2326
+ [
2327
+ "astronaut.png",
2328
+ "An astronaut hatches from a fragile egg on the surface of the Moon, the shell cracking and peeling apart in gentle low-gravity motion. Fine lunar dust lifts and drifts outward with each movement, floating in slow arcs before settling back onto the ground. The astronaut pushes free in a deliberate, weightless motion, small fragments of the egg tumbling and spinning through the air. In the background, the deep darkness of space subtly shifts as stars glide with the camera's movement, emphasizing vast depth and scale. The camera performs a smooth, cinematic slow push-in, with natural parallax between the foreground dust, the astronaut, and the distant starfield. Ultra-realistic detail, physically accurate low-gravity motion, cinematic lighting, and a breath-taking, movie-like shot.",
2329
+ "Static",
2330
+ "1:1",
2331
+ "Image-to-Video",
2332
+ None,
2333
+ None,
2334
+ ],
2335
+ ],
2336
+ fn=generate_video_example,
2337
+ inputs=[input_image, prompt_ui, camera_ui, resolution_ui, radioanimated_mode, input_video, audio_input],
2338
+ outputs = [output_video],
2339
+ cache_examples=True,
2340
+ )
2341
+ prompt_debug=gr.Textbox(label="Prompt Debug")
2342
+ input_image_debug=gr.Image(type="pil", label="Image Debug")
2343
+ end_image_debug=gr.Image(type="pil", label="End Image Debug")
2344
+ total_second_length_debug=gr.Slider(label="Duration Debug", minimum=1, maximum=120, value=5, step=0.1)
2345
+ resolution_debug = gr.Dropdown([
2346
+ ["400,000 px", 400000],
2347
+ ["465,920 px", 465920],
2348
+ ["495,616 px", 495616],
2349
+ ["500,000 px", 500000],
2350
+ ["600,000 px", 600000],
2351
+ ["700,000 px", 700000],
2352
+ ["800,000 px", 800000],
2353
+ ["900,000 px", 900000],
2354
+ ["1,000,000 px", 1000000],
2355
+ ["1,100,000 px", 1100000],
2356
+ ["1,200,000 px", 1200000],
2357
+ ["1,300,000 px", 1300000],
2358
+ ["1,400,000 px", 1400000],
2359
+ ["1,500,000 px", 1500000]
2360
+ ], value=500000, label="Resolution Debug")
2361
+ factor_debug=gr.Slider(label="Factor Debug", minimum=1, maximum=100, value=3.2, step=0.1)
2362
+ allocation_time_debug=gr.Slider(label="Allocation Debug", minimum=1, maximum=60 * 20, value=720, step=1)
2363
+
2364
+ def handle_field_debug_change(
2365
+ input_image_debug_data,
2366
+ input_video_debug_data,
2367
+ prompt_debug_data,
2368
+ total_second_length_debug_data,
2369
+ resolution_debug_data,
2370
+ factor_debug_data,
2371
+ allocation_time_debug_data
2372
+ ):
2373
+ input_image_debug_value[0] = input_image_debug_data
2374
+ input_video_debug_value[0] = input_video_debug_data
2375
+ prompt_debug_value[0] = prompt_debug_data
2376
+ total_second_length_debug_value[0] = total_second_length_debug_data
2377
+ resolution_debug_value[0] = resolution_debug_data
2378
+ factor_debug_value[0] = factor_debug_data
2379
+ allocation_time_debug_value[0] = allocation_time_debug_data
2380
+ return []
2381
+
2382
+ inputs_debug=[input_image_debug, input_video_debug, prompt_debug, total_second_length_debug, resolution_debug, factor_debug, allocation_time_debug]
2383
+
2384
+ input_image_debug.upload(fn=handle_field_debug_change, inputs=inputs_debug, outputs=[])
2385
+ input_video_debug.upload(fn=handle_field_debug_change, inputs=inputs_debug, outputs=[])
2386
+ prompt_debug.change(fn=handle_field_debug_change, inputs=inputs_debug, outputs=[])
2387
+ total_second_length_debug.change(fn=handle_field_debug_change, inputs=inputs_debug, outputs=[])
2388
+ resolution_debug.change(fn=handle_field_debug_change, inputs=inputs_debug, outputs=[])
2389
+ factor_debug.change(fn=handle_field_debug_change, inputs=inputs_debug, outputs=[])
2390
+ allocation_time_debug.change(fn=handle_field_debug_change, inputs=inputs_debug, outputs=[])
2391
 
2392
  gr.Examples(
 
2393
  examples=[
2394
  [
2395
  "supergirl-2.png",
 
2459
  inputs=[input_image, prompt_ui, camera_ui, resolution_ui, radioanimated_mode, input_video, audio_input],
2460
  outputs = [output_video],
2461
  label="Examples",
2462
+ run_on_click=False,
2463
+ cache_examples=False,
2464
  )
2465
 
2466