import torch from diffsynth.pipelines.ltx2_audio_video import LTX2AudioVideoPipeline, ModelConfig from diffsynth.utils.data.media_io_ltx2 import write_video_audio_ltx2 from diffsynth.utils.data import VideoData vram_config = { "offload_dtype": torch.bfloat16, "offload_device": "cpu", "onload_dtype": torch.bfloat16, "onload_device": "cuda", "preparing_dtype": torch.bfloat16, "preparing_device": "cuda", "computation_dtype": torch.bfloat16, "computation_device": "cuda", } pipe = LTX2AudioVideoPipeline.from_pretrained( torch_dtype=torch.bfloat16, device="cuda", tokenizer_config=ModelConfig(path="./models/DiffSynth-Studio/LTX-2.5-Repackage/tokenizer"), model_configs=[ ModelConfig(model_id="Lightricks/LTX-2.5", origin_file_pattern="text_encoders/gemma4-12b-with-proj-ltx-2.5-comfy-int8-convrot.safetensors", **vram_config), ModelConfig(model_id="DiffSynth-Studio/LTX-2.5-Repackage", origin_file_pattern="text_encoder_post_modules.safetensors", **vram_config), ModelConfig(model_id="Lightricks/LTX-2.5", origin_file_pattern="diffusion_models/ltx-2.5-22b-dev-transformer-comfy-int8-convrot.safetensors", **vram_config), ModelConfig(model_id="Lightricks/LTX-2.5", origin_file_pattern="vae/ltx-2.5-video-vae-bf16.safetensors", **vram_config), ModelConfig(model_id="Lightricks/LTX-2.5", origin_file_pattern="vae/ltx-2.5-audio-vae-bf16.safetensors", **vram_config), ], ) pipe.load_lora(pipe.dit, "models/train/LTX2.5-I2AV-Int8-ConvRot_lora/epoch-4.safetensors") prompt = "A beautiful sunset over the ocean." negative_prompt = pipe.default_negative_prompt["LTX-2.5"] height, width, num_frames = 512, 768, 121 image = VideoData("data/diffsynth_example_dataset/ltx2/LTX-2.5-I2AV-splited/video.mp4", height=height, width=width)[0] video, audio = pipe( prompt=prompt, negative_prompt=negative_prompt, seed=42, height=height, width=width, num_frames=num_frames, tiled=True, tile_size_in_frames=80, input_images=[image], input_images_indexes=[0], input_images_strength=1.0, ) write_video_audio_ltx2( video=video, audio=audio, output_path="ltx2.5_i2av_int8_convrot_lora.mp4", fps=24, audio_sample_rate=pipe.audio_vocoder.output_sampling_rate, ) # Specify `input_image` and `end_image` to enable first/last-frame training. Requires # the first/last-frame LoRA (see the commented commands in lora/LTX-2.5-Int8-ConvRot-splited.sh). # Replace the `pipe.load_lora` and the generation call above with: # pipe.load_lora(pipe.dit, "models/train/LTX2.5-FL2AV-Int8-ConvRot_lora/epoch-4.safetensors") # frames = VideoData("data/diffsynth_example_dataset/ltx2/LTX-2.5-I2AV-splited/video.mp4", height=height, width=width) # video, audio = pipe( # prompt=prompt, # negative_prompt=negative_prompt, # seed=42, # height=height, # width=width, # num_frames=num_frames, # tiled=True, # tile_size_in_frames=80, # input_images=[frames[0], frames[len(frames) - 1]], # input_images_indexes=[0, num_frames - 1], # input_images_strength=1.0, # ) # write_video_audio_ltx2( # video=video, # audio=audio, # output_path="ltx2.5_fl2av_int8_convrot_lora.mp4", # fps=24, # audio_sample_rate=pipe.audio_vocoder.output_sampling_rate, # )