dagloop5 commited on
Commit
066348b
·
verified ·
1 Parent(s): cf88763

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -611
app.py DELETED
@@ -1,611 +0,0 @@
1
- import os
2
- import subprocess
3
- import sys
4
-
5
- # Disable torch.compile / dynamo before any torch import
6
- os.environ["TORCH_COMPILE_DISABLE"] = "1"
7
- os.environ["TORCHDYNAMO_DISABLE"] = "1"
8
-
9
- # Install xformers for memory-efficient attention
10
- subprocess.run([sys.executable, "-m", "pip", "install", "xformers==0.0.32.post2", "--no-build-isolation"], check=False)
11
-
12
- # Clone LTX-2 repo and install packages
13
- LTX_REPO_URL = "https://github.com/Lightricks/LTX-2.git"
14
- LTX_REPO_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), "LTX-2")
15
-
16
- if not os.path.exists(LTX_REPO_DIR):
17
- print(f"Cloning {LTX_REPO_URL}...")
18
- subprocess.run(["git", "clone", "--depth", "1", LTX_REPO_URL, LTX_REPO_DIR], check=True)
19
-
20
- print("Installing ltx-core and ltx-pipelines from cloned repo...")
21
- subprocess.run(
22
- [sys.executable, "-m", "pip", "install", "--force-reinstall", "--no-deps", "-e",
23
- os.path.join(LTX_REPO_DIR, "packages", "ltx-core"),
24
- "-e", os.path.join(LTX_REPO_DIR, "packages", "ltx-pipelines")],
25
- check=True,
26
- )
27
-
28
- sys.path.insert(0, os.path.join(LTX_REPO_DIR, "packages", "ltx-pipelines", "src"))
29
- sys.path.insert(0, os.path.join(LTX_REPO_DIR, "packages", "ltx-core", "src"))
30
-
31
- import logging
32
- import random
33
- import tempfile
34
- from pathlib import Path
35
-
36
- import torch
37
- torch._dynamo.config.suppress_errors = True
38
- torch._dynamo.config.disable = True
39
-
40
- import spaces
41
- import gradio as gr
42
- import numpy as np
43
- from huggingface_hub import hf_hub_download, snapshot_download
44
-
45
- from ltx_core.components.diffusion_steps import EulerDiffusionStep
46
- from ltx_core.components.noisers import GaussianNoiser
47
- from ltx_core.model.audio_vae import encode_audio as vae_encode_audio
48
- from ltx_core.model.upsampler import upsample_video
49
- from ltx_core.model.video_vae import TilingConfig, get_video_chunks_number, decode_video as vae_decode_video
50
- # >>> ADD these imports (place immediately after your video_vae import)
51
- from ltx_core.loader import LoraPathStrengthAndSDOps, LTXV_LORA_COMFY_RENAMING_MAP
52
- from ltx_core.quantization import QuantizationPolicy
53
- from ltx_core.types import Audio, AudioLatentShape, VideoPixelShape
54
- from ltx_pipelines.distilled import DistilledPipeline
55
- from ltx_pipelines.utils import euler_denoising_loop
56
- from ltx_pipelines.utils.args import ImageConditioningInput
57
- from ltx_pipelines.utils.constants import DISTILLED_SIGMA_VALUES, STAGE_2_DISTILLED_SIGMA_VALUES
58
- from ltx_pipelines.utils.helpers import (
59
- cleanup_memory,
60
- combined_image_conditionings,
61
- denoise_video_only,
62
- encode_prompts,
63
- simple_denoising_func,
64
- )
65
- from ltx_pipelines.utils.media_io import decode_audio_from_file, encode_video
66
-
67
- # Force-patch xformers attention into the LTX attention module.
68
- from ltx_core.model.transformer import attention as _attn_mod
69
- print(f"[ATTN] Before patch: memory_efficient_attention={_attn_mod.memory_efficient_attention}")
70
- try:
71
- from xformers.ops import memory_efficient_attention as _mea
72
- _attn_mod.memory_efficient_attention = _mea
73
- print(f"[ATTN] After patch: memory_efficient_attention={_attn_mod.memory_efficient_attention}")
74
- except Exception as e:
75
- print(f"[ATTN] xformers patch FAILED: {type(e).__name__}: {e}")
76
-
77
- logging.getLogger().setLevel(logging.INFO)
78
-
79
- MAX_SEED = np.iinfo(np.int32).max
80
- DEFAULT_PROMPT = (
81
- "An astronaut hatches from a fragile egg on the surface of the Moon, "
82
- "the shell cracking and peeling apart in gentle low-gravity motion. "
83
- "Fine lunar dust lifts and drifts outward with each movement, floating "
84
- "in slow arcs before settling back onto the ground."
85
- )
86
- DEFAULT_FRAME_RATE = 24.0
87
-
88
- # Resolution presets: (width, height)
89
- RESOLUTIONS = {
90
- "high": {"16:9": (1536, 1024), "9:16": (1024, 1536), "1:1": (1024, 1024)},
91
- "low": {"16:9": (768, 512), "9:16": (512, 768), "1:1": (768, 768)},
92
- }
93
-
94
-
95
- class LTX23DistilledA2VPipeline(DistilledPipeline):
96
- """DistilledPipeline with optional audio conditioning."""
97
-
98
- def __call__(
99
- self,
100
- prompt: str,
101
- seed: int,
102
- height: int,
103
- width: int,
104
- num_frames: int,
105
- frame_rate: float,
106
- images: list[ImageConditioningInput],
107
- audio_path: str | None = None,
108
- tiling_config: TilingConfig | None = None,
109
- enhance_prompt: bool = False,
110
- ):
111
- # Standard path when no audio input is provided.
112
- print(prompt)
113
- if audio_path is None:
114
- return super().__call__(
115
- prompt=prompt,
116
- seed=seed,
117
- height=height,
118
- width=width,
119
- num_frames=num_frames,
120
- frame_rate=frame_rate,
121
- images=images,
122
- tiling_config=tiling_config,
123
- enhance_prompt=enhance_prompt,
124
- )
125
-
126
- generator = torch.Generator(device=self.device).manual_seed(seed)
127
- noiser = GaussianNoiser(generator=generator)
128
- stepper = EulerDiffusionStep()
129
- dtype = torch.bfloat16
130
-
131
- (ctx_p,) = encode_prompts(
132
- [prompt],
133
- self.model_ledger,
134
- enhance_first_prompt=enhance_prompt,
135
- enhance_prompt_image=images[0].path if len(images) > 0 else None,
136
- )
137
- video_context, audio_context = ctx_p.video_encoding, ctx_p.audio_encoding
138
-
139
- video_duration = num_frames / frame_rate
140
- decoded_audio = decode_audio_from_file(audio_path, self.device, 0.0, video_duration)
141
- if decoded_audio is None:
142
- raise ValueError(f"Could not extract audio stream from {audio_path}")
143
-
144
- encoded_audio_latent = vae_encode_audio(decoded_audio, self.model_ledger.audio_encoder())
145
- audio_shape = AudioLatentShape.from_duration(batch=1, duration=video_duration, channels=8, mel_bins=16)
146
- expected_frames = audio_shape.frames
147
- actual_frames = encoded_audio_latent.shape[2]
148
-
149
- if actual_frames > expected_frames:
150
- encoded_audio_latent = encoded_audio_latent[:, :, :expected_frames, :]
151
- elif actual_frames < expected_frames:
152
- pad = torch.zeros(
153
- encoded_audio_latent.shape[0],
154
- encoded_audio_latent.shape[1],
155
- expected_frames - actual_frames,
156
- encoded_audio_latent.shape[3],
157
- device=encoded_audio_latent.device,
158
- dtype=encoded_audio_latent.dtype,
159
- )
160
- encoded_audio_latent = torch.cat([encoded_audio_latent, pad], dim=2)
161
-
162
- video_encoder = self.model_ledger.video_encoder()
163
- transformer = self.model_ledger.transformer()
164
- stage_1_sigmas = torch.tensor(DISTILLED_SIGMA_VALUES, device=self.device)
165
-
166
- def denoising_loop(sigmas, video_state, audio_state, stepper):
167
- return euler_denoising_loop(
168
- sigmas=sigmas,
169
- video_state=video_state,
170
- audio_state=audio_state,
171
- stepper=stepper,
172
- denoise_fn=simple_denoising_func(
173
- video_context=video_context,
174
- audio_context=audio_context,
175
- transformer=transformer,
176
- ),
177
- )
178
-
179
- stage_1_output_shape = VideoPixelShape(
180
- batch=1,
181
- frames=num_frames,
182
- width=width // 2,
183
- height=height // 2,
184
- fps=frame_rate,
185
- )
186
- stage_1_conditionings = combined_image_conditionings(
187
- images=images,
188
- height=stage_1_output_shape.height,
189
- width=stage_1_output_shape.width,
190
- video_encoder=video_encoder,
191
- dtype=dtype,
192
- device=self.device,
193
- )
194
- video_state = denoise_video_only(
195
- output_shape=stage_1_output_shape,
196
- conditionings=stage_1_conditionings,
197
- noiser=noiser,
198
- sigmas=stage_1_sigmas,
199
- stepper=stepper,
200
- denoising_loop_fn=denoising_loop,
201
- components=self.pipeline_components,
202
- dtype=dtype,
203
- device=self.device,
204
- initial_audio_latent=encoded_audio_latent,
205
- )
206
-
207
- torch.cuda.synchronize()
208
- cleanup_memory()
209
-
210
- upscaled_video_latent = upsample_video(
211
- latent=video_state.latent[:1],
212
- video_encoder=video_encoder,
213
- upsampler=self.model_ledger.spatial_upsampler(),
214
- )
215
- stage_2_sigmas = torch.tensor(STAGE_2_DISTILLED_SIGMA_VALUES, device=self.device)
216
- stage_2_output_shape = VideoPixelShape(batch=1, frames=num_frames, width=width, height=height, fps=frame_rate)
217
- stage_2_conditionings = combined_image_conditionings(
218
- images=images,
219
- height=stage_2_output_shape.height,
220
- width=stage_2_output_shape.width,
221
- video_encoder=video_encoder,
222
- dtype=dtype,
223
- device=self.device,
224
- )
225
- video_state = denoise_video_only(
226
- output_shape=stage_2_output_shape,
227
- conditionings=stage_2_conditionings,
228
- noiser=noiser,
229
- sigmas=stage_2_sigmas,
230
- stepper=stepper,
231
- denoising_loop_fn=denoising_loop,
232
- components=self.pipeline_components,
233
- dtype=dtype,
234
- device=self.device,
235
- noise_scale=stage_2_sigmas[0],
236
- initial_video_latent=upscaled_video_latent,
237
- initial_audio_latent=encoded_audio_latent,
238
- )
239
-
240
- torch.cuda.synchronize()
241
- del transformer
242
- del video_encoder
243
- cleanup_memory()
244
-
245
- decoded_video = vae_decode_video(
246
- video_state.latent,
247
- self.model_ledger.video_decoder(),
248
- tiling_config,
249
- generator,
250
- )
251
- original_audio = Audio(
252
- waveform=decoded_audio.waveform.squeeze(0),
253
- sampling_rate=decoded_audio.sampling_rate,
254
- )
255
- return decoded_video, original_audio
256
-
257
-
258
- # Model repos
259
- LTX_MODEL_REPO = "Lightricks/LTX-2.3"
260
- GEMMA_REPO ="rahul7star/gemma-3-12b-it-heretic"
261
-
262
-
263
- # Download model checkpoints
264
- print("=" * 80)
265
- print("Downloading LTX-2.3 distilled model + Gemma...")
266
- print("=" * 80)
267
-
268
- checkpoint_path = hf_hub_download(repo_id=LTX_MODEL_REPO, filename="ltx-2.3-22b-distilled.safetensors")
269
- spatial_upsampler_path = hf_hub_download(repo_id=LTX_MODEL_REPO, filename="ltx-2.3-spatial-upscaler-x2-1.0.safetensors")
270
- gemma_root = snapshot_download(repo_id=GEMMA_REPO)
271
-
272
- # >>> ADD: download and prepare LoRA descriptor
273
- print("Downloading LoRA for this Space (dagloop5/LoRA:LoRA.safetensors)...")
274
- lora_path = hf_hub_download(repo_id="dagloop5/LoRA", filename="LoRA.safetensors")
275
- # Create a descriptor object that the LTX loader expects.
276
- # initial strength is set to 1.0; we'll mutate `.strength` at runtime from the UI slider.
277
- lora_descriptor = LoraPathStrengthAndSDOps(lora_path, 1.0, LTXV_LORA_COMFY_RENAMING_MAP)
278
-
279
- print(f"LoRA: {lora_path}")
280
-
281
- print(f"Checkpoint: {checkpoint_path}")
282
- print(f"Spatial upsampler: {spatial_upsampler_path}")
283
- print(f"Gemma root: {gemma_root}")
284
-
285
- # Initialize pipeline WITH text encoder and optional audio support
286
- pipeline = LTX23DistilledA2VPipeline(
287
- distilled_checkpoint_path=checkpoint_path,
288
- spatial_upsampler_path=spatial_upsampler_path,
289
- gemma_root=gemma_root,
290
- loras=[lora_descriptor],
291
- quantization=QuantizationPolicy.fp8_cast(),
292
- )
293
-
294
- pipeline_cache = {}
295
-
296
- # Preload all models for ZeroGPU tensor packing.
297
- # >>> REPLACE the "Preload all models" block with this one:
298
- print("Preloading models (pinning decoders/encoders but leaving transformer dynamic)...")
299
- ledger = pipeline.model_ledger
300
-
301
- # NOTE: do NOT call ledger.transformer() here. We keep the transformer's construction dynamic
302
- # so that changes to lora_descriptor.strength (made at runtime) are applied when the transformer
303
- # is built. We DO preload other components that are safe to pin.
304
- _video_encoder = ledger.video_encoder()
305
- _video_decoder = ledger.video_decoder()
306
- _audio_encoder = ledger.audio_encoder()
307
- _audio_decoder = ledger.audio_decoder()
308
- _vocoder = ledger.vocoder()
309
- _spatial_upsampler = ledger.spatial_upsampler()
310
- _text_encoder = ledger.text_encoder()
311
- _embeddings_processor = ledger.gemma_embeddings_processor()
312
-
313
- # Replace ledger methods to return the pinned objects for those components.
314
- # Intentionally do NOT override ledger.transformer so transformer is built when needed.
315
- ledger.video_encoder = lambda: _video_encoder
316
- ledger.video_decoder = lambda: _video_decoder
317
- ledger.audio_encoder = lambda: _audio_encoder
318
- ledger.audio_decoder = lambda: _audio_decoder
319
- ledger.vocoder = lambda: _vocoder
320
- ledger.spatial_upsampler = lambda: _spatial_upsampler
321
- ledger.text_encoder = lambda: _text_encoder
322
- ledger.gemma_embeddings_processor = lambda: _embeddings_processor
323
-
324
- print("Selected models pinned. Transformer remains dynamic to reflect runtime LoRA strength.")
325
- print("Preload complete.")
326
-
327
- print("=" * 80)
328
- print("Pipeline ready!")
329
- print("=" * 80)
330
-
331
-
332
- def log_memory(tag: str):
333
- if torch.cuda.is_available():
334
- allocated = torch.cuda.memory_allocated() / 1024**3
335
- peak = torch.cuda.max_memory_allocated() / 1024**3
336
- free, total = torch.cuda.mem_get_info()
337
- print(f"[VRAM {tag}] allocated={allocated:.2f}GB peak={peak:.2f}GB free={free / 1024**3:.2f}GB total={total / 1024**3:.2f}GB")
338
-
339
-
340
- def detect_aspect_ratio(image) -> str:
341
- if image is None:
342
- return "16:9"
343
- if hasattr(image, "size"):
344
- w, h = image.size
345
- elif hasattr(image, "shape"):
346
- h, w = image.shape[:2]
347
- else:
348
- return "16:9"
349
- ratio = w / h
350
- candidates = {"16:9": 16 / 9, "9:16": 9 / 16, "1:1": 1.0}
351
- return min(candidates, key=lambda k: abs(ratio - candidates[k]))
352
-
353
-
354
- def on_image_upload(first_image, last_image, high_res):
355
- ref_image = first_image if first_image is not None else last_image
356
- aspect = detect_aspect_ratio(ref_image)
357
- tier = "high" if high_res else "low"
358
- w, h = RESOLUTIONS[tier][aspect]
359
- return gr.update(value=w), gr.update(value=h)
360
-
361
-
362
- def on_highres_toggle(first_image, last_image, high_res):
363
- ref_image = first_image if first_image is not None else last_image
364
- aspect = detect_aspect_ratio(ref_image)
365
- tier = "high" if high_res else "low"
366
- w, h = RESOLUTIONS[tier][aspect]
367
- return gr.update(value=w), gr.update(value=h)
368
-
369
-
370
- @spaces.GPU(duration=75)
371
- @torch.inference_mode()
372
- def generate_video(
373
- first_image,
374
- last_image,
375
- input_audio,
376
- prompt: str,
377
- duration: float,
378
- enhance_prompt: bool = True,
379
- seed: int = 42,
380
- randomize_seed: bool = True,
381
- height: int = 1024,
382
- width: int = 1536,
383
- lora_strength: float = 1.0,
384
- progress=gr.Progress(track_tqdm=True),
385
- ):
386
- try:
387
- global pipeline # <<< ADD THIS LINE HERE (VERY TOP of try block)
388
- torch.cuda.reset_peak_memory_stats()
389
- log_memory("start")
390
-
391
- current_seed = random.randint(0, MAX_SEED) if randomize_seed else int(seed)
392
-
393
- frame_rate = DEFAULT_FRAME_RATE
394
- num_frames = int(duration * frame_rate) + 1
395
- num_frames = ((num_frames - 1 + 7) // 8) * 8 + 1
396
-
397
- print(f"Generating: {height}x{width}, {num_frames} frames ({duration}s), seed={current_seed}")
398
-
399
- images = []
400
- output_dir = Path("outputs")
401
- output_dir.mkdir(exist_ok=True)
402
-
403
- if first_image is not None:
404
- temp_first_path = output_dir / f"temp_first_{current_seed}.jpg"
405
- if hasattr(first_image, "save"):
406
- first_image.save(temp_first_path)
407
- else:
408
- temp_first_path = Path(first_image)
409
- images.append(ImageConditioningInput(path=str(temp_first_path), frame_idx=0, strength=1.0))
410
-
411
- if last_image is not None:
412
- temp_last_path = output_dir / f"temp_last_{current_seed}.jpg"
413
- if hasattr(last_image, "save"):
414
- last_image.save(temp_last_path)
415
- else:
416
- temp_last_path = Path(last_image)
417
- images.append(ImageConditioningInput(path=str(temp_last_path), frame_idx=num_frames - 1, strength=1.0))
418
-
419
- tiling_config = TilingConfig.default()
420
- video_chunks_number = get_video_chunks_number(num_frames, tiling_config)
421
-
422
- # >>> NEW: deterministic pipeline-per-strength approach
423
-
424
- runtime_strength = float(lora_strength)
425
-
426
- # round strength to avoid cache explosion (important)
427
- cache_key = round(runtime_strength, 2)
428
-
429
- if cache_key not in pipeline_cache:
430
- print(f"[LoRA] building new pipeline for strength={cache_key}")
431
-
432
- runtime_lora = LoraPathStrengthAndSDOps(
433
- lora_path,
434
- cache_key,
435
- LTXV_LORA_COMFY_RENAMING_MAP
436
- )
437
-
438
- new_pipeline = LTX23DistilledA2VPipeline(
439
- distilled_checkpoint_path=checkpoint_path,
440
- spatial_upsampler_path=spatial_upsampler_path,
441
- gemma_root=gemma_root,
442
- loras=[runtime_lora],
443
- quantization=QuantizationPolicy.fp8_cast(),
444
- )
445
-
446
- # OPTIONAL: minimal preload (safe components only)
447
- ledger = new_pipeline.model_ledger
448
- _video_encoder = ledger.video_encoder()
449
- _video_decoder = ledger.video_decoder()
450
- _audio_encoder = ledger.audio_encoder()
451
- _audio_decoder = ledger.audio_decoder()
452
- _vocoder = ledger.vocoder()
453
- _spatial_upsampler = ledger.spatial_upsampler()
454
- _text_encoder = ledger.text_encoder()
455
- _embeddings_processor = ledger.gemma_embeddings_processor()
456
-
457
- ledger.video_encoder = lambda: _video_encoder
458
- ledger.video_decoder = lambda: _video_decoder
459
- ledger.audio_encoder = lambda: _audio_encoder
460
- ledger.audio_decoder = lambda: _audio_decoder
461
- ledger.vocoder = lambda: _vocoder
462
- ledger.spatial_upsampler = lambda: _spatial_upsampler
463
- ledger.text_encoder = lambda: _text_encoder
464
- ledger.gemma_embeddings_processor = lambda: _embeddings_processor
465
-
466
- pipeline_cache[cache_key] = new_pipeline
467
- else:
468
- print(f"[LoRA] reusing cached pipeline (strength={cache_key})")
469
-
470
- active_pipeline = pipeline_cache[cache_key]
471
-
472
- video, audio = active_pipeline(
473
- prompt=prompt,
474
- seed=current_seed,
475
- height=int(height),
476
- width=int(width),
477
- num_frames=num_frames,
478
- frame_rate=frame_rate,
479
- images=images,
480
- audio_path=input_audio,
481
- tiling_config=tiling_config,
482
- enhance_prompt=enhance_prompt,
483
- )
484
-
485
- log_memory("after pipeline call")
486
-
487
- output_path = tempfile.mktemp(suffix=".mp4")
488
- encode_video(
489
- video=video,
490
- fps=frame_rate,
491
- audio=audio,
492
- output_path=output_path,
493
- video_chunks_number=video_chunks_number,
494
- )
495
-
496
- log_memory("after encode_video")
497
- return str(output_path), current_seed
498
-
499
- except Exception as e:
500
- import traceback
501
- log_memory("on error")
502
- print(f"Error: {str(e)}\n{traceback.format_exc()}")
503
- return None, current_seed
504
-
505
-
506
- with gr.Blocks(title="LTX-2.3 Heretic Distilled") as demo:
507
- gr.Markdown("# LTX-2.3 F2LF:Heretic with Fast Audio-Video Generation with Frame Conditioning")
508
-
509
-
510
- with gr.Row():
511
- with gr.Column():
512
- with gr.Row():
513
- first_image = gr.Image(label="First Frame (Optional)", type="pil")
514
- last_image = gr.Image(label="Last Frame (Optional)", type="pil")
515
- input_audio = gr.Audio(label="Audio Input (Optional)", type="filepath")
516
- prompt = gr.Textbox(
517
- label="Prompt",
518
- info="for best results - make it as elaborate as possible",
519
- value="Make this image come alive with cinematic motion, smooth animation",
520
- lines=3,
521
- placeholder="Describe the motion and animation you want...",
522
- )
523
- duration = gr.Slider(label="Duration (seconds)", minimum=1.0, maximum=30.0, value=10.0, step=0.1)
524
-
525
-
526
- generate_btn = gr.Button("Generate Video", variant="primary", size="lg")
527
-
528
- with gr.Accordion("Advanced Settings", open=False):
529
- seed = gr.Slider(label="Seed", minimum=0, maximum=MAX_SEED, value=10, step=1)
530
- randomize_seed = gr.Checkbox(label="Randomize Seed", value=True)
531
- with gr.Row():
532
- width = gr.Number(label="Width", value=1536, precision=0)
533
- height = gr.Number(label="Height", value=1024, precision=0)
534
- with gr.Row():
535
- enhance_prompt = gr.Checkbox(label="Enhance Prompt", value=False)
536
- high_res = gr.Checkbox(label="High Resolution", value=True)
537
-
538
- # >>> MOVE slider OUTSIDE the row
539
- lora_strength = gr.Slider(
540
- label="LoRA Strength",
541
- info="Scale for the LoRA weights (0.0 = off). Set near 1.0 for full effect.",
542
- minimum=0.0,
543
- maximum=2.0,
544
- value=1.0,
545
- step=0.01,
546
- )
547
-
548
- with gr.Column():
549
- output_video = gr.Video(label="Generated Video", autoplay=False)
550
-
551
- gr.Examples(
552
- examples=[
553
- [
554
- None,
555
- "pinkknit.jpg",
556
- None,
557
- "The camera falls downward through darkness as if dropped into a tunnel. "
558
- "As it slows, five friends wearing pink knitted hats and sunglasses lean "
559
- "over and look down toward the camera with curious expressions. The lens "
560
- "has a strong fisheye effect, creating a circular frame around them. They "
561
- "crowd together closely, forming a symmetrical cluster while staring "
562
- "directly into the lens.",
563
- 3.0,
564
- False,
565
- 42,
566
- True,
567
- 1024,
568
- 1024,
569
- 1.0,
570
- ],
571
- ],
572
- inputs=[
573
- first_image, last_image, input_audio, prompt, duration,
574
- enhance_prompt, seed, randomize_seed, height, width, lora_strength
575
- ],
576
- )
577
-
578
- first_image.change(
579
- fn=on_image_upload,
580
- inputs=[first_image, last_image, high_res],
581
- outputs=[width, height],
582
- )
583
-
584
- last_image.change(
585
- fn=on_image_upload,
586
- inputs=[first_image, last_image, high_res],
587
- outputs=[width, height],
588
- )
589
-
590
- high_res.change(
591
- fn=on_highres_toggle,
592
- inputs=[first_image, last_image, high_res],
593
- outputs=[width, height],
594
- )
595
-
596
- generate_btn.click(
597
- fn=generate_video,
598
- inputs=[
599
- first_image, last_image, input_audio, prompt, duration, enhance_prompt,
600
- seed, randomize_seed, height, width, lora_strength
601
- ],
602
- outputs=[output_video, seed],
603
- )
604
-
605
-
606
- css = """
607
- .fillable{max-width: 1200px !important}
608
- """
609
-
610
- if __name__ == "__main__":
611
- demo.launch(theme=gr.themes.Citrus(), css=css)