Buckets:

download
raw
302 kB
import"../chunks/DsnmJJEf.js";import{i as Uo,h as jo,H as t,a as s,D as o,E as Zo,s as vo}from"../chunks/BtE7mKSK.js";import{p as Xo,o as Go,s as e,f as m,a as p,b as Io,c as n,d as E,r as a,n as l}from"../chunks/jDjavuwI.js";import{E as u}from"../chunks/SrSJA0zO.js";const Bo='{"title":"LTX-2","local":"ltx-2","sections":[{"title":"Two-stages Generation","local":"two-stages-generation","sections":[],"depth":2},{"title":"Distilled checkpoint generation","local":"distilled-checkpoint-generation","sections":[],"depth":2},{"title":"Condition Pipeline Generation","local":"condition-pipeline-generation","sections":[],"depth":2},{"title":"Multimodal Guidance","local":"multimodal-guidance","sections":[],"depth":2},{"title":"Prompt Enhancement","local":"prompt-enhancement","sections":[],"depth":2},{"title":"LTX-2.5","local":"ltx-25","sections":[{"title":"Two-stage generation for LTX-2.5","local":"two-stage-generation-for-ltx-25","sections":[{"title":"Stage 2 with the distilled LoRA","local":"stage-2-with-the-distilled-lora","sections":[],"depth":4}],"depth":3},{"title":"Convolutional and diffusion decoding","local":"convolutional-and-diffusion-decoding","sections":[],"depth":3},{"title":"Full / SFT transformer","local":"full--sft-transformer","sections":[],"depth":3},{"title":"Prompt Enhancement for LTX-2.5","local":"prompt-enhancement-for-ltx-25","sections":[],"depth":3},{"title":"Automatic duration for LTX-2.5","local":"automatic-duration-for-ltx-25","sections":[],"depth":3},{"title":"LTX-2.5 Modular","local":"ltx-25-modular","sections":[],"depth":3}],"depth":2},{"title":"LTX2Pipeline","local":"diffusers.LTX2Pipeline","sections":[],"depth":2},{"title":"LTX2ImageToVideoPipeline","local":"diffusers.LTX2ImageToVideoPipeline","sections":[],"depth":2},{"title":"LTX2ConditionPipeline","local":"diffusers.LTX2ConditionPipeline","sections":[],"depth":2},{"title":"LTX2LatentUpsamplePipeline","local":"diffusers.LTX2LatentUpsamplePipeline","sections":[],"depth":2},{"title":"LTX2VideoDiffusionDecodePipeline","local":"diffusers.LTX2VideoDiffusionDecodePipeline","sections":[],"depth":2},{"title":"LTX2DurationHead","local":"diffusers.pipelines.ltx2.LTX2DurationHead","sections":[],"depth":2},{"title":"LTX2PipelineOutput","local":"diffusers.pipelines.ltx2.pipeline_output.LTX2PipelineOutput","sections":[],"depth":2},{"title":"LTX2ModularPipeline","local":"diffusers.LTX2ModularPipeline","sections":[],"depth":2},{"title":"LTX2AutoBlocks","local":"diffusers.LTX2AutoBlocks","sections":[],"depth":2},{"title":"LTX25ModularPipeline","local":"diffusers.LTX25ModularPipeline","sections":[],"depth":2},{"title":"LTX25AutoBlocks","local":"diffusers.LTX25AutoBlocks","sections":[],"depth":2},{"title":"LTX2Guidance","local":"diffusers.modular_pipelines.ltx2.guider.LTX2Guidance","sections":[],"depth":2}],"depth":1}';var Vo=E('<meta name="hf:doc:metadata"/>'),h=E("<p>Examples:</p> <!>",1),Wo=E(`<p></p> <!> <div class="flex flex-wrap space-x-1"><img alt="LoRA" src="https://img.shields.io/badge/LoRA-d8b4fe?style=flat"/></div> <p><a href="https://hf.co/papers/2601.03233" rel="nofollow">LTX-2</a> is a DiT-based foundation model designed to generate synchronized video and audio within a single model. It brings together the core building blocks of modern video generation, with open weights and a focus on practical, local execution.</p> <p>You can find all the original LTX-Video checkpoints under the <a href="https://huggingface.co/Lightricks" rel="nofollow">Lightricks</a> organization.</p> <p>The original codebase for LTX-2 can be found <a href="https://github.com/Lightricks/LTX-2" rel="nofollow">here</a>.</p> <!> <p>The shared <code>LTX2Pipeline</code> / <code>LTX2ImageToVideoPipeline</code> <code>__call__</code> defaults match the LTX-2.5 reference (<code>num_inference_steps=30</code>; <code>num_frames</code> is optional when a <code>duration_head</code> is present, otherwise it falls back to <code>121</code>). The examples below use those defaults for LTX-2.0/2.3 as well.</p> <p>Recommended pipeline to achieve production quality generation, this pipeline is composed of two stages:</p> <ul><li>Stage 1: Generate a video at the target resolution using diffusion sampling with classifier-free guidance (CFG). This stage produces a coherent low-noise video sequence that respects the text/image conditioning.</li> <li>Stage 2: Upsample the Stage 1 output by 2 and refine details using a distilled LoRA model to improve fidelity and visual quality. Stage 2 may apply lighter CFG to preserve the structure from Stage 1 while enhancing texture and sharpness.</li></ul> <p>Sample usage of text-to-video two stages pipeline</p> <!> <!> <p>Fastest two-stages generation pipeline using a distilled checkpoint.</p> <!> <!> <p>You can use <code>LTX2ConditionPipeline</code> to specify image and/or video conditions at arbitrary latent indices. For example, we can specify both a first-frame and last-frame condition to perform first-last-frame-to-video (FLF2V) generation:</p> <!> <p>You can use both image and video conditions:</p> <!> <p>Because the conditioning is done via latent frames, the 8 data space frames corresponding to the specified latent frame for an image condition will tend to be static.</p> <!> <p>LTX-2.X pipelines support multimodal guidance. It is composed of three terms, all using a CFG-style update rule:</p> <ol><li>Classifier-Free Guidance (CFG): standard <a href="https://huggingface.co/papers/2207.12598" rel="nofollow">CFG</a> where the perturbed (“weaker”) output is generated using the negative prompt.</li> <li>Spatio-Temporal Guidance (STG): <a href="https://huggingface.co/papers/2411.18664" rel="nofollow">STG</a> moves away from a perturbed output created from short-cutting self-attention operations and substitutes in the attention values instead. The idea is that this creates sharper videos and better spatiotemporal consistency.</li> <li>Modality Isolation Guidance: moves away from a perturbed output created from disabling cross-modality (audio-to-video and video-to-audio) cross attention. This guidance is more specific to <a href="https://huggingface.co/papers/2601.03233" rel="nofollow">LTX-2.X</a> models, with the idea that this produces better consistency between the generated audio and video.</li></ol> <p>These are controlled by the <code>guidance_scale</code>, <code>stg_scale</code>, and <code>modality_scale</code> arguments and can be set separately for video and audio. Additionally, for STG the transformer block indices where self-attention is skipped needs to be specified via the <code>spatio_temporal_guidance_blocks</code> argument. The LTX-2.X pipelines also support <a href="https://huggingface.co/papers/2305.08891" rel="nofollow">guidance rescaling</a> to help reduce over-exposure, which can be a problem when the guidance scales are set to high values.</p> <!> <!> <p>The LTX-2.X models are sensitive to prompting style. Refer to the <a href="https://ltx.io/model/model-blog/prompting-guide-for-ltx-2" rel="nofollow">official prompting guide</a> for recommendations on how to write a good prompt. Using prompt enhancement, where the supplied prompts are enhanced using the pipeline’s text encoder (by default a <a href="https://huggingface.co/google/gemma-3-12b-it-qat-q4_0-unquantized" rel="nofollow">Gemma 3</a> model) given a system prompt, can also improve sample quality. The optional <code>processor</code> pipeline component needs to be present to use prompt enhancement. Enable it with <code>enable_prompt_enhancement=True</code> and a <code>system_prompt</code> (opt-in, matching the Lightricks reference pipelines):</p> <!> <!> <p>LTX-2.5 reuses the same <code>LTX2Pipeline</code>/<code>LTX2VideoTransformer3DModel</code>/<code>AutoencoderKLLTX2Video</code>/etc. classes as LTX-2.3 — there is no separate pipeline class for it. The user-visible difference is the text encoder: LTX-2.5 is paired with a Gemma 4 (<code>gemma4_unified</code>) checkpoint instead of Gemma 3. This is loaded automatically when you call <code>from_pretrained</code> on a converted LTX-2.5 checkpoint (via the <code>transformers</code> <code>Auto*</code> classes), so no extra setup is needed at inference time — just point <code>from_pretrained</code> at an LTX-2.5 repo instead of an LTX-2.3 one.</p> <p><a href="https://huggingface.co/Lightricks/LTX-2.5-Diffusers" rel="nofollow"><code>Lightricks/LTX-2.5-Diffusers</code></a> ships both transformers: the <strong>distilled</strong> DiT in <code>transformer/</code>, which is what <code>model_index.json</code> points at, and the full/SFT DiT in <code>transformer_full/</code>, which has to be loaded explicitly (see <a href="#full--sft-transformer">Full / SFT transformer</a>). The repo’s <code>scheduler/</code> is configured for the distilled checkpoint (<code>use_dynamic_shifting=False</code>, <code>shift_terminal=None</code>) so that its sigma schedule is used exactly as given. Everything <a href="#two-stage-generation-for-ltx-25">two-stage generation</a> needs is shipped there too: a <code>latent_upsampler/</code> subfolder and the stage 2 distilled LoRA, <code>ltx-2.5-22b-distilled-lora-450-bf16.safetensors</code>, at the root of the repo.</p> <p>Distilled inference is driven by an explicit sigma schedule rather than a step count, and runs unguided (<code>guidance_scale=1.0</code>, so <code>negative_prompt</code> is unused). Passing <code>num_inference_steps</code> instead would hand the model a generic linear schedule and quietly cost quality:</p> <!> <!> <p>LTX-2.5 supports both two-stage variants, and <code>DISTILLED_SIGMA_VALUES</code> / <code>STAGE_2_DISTILLED_SIGMA_VALUES</code> are its reference schedules:</p> <ul><li><strong>Distilled checkpoint, both stages</strong> — the reference recipe for the default <code>transformer/</code>, and the one shown below. No stage 2 LoRA is involved, since the transformer is already distilled; this is <a href="#distilled-checkpoint-generation">Distilled checkpoint generation</a> with LTX-2.5 weights.</li> <li><strong>Full/SFT stage 1 + distilled LoRA stage 2</strong> — <a href="#two-stages-generation">Two-stages Generation</a> as described at the top of this page, using <code>transformer_full/</code> and the shipped LoRA. See <a href="#stage-2-with-the-distilled-lora">below</a> for what changes.</li></ul> <p>Stage 1 runs at half the target resolution, the upsampler doubles it, and stage 2 refines at full resolution — video <em>and</em> audio, both reseeded from the stage 1 latents at <code>noise_scale=STAGE_2_DISTILLED_SIGMA_VALUES[0]</code>. Height and width must be divisible by 64, since stage 1 halves each axis and still has to land on the VAE’s spatial grid.</p> <!> <p>When the length comes from the <a href="#automatic-duration-for-ltx-25">duration head</a> rather than an explicit <code>num_frames</code>, let stage 1 decide and recover the realized length from its latents (<code>[B, C, F, H, W]</code>) before stage 2 runs, instead of predicting a second time:</p> <!> <!> <p>To run <a href="#two-stages-generation">Two-stages Generation</a> instead — full/SFT DiT for stage 1, distilled LoRA for stage 2 — build the pipeline as in <a href="#full--sft-transformer">Full / SFT transformer</a> and generate stage 1 latents with that guidance stack. Two things then differ from LTX-2.0/2.3. The LoRA lives in the diffusers repo itself rather than alongside the original weights, and the scheduler flip goes the other way round: LTX-2.5 ships the <em>distilled</em> scheduler config, so stage 1 is what turned dynamic shifting on, and stage 2 turns it back off.</p> <!> <p>The upsample step and the stage 2 call itself are unchanged from the distilled recipe above: same <code>sigmas=STAGE_2_DISTILLED_SIGMA_VALUES</code>, same <code>noise_scale</code>, and <code>guidance_scale=1.0</code>, since stage 2 is running a distilled model either way.</p> <!> <p>LTX-2.5 ships two video decoders over the same latent space, so latents are interchangeable between them:</p> <ul><li><code>vae/</code> — the convolutional VAE (<a href="/docs/diffusers/pr_14588/en/api/models/autoencoderkl_ltx_2#diffusers.AutoencoderKLLTX2Video">AutoencoderKLLTX2Video</a>). It is what the pipelines decode with, so every snippet above already uses it, and it is the only one of the two that tiles (<code>pipe.vae.enable_tiling()</code>), which is usually what makes a high resolution fit.</li> <li><code>diffusion_decoder/</code> — <a href="/docs/diffusers/pr_14588/en/api/models/ltx2_diffusion_decoder#diffusers.LTX2VideoDiffusionDecoderModel">LTX2VideoDiffusionDecoderModel</a>. It is a diffusion model in its own right rather than a pipeline component, so it is not passed as a <code>vae</code>: run the pipeline with <code>output_type="latent"</code> and hand the latents to <a href="/docs/diffusers/pr_14588/en/api/pipelines/ltx2#diffusers.LTX2VideoDiffusionDecodePipeline">LTX2VideoDiffusionDecodePipeline</a>.</li></ul> <p>Encoding always goes through <code>vae/</code>, so image and video conditioning are unaffected by the choice.</p> <p>Two things change when you decode with the diffusion decoder. <code>output_type="latent"</code> also skips the vocoder, so the audio comes back as latents and has to be finished by hand, and the NATTEN processor is effectively required at video resolutions:</p> <!> <p>To combine this with <a href="#two-stage-generation-for-ltx-25">two-stage generation</a>, ask <em>stage 2</em> for <code>output_type="latent"</code> and decode that.</p> <p><code>decoder.enable_tiling()</code> is what keeps a high resolution decode in memory, the same way <code>pipe.vae.enable_tiling()</code> does for the convolutional VAE. The memory-dominant part of the decode — the last upsampling stage and the diffusion stage — then runs on overlapping tiles that are blended back together, so peak memory is bounded by the tile size instead of the video size. Tiling only kicks in once the latent exceeds one tile, and the tile and overlap sizes can be tuned via the <code>tile_sample_min_*</code> / <code>tile_sample_stride_*</code> arguments (defaults match the reference implementation). Since the diffusion stage denoises each tile separately, a tiled decode does not reproduce the untiled result exactly.</p> <p>On a single card it is also worth moving the pipeline out of the way before decoding (<code>pipe.to("cpu")</code> and <code>torch.cuda.empty_cache()</code>, after capturing <code>pipe.scheduler</code> and the vocoder’s <code>output_sampling_rate</code>), since the decoder needs its own headroom. See <a href="/docs/diffusers/pr_14588/en/api/models/ltx2_diffusion_decoder#diffusers.LTX2VideoDiffusionDecoderModel">LTX2VideoDiffusionDecoderModel</a> for the attention backends, the tiling details, and the rest of the decoder’s behaviour.</p> <!> <p><code>transformer_full/</code> is not referenced by <code>model_index.json</code>, so load it explicitly. It also needs a different scheduler and a real guidance stack: the shipped <code>scheduler/</code> is configured for the distilled checkpoint, and the guidance defaults are LTX-2.0-era generics that leave an LTX-2.5 SFT run visibly under-guided without raising anything. The <a href="#multimodal-guidance">Multimodal Guidance</a> recommendations apply here unchanged, including STG on block <code>28</code>:</p> <!> <p>Drop <code>sigmas</code> here — the full DiT takes its schedule from the scheduler.</p> <!> <p><strong>Using prompt enhancement is strongly recommended for LTX-2.5; pass <code>enable_prompt_enhancement=True</code> to opt in</strong> (same as the Lightricks reference pipelines). Unlike LTX-2.0/2.3, where the same text encoder checkpoint doubles as the enhancer (see <a href="#prompt-enhancement">Prompt Enhancement</a> above), LTX-2.5’s fine-tuned text encoder was not trained for enhancement. Instead, enhancement uses a separate, off-the-shelf <code>google/gemma-4-E2B-it</code> checkpoint. Load it into the pipeline’s optional <code>prompt_enhancer</code>/<code>processor</code> components, then enable enhancement — the pipeline defaults to <code>LTX2_5_T2V_DEFAULT_SYSTEM_PROMPT</code> and the Gemma 4 recipe (<code>do_sample=False</code>, <code>no_repeat_ngram_size=5</code>, <code>max_new_tokens=600</code>). Pass an explicit <code>system_prompt=</code> to override:</p> <!> <p>The same applies to image-to-video with <code>LTX2ImageToVideoPipeline</code>: set <code>pipe.prompt_enhancer</code>/<code>pipe.processor</code> the same way and pass <code>enable_prompt_enhancement=True</code> (using <code>LTX2_5_I2V_DEFAULT_SYSTEM_PROMPT</code>, conditioning on both the reference image and the text prompt) — again, no <code>system_prompt=</code> needed unless you want to override it.</p> <!> <p>LTX-2.5 checkpoints ship a small <code>duration_head</code> that predicts how long the described shot should be, from the same text-connector output the transformer is conditioned on. When the loaded pipeline has one, <strong><code>num_frames</code> is auto-predicted by default</strong> — omit it and the model chooses the length:</p> <!> <p>To set the length yourself, pass <code>num_frames</code> explicitly. An integer always wins over the head:</p> <!> <p>Pipelines loaded from LTX-2.0 or LTX-2.3 checkpoints have no duration head and keep the previous default of 121 frames, so this changes nothing for them.</p> <p>Pass <code>min_seconds</code> / <code>max_seconds</code> to constrain the prediction. The raw prediction is clamped into the range, then converted to frames:</p> <!> <p>Predicted frame counts are snapped to the VAE’s causal temporal grid (<code>8k + 1</code>), so the realized duration is quantized — about 0.33s per step at 24 fps — and it shifts with <code>frame_rate</code>, since the head predicts seconds rather than frames. <code>min_seconds</code> must be strictly less than <code>max_seconds</code>. These bounds are ignored when <code>num_frames</code> is set explicitly.</p> <p>Bounds narrower than one grid step may not be satisfiable exactly: at 24 fps <code>[1.0s, 1.02s]</code> converts to <code>[24, 24]</code> frames, and 24 is not <code>8k + 1</code>. The nearest grid point is used and a warning is logged, so the returned length can fall just outside bounds that tight.</p> <p>To inspect a prediction without generating a video, call the head directly. Everything it needs is public:</p> <!> <p>Converting a 2.5 checkpoint picks the head up automatically with <code>--full_pipeline</code>, or on its own with <code>--duration_head</code>. Checkpoints predating 2.5 have no such weights, and conversion skips the component rather than failing.</p> <!> <p>LTX-2.5 is also available as a modular pipeline. The default blockset uses the diffusion decoder and predicts the video duration when <code>num_frames</code> is omitted. It applies guidance separately to video and audio through the <code>guider</code> and <code>audio_guider</code> components. See <code>LTX2Guidance</code> for the available guidance parameters. By default, the modular pipeline will download the prompt enhancer and processor from the <a href="https://huggingface.co/google/gemma-4-E2B-it" rel="nofollow">google/gemma-4-E2B-it</a> repo. Below is a T2V modular example:</p> <!> <p>The modular pipeline will automatically switch workflows based on the supplied inputs. For example, if <code>image</code> is supplied, an I2V workflow will be used:</p> <!> <p>You can see the supported workflows in the docs for each blockset (e.g. <a href="/docs/diffusers/pr_14588/en/api/pipelines/ltx2#diffusers.LTX2AutoBlocks">LTX2AutoBlocks</a>, <a href="/docs/diffusers/pr_14588/en/api/pipelines/ltx2#diffusers.LTX25AutoBlocks">LTX25AutoBlocks</a>).</p> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Pipeline for text-to-video generation.</p> <p>Reference: <a href="https://github.com/Lightricks/LTX-Video" rel="nofollow">https://github.com/Lightricks/LTX-Video</a></p> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Function invoked when calling the pipeline for generation.</p> <!></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Encodes the prompt into text encoder hidden states.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Enhances the supplied <code>prompt</code> by generating a new prompt using the prompt enhancer (a Gemma
conditional-generation model) from it and a system prompt. When <code>image</code> is supplied, the enhancer is also
conditioned on that reference frame (I2V / keyframe-style enhancement). Uses the dedicated <code>prompt_enhancer</code> component if one is configured (e.g. LTX-2.5, whose text encoder isn’t trained for enhancement), otherwise
falls back to the main <code>text_encoder</code> (LTX-2.0/2.3, which double as their own enhancer).</p> <p>Message templates, decoding kwargs, response cleaning, and image long-side prep match <code>ltx-core</code> / <code>ltx-pipelines</code> (<code>enhance_t2v</code> / <code>enhance_i2v</code> / <code>generate_enhanced_prompt</code>).</p></div></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Pipeline for image-to-video generation.</p> <p>Reference: <a href="https://github.com/Lightricks/LTX-Video" rel="nofollow">https://github.com/Lightricks/LTX-Video</a></p> <p>TODO</p> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Function invoked when calling the pipeline for generation.</p> <!></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Encodes the prompt into text encoder hidden states.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Enhances the supplied <code>prompt</code> by generating a new prompt using the prompt enhancer (a Gemma
conditional-generation model) from it and a system prompt. When <code>image</code> is supplied, the enhancer is also
conditioned on that reference frame (I2V / keyframe-style enhancement). Uses the dedicated <code>prompt_enhancer</code> component if one is configured (e.g. LTX-2.5, whose text encoder isn’t trained for enhancement), otherwise
falls back to the main <code>text_encoder</code> (LTX-2.0/2.3, which double as their own enhancer).</p> <p>Message templates, decoding kwargs, response cleaning, and image long-side prep match <code>ltx-core</code> / <code>ltx-pipelines</code> (<code>enhance_t2v</code> / <code>enhance_i2v</code> / <code>generate_enhanced_prompt</code>).</p></div></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Pipeline for video generation which allows image conditions to be inserted at arbitary parts of the video.</p> <p>Reference: <a href="https://github.com/Lightricks/LTX-Video" rel="nofollow">https://github.com/Lightricks/LTX-Video</a></p> <p>TODO</p> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Function invoked when calling the pipeline for generation.</p> <!></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Apply first-frame visual conditioning by overwriting tokens at the first-frame positions.</p> <p>Only conditions with <code>latent_idx == 0</code> are applied here (matching <code>VideoConditionByLatentIndex</code> in the
reference implementation). Conditions at non-zero latent indices are appended as separate keyframe tokens via <code>prepare_keyframe_extras</code> (matching <code>VideoConditionByKeyframeIndex</code>) and are skipped here.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Encodes the prompt into text encoder hidden states.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Enhances the supplied <code>prompt</code> by generating a new prompt using the prompt enhancer (a Gemma
conditional-generation model) from it and a system prompt. When <code>image</code> is supplied, the enhancer is also
conditioned on that reference frame (I2V / keyframe-style enhancement). Uses the dedicated <code>prompt_enhancer</code> component if one is configured (e.g. LTX-2.5, whose text encoder isn’t trained for enhancement), otherwise
falls back to the main <code>text_encoder</code> (LTX-2.0/2.3, which double as their own enhancer).</p> <p>Message templates, decoding kwargs, response cleaning, and image long-side prep match <code>ltx-core</code> / <code>ltx-pipelines</code> (<code>enhance_t2v</code> / <code>enhance_i2v</code> / <code>generate_enhanced_prompt</code>).</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Prepare noisy video latents, applying frame conditions.</p> <p>First-frame conditions (<code>latent_idx == 0</code>) are applied by overwriting tokens at the first-frame positions
(<code>VideoConditionByLatentIndex</code> semantics). Non-first-frame conditions (<code>latent_idx &gt; 0</code>) are concatenated onto
the main latent sequence with per-token <code>conditioning_mask = strength</code> (<code>VideoConditionByKeyframeIndex</code> semantics) — the denoising loop’s existing timestep formula <code>t * (1 - conditioning_mask)</code> and post-process
blend <code>denoised * (1 - conditioning_mask) + clean * conditioning_mask</code> then drive them across steps.</p> <p>Returns a 4-tuple:</p> <ul><li><code>latents</code>: packed noisy latents (base tokens + any keyframe tokens cat’d onto the sequence dim).</li> <li><code>conditioning_mask</code>: packed conditioning mask with values in <code>[0, 1]</code> — <code>1</code> at first-frame positions, <code>strength</code> at keyframe positions, <code>0</code> elsewhere.</li> <li><code>clean_latents</code>: clean condition values at conditioned positions (zeros elsewhere); same shape as <code>latents</code>.</li> <li><code>keyframe_coords</code>: <code>[B, 3, num_keyframe_patches, 2]</code> positional coordinates to append to <code>video_coords</code>,
or <code>None</code> if there are no non-first-frame conditions.</li></ul></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Preprocesses the condition images/videos to torch tensors.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Trim a conditioning sequence to the allowed number of frames.</p></div></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Function invoked when calling the pipeline for generation.</p> <!></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Applies Adaptive Instance Normalization (AdaIN) to a latent tensor based on statistics from a reference latent
tensor.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Applies a non-linear tone-mapping function to latent values to reduce their dynamic range in a perceptually
smooth way using a sigmoid-based compression.</p> <p>This is useful for regularizing high-variance latents or for conditioning outputs during generation, especially
when controlling dynamic behavior with a <code>compression</code> factor.</p></div></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Decode LTX-2 video latents with the diffusion decoder introduced in LTX-2.5.</p> <p>Unlike a convolutional decoder this one is itself a small diffusion model: it denoises pixels conditioned on a
context volume built from the latents, so it needs a scheduler and a generator. Pair it with any LTX-2 pipeline run
with <code>output_type="latent"</code>, passing <code>denormalize=False</code> since that path already applied the latent statistics.</p> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!></div></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Predicts the natural duration of the shot implied by a caption, from the LTX-2 text connector outputs.</p> <p>The head is modality-agnostic: pass either or both of the video and audio connector outputs. Modality-specific
input projections map each stream into a shared pooler dimension, learnable modality embeddings tag the streams so
the pooler can tell them apart, and a small MLP turns the pooled vector into a log-duration. The regression target
is trained in log-seconds, so <code>forward</code> exponentiates and callers always get seconds.</p> <p>Ships from LTX-2.5 checkpoints onward.</p> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Predicts a frame count from connector tokens, clamped to <code>[min_seconds, max_seconds]</code> and snapped to the VAE’s
causal temporal grid (<code>k * temporal_compression_ratio + 1</code>).</p> <p>The clamp is applied before snapping: a clamped frame count is not necessarily grid-aligned, so snapping first
would give a different result. Because snapping floors, it can land below the minimum; when that happens the
result is snapped up to the next grid point instead, so the frame count stays within bounds.</p> <p>Narrow bounds can convert to a frame window containing no grid point at all — at 24 fps, <code>[1.0s, 1.02s]</code> rounds to <code>[24, 24]</code>, and 24 is not <code>8k + 1</code>. The nearest grid point is used and a warning is logged, since
overshooting by under one grid step beats refusing to generate. The returned count is therefore always on the
grid, but may fall just outside the requested bounds in this case.</p></div></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Output class for LTX pipelines.</p></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>A ModularPipeline for LTX-2 (joint video + audio generation).</p></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Auto blocks for LTX-2 supporting text-to-video, image-to-video, condition-to-video and in-context (IC-LoRA)
generation (joint video + audio).</p> <p>Supported workflows:</p> <ul><li><code>text2video</code>: requires <code>prompt</code></li> <li><code>image2video</code>: requires <code>image</code>, <code>prompt</code></li> <li><code>condition</code>: requires <code>conditions</code>, <code>prompt</code></li> <li><code>in_context</code>: requires <code>reference_conditions</code>, <code>num_frames</code>, <code>prompt</code></li></ul> <p>Components:
prompt_enhancer (<code>PreTrainedModel</code>) processor (<code>ProcessorMixin</code>) text_encoder (<code>PreTrainedModel</code>) tokenizer
(<code>PreTrainedTokenizerBase</code>) connectors (<code>LTX2TextConnectors</code>) duration_head (<code>LTX2DurationHead</code>) vae
(<code>AutoencoderKLLTX2Video</code>) video_processor (<code>VideoProcessor</code>) transformer (<code>LTX2VideoTransformer3DModel</code>)
scheduler (<code>FlowMatchEulerDiscreteScheduler</code>) audio_vae (<code>AutoencoderKLLTX2Audio</code>) guider (<code>LTX2Guidance</code>)
audio_guider (<code>LTX2Guidance</code>) vocoder (<code>LTX2Vocoder</code>)</p> <p>Inputs:
prompt (<code>str</code>, <em>optional</em>):
The prompt or prompts to guide image generation.
conditions (<code>list</code>, <em>optional</em>): <code>LTX2VideoCondition</code> (or list of them) placing image/video conditions at latent frame indices of the
generated video.
enable_prompt_enhancement (<code>bool</code>, <em>optional</em>, defaults to False):
Whether to run the prompt enhancer. Opt-in, matching the Lightricks reference pipelines.
system_prompt (<code>str</code>, <em>optional</em>):
System prompt for enhancement. Defaults to <code>LTX2_5_I2V_DEFAULT_SYSTEM_PROMPT</code> when a <code>PIL.Image.Image</code> condition frame is available, else <code>LTX2_5_T2V_DEFAULT_SYSTEM_PROMPT</code>.
prompt_max_new_tokens (<code>int</code>, <em>optional</em>):
Maximum number of new tokens to generate during prompt enhancement. Defaults to 600, the LTX-2.5 Gemma-4
enhancer’s budget.
prompt_enhancement_kwargs (<code>dict</code>, <em>optional</em>):
Keyword arguments for the enhancer’s <code>.generate</code> call. Defaults to greedy decoding.
prompt_enhancement_seed (<code>int</code>, <em>optional</em>, defaults to 10):
Random seed for prompt enhancement (inert under LTX-2.5’s greedy decoding).
generator (<code>Generator</code>, <em>optional</em>):
Torch generator for deterministic generation.
image (<code>Image | list</code>, <em>optional</em>):
Reference image(s) for denoising. Can be a single image or list of images.
negative_prompt (<code>str</code>, <em>optional</em>):
The prompt or prompts not to guide the image generation.
max_sequence_length (<code>int</code>, <em>optional</em>, defaults to 1024):
Maximum sequence length for prompt encoding.
min_seconds (<code>float</code>, <em>optional</em>, defaults to 1.0):
Lower bound on the auto-predicted duration.
max_seconds (<code>float</code>, <em>optional</em>, defaults to 20.0):
Upper bound on the auto-predicted duration. Must be strictly greater than <code>min_seconds</code>.
frame_rate (<code>float</code>, <em>optional</em>, defaults to 24.0):
Frames per second of the generated video.
height (<code>int</code>, <em>optional</em>, defaults to 512):
The height in pixels of the generated image.
width (<code>int</code>, <em>optional</em>, defaults to 704):
The width in pixels of the generated image.
image_crf (<code>int</code>, <em>optional</em>):
H.264 CRF used to re-compress the conditioning <code>image</code> before VAE encode, matching the compression the
model was trained against. <code>None</code> (default) resolves from the text-encoder generation (33 through
LTX-2.3, 18 for LTX-2.5). Pass <code>0</code> to skip re-compression. Requires a <code>PIL.Image.Image</code> when
re-compression runs.
num_frames (<code>int</code>, <em>optional</em>):
The number of frames in the generated video. Omit to auto-predict via the <code>duration_head</code> (see <code>LTX2AutoDurationStep</code>).
reference_conditions (<code>list</code>, <em>optional</em>): <code>LTX2ReferenceCondition</code> (or list of them) whose videos are encoded into extra latent tokens the IC-LoRA
adapter attends to.
reference_downscale_factor (<code>int</code>, <em>optional</em>, defaults to 1):
Ratio between the target and reference resolutions; 2 means the reference is preprocessed at half the
target resolution. Spatial coordinates are scaled by this factor so the reference tokens land in the
target coordinate space. Must match the factor the IC-LoRA was trained with.
conditioning_attention_strength (<code>float</code>, <em>optional</em>, defaults to 1.0):
Scalar in [0, 1] controlling how strongly the noisy tokens and reference tokens attend to each other. 1.0
(default) leaves attention unmasked.
conditioning_attention_mask (<code>Tensor</code>, <em>optional</em>):
Optional pixel-space mask of shape (1, 1, F, H, W) with values in [0, 1] giving spatially varying
attention strength. Downsampled to the reference’s latent grid and multiplied by <code>conditioning_attention_strength</code>.
num_videos_per_prompt (<code>int</code>, <em>optional</em>, defaults to 1):
The number of images to generate per prompt.
condition_latents (<code>list</code>, <em>optional</em>):
Per-condition normalized VAE latents of shape [1, C, F, H, W].
condition_strengths (<code>list</code>, <em>optional</em>):
Per-condition conditioning strengths.
condition_indices (<code>list</code>, <em>optional</em>):
Per-condition latent frame index at which the condition is applied.
condition_pixel_frames (<code>list</code>, <em>optional</em>):
Per-condition trimmed pixel frame count, used to clamp single-frame keyframe coords.
reference_latents (<code>Tensor</code>, <em>optional</em>):
Packed reference tokens of shape [1, total_reference_tokens, C], or <code>None</code> when no reference conditions
were supplied (<code>LTX2AutoReferenceEncoderStep</code> is skipped).
reference_coords (<code>Tensor</code>, <em>optional</em>):
RoPE coordinates for the reference tokens.
reference_token_counts (<code>list</code>, <em>optional</em>):
Per-reference token counts, in <code>reference_conditions</code> order.
latents (<code>Tensor</code>):
Pre-generated noisy latents for image generation.
noise_scale (<code>float</code>, <em>optional</em>):
Initial noise level for the un-conditioned tokens. <code>None</code> (default) resolves to <code>sigmas[0]</code> when custom <code>sigmas</code> are supplied, else 1.0.
sigmas (<code>list</code>, <em>optional</em>):
Custom sigmas for the denoising process.
reference_cross_mask (<code>Tensor</code>, <em>optional</em>):
Per-reference-token noisy&#60;->reference attention strengths of shape [1, num_ref_tokens].
num_inference_steps (<code>int</code>):
The number of denoising steps.
timesteps (<code>Tensor</code>):
Timesteps for the denoising process.
audio_latents (<code>Tensor</code>):
Optional pre-encoded audio latents; random noise is used when not provided.
*<em>denoiser_input_fields (<code>None</code>,</em>optional<em>):
conditional model inputs for the denoiser: e.g. prompt_embeds, negative_prompt_embeds, etc.
use_cross_timestep (<code>bool</code>,</em>optional<em>, defaults to True):
Whether to condition the transformer on a separate per-token cross timestep (LTX-2.3+).
attention_kwargs (<code>dict</code>,</em>optional<em>):
Additional kwargs for attention processors.
image_latents (<code>Tensor</code>,</em>optional<em>):
VAE-encoded reference-image latents used for image-to-video conditioning.
output_type (<code>str</code>,</em>optional<em>, defaults to pil):
Output format: ‘pil’, ‘np’, ‘pt’.
decode_timestep (<code>None</code>,</em>optional<em>, defaults to 0.0):
The timestep at which the VAE decodes the final latents.
decode_noise_scale (<code>None</code>,</em>optional*):
Noise interpolation factor applied to the latents at the decode timestep.</p> <p>Outputs:
videos (<code>list</code>):
The generated videos.
audio (<code>Tensor</code>):
The generated audio waveform.</p></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>A ModularPipeline for LTX-2.5 (joint video + audio generation).</p> <p>Identical to <a href="/docs/diffusers/pr_14588/en/api/pipelines/ltx2#diffusers.LTX2ModularPipeline">LTX2ModularPipeline</a> except that its default blocks decode with the diffusion video decoder, which
is the native default from LTX-2.5 on. A checkpoint routes here through <code>modular_model_index.json</code>.</p></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Auto blocks for LTX-2.5 supporting text-to-video, image-to-video, condition-to-video and in-context (IC-LoRA)
generation (joint video + audio). Identical to <code>LTX2AutoBlocks</code> except that the video decoder is <code>LTX2DiffusionVaeDecoderStep</code>, since the diffusion decoder is the native default from LTX-2.5 on. To decode with
the convolutional VAE instead, swap the decode block: <code>blocks.sub_blocks["decode"] = LTX2AutoDecoderStep()</code>.</p> <p>Supported workflows:</p> <ul><li><code>text2video</code>: requires <code>prompt</code></li> <li><code>image2video</code>: requires <code>image</code>, <code>prompt</code></li> <li><code>condition</code>: requires <code>conditions</code>, <code>prompt</code></li> <li><code>in_context</code>: requires <code>reference_conditions</code>, <code>num_frames</code>, <code>prompt</code></li></ul> <p>Components:
prompt_enhancer (<code>PreTrainedModel</code>) processor (<code>ProcessorMixin</code>) text_encoder (<code>PreTrainedModel</code>) tokenizer
(<code>PreTrainedTokenizerBase</code>) connectors (<code>LTX2TextConnectors</code>) duration_head (<code>LTX2DurationHead</code>) vae
(<code>AutoencoderKLLTX2Video</code>) video_processor (<code>VideoProcessor</code>) transformer (<code>LTX2VideoTransformer3DModel</code>)
scheduler (<code>FlowMatchEulerDiscreteScheduler</code>) audio_vae (<code>AutoencoderKLLTX2Audio</code>) guider (<code>LTX2Guidance</code>)
audio_guider (<code>LTX2Guidance</code>) diffusion_decoder (<code>LTX2VideoDiffusionDecoderModel</code>) vocoder (<code>LTX2Vocoder</code>)</p> <p>Inputs:
prompt (<code>str</code>, <em>optional</em>):
The prompt or prompts to guide image generation.
conditions (<code>list</code>, <em>optional</em>): <code>LTX2VideoCondition</code> (or list of them) placing image/video conditions at latent frame indices of the
generated video.
enable_prompt_enhancement (<code>bool</code>, <em>optional</em>, defaults to False):
Whether to run the prompt enhancer. Opt-in, matching the Lightricks reference pipelines.
system_prompt (<code>str</code>, <em>optional</em>):
System prompt for enhancement. Defaults to <code>LTX2_5_I2V_DEFAULT_SYSTEM_PROMPT</code> when a <code>PIL.Image.Image</code> condition frame is available, else <code>LTX2_5_T2V_DEFAULT_SYSTEM_PROMPT</code>.
prompt_max_new_tokens (<code>int</code>, <em>optional</em>):
Maximum number of new tokens to generate during prompt enhancement. Defaults to 600, the LTX-2.5 Gemma-4
enhancer’s budget.
prompt_enhancement_kwargs (<code>dict</code>, <em>optional</em>):
Keyword arguments for the enhancer’s <code>.generate</code> call. Defaults to greedy decoding.
prompt_enhancement_seed (<code>int</code>, <em>optional</em>, defaults to 10):
Random seed for prompt enhancement (inert under LTX-2.5’s greedy decoding).
generator (<code>Generator</code>, <em>optional</em>):
Torch generator for deterministic generation.
image (<code>Image | list</code>, <em>optional</em>):
Reference image(s) for denoising. Can be a single image or list of images.
negative_prompt (<code>str</code>, <em>optional</em>):
The prompt or prompts not to guide the image generation.
max_sequence_length (<code>int</code>, <em>optional</em>, defaults to 1024):
Maximum sequence length for prompt encoding.
min_seconds (<code>float</code>, <em>optional</em>, defaults to 1.0):
Lower bound on the auto-predicted duration.
max_seconds (<code>float</code>, <em>optional</em>, defaults to 20.0):
Upper bound on the auto-predicted duration. Must be strictly greater than <code>min_seconds</code>.
frame_rate (<code>float</code>, <em>optional</em>, defaults to 24.0):
Frames per second of the generated video.
height (<code>int</code>, <em>optional</em>, defaults to 512):
The height in pixels of the generated image.
width (<code>int</code>, <em>optional</em>, defaults to 704):
The width in pixels of the generated image.
image_crf (<code>int</code>, <em>optional</em>):
H.264 CRF used to re-compress the conditioning <code>image</code> before VAE encode, matching the compression the
model was trained against. <code>None</code> (default) resolves from the text-encoder generation (33 through
LTX-2.3, 18 for LTX-2.5). Pass <code>0</code> to skip re-compression. Requires a <code>PIL.Image.Image</code> when
re-compression runs.
num_frames (<code>int</code>, <em>optional</em>):
The number of frames in the generated video. Omit to auto-predict via the <code>duration_head</code> (see <code>LTX2AutoDurationStep</code>).
reference_conditions (<code>list</code>, <em>optional</em>): <code>LTX2ReferenceCondition</code> (or list of them) whose videos are encoded into extra latent tokens the IC-LoRA
adapter attends to.
reference_downscale_factor (<code>int</code>, <em>optional</em>, defaults to 1):
Ratio between the target and reference resolutions; 2 means the reference is preprocessed at half the
target resolution. Spatial coordinates are scaled by this factor so the reference tokens land in the
target coordinate space. Must match the factor the IC-LoRA was trained with.
conditioning_attention_strength (<code>float</code>, <em>optional</em>, defaults to 1.0):
Scalar in [0, 1] controlling how strongly the noisy tokens and reference tokens attend to each other. 1.0
(default) leaves attention unmasked.
conditioning_attention_mask (<code>Tensor</code>, <em>optional</em>):
Optional pixel-space mask of shape (1, 1, F, H, W) with values in [0, 1] giving spatially varying
attention strength. Downsampled to the reference’s latent grid and multiplied by <code>conditioning_attention_strength</code>.
num_videos_per_prompt (<code>int</code>, <em>optional</em>, defaults to 1):
The number of images to generate per prompt.
condition_latents (<code>list</code>, <em>optional</em>):
Per-condition normalized VAE latents of shape [1, C, F, H, W].
condition_strengths (<code>list</code>, <em>optional</em>):
Per-condition conditioning strengths.
condition_indices (<code>list</code>, <em>optional</em>):
Per-condition latent frame index at which the condition is applied.
condition_pixel_frames (<code>list</code>, <em>optional</em>):
Per-condition trimmed pixel frame count, used to clamp single-frame keyframe coords.
reference_latents (<code>Tensor</code>, <em>optional</em>):
Packed reference tokens of shape [1, total_reference_tokens, C], or <code>None</code> when no reference conditions
were supplied (<code>LTX2AutoReferenceEncoderStep</code> is skipped).
reference_coords (<code>Tensor</code>, <em>optional</em>):
RoPE coordinates for the reference tokens.
reference_token_counts (<code>list</code>, <em>optional</em>):
Per-reference token counts, in <code>reference_conditions</code> order.
latents (<code>Tensor</code>):
Pre-generated noisy latents for image generation.
noise_scale (<code>float</code>, <em>optional</em>):
Initial noise level for the un-conditioned tokens. <code>None</code> (default) resolves to <code>sigmas[0]</code> when custom <code>sigmas</code> are supplied, else 1.0.
sigmas (<code>list</code>, <em>optional</em>):
Custom sigmas for the denoising process.
reference_cross_mask (<code>Tensor</code>, <em>optional</em>):
Per-reference-token noisy&#60;->reference attention strengths of shape [1, num_ref_tokens].
num_inference_steps (<code>int</code>):
The number of denoising steps.
timesteps (<code>Tensor</code>):
Timesteps for the denoising process.
audio_latents (<code>Tensor</code>):
Optional pre-encoded audio latents; random noise is used when not provided.
*<em>denoiser_input_fields (<code>None</code>,</em>optional<em>):
conditional model inputs for the denoiser: e.g. prompt_embeds, negative_prompt_embeds, etc.
use_cross_timestep (<code>bool</code>,</em>optional<em>, defaults to True):
Whether to condition the transformer on a separate per-token cross timestep (LTX-2.3+).
attention_kwargs (<code>dict</code>,</em>optional<em>):
Additional kwargs for attention processors.
image_latents (<code>Tensor</code>,</em>optional<em>):
VAE-encoded reference-image latents used for image-to-video conditioning.
output_type (<code>str</code>,</em>optional*, defaults to pil):
Output format: ‘pil’, ‘np’, ‘pt’.</p> <p>Outputs:
videos (<code>list</code>):
The generated videos.
audio (<code>Tensor</code>):
The generated audio waveform.</p></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Single-modality guider for LTX-2.X. Combines up to three terms via the delta formulation:</p> <ul><li>classifier-free guidance (CFG),</li> <li>spatio-temporal guidance (STG), an extra pass with a set of transformer blocks perturbed,</li> <li>modality-isolation guidance, an extra pass with A2V/V2A cross-attention disabled.</li></ul> <p>Instantiated once per modality (<code>guider</code> for video, <code>audio_guider</code> for audio) with that modality’s scales;
that keeps the per-modality scales in independent, fully-defined component configs. The combine is done in
whatever space the caller feeds it — the LTX-2 denoiser converts velocity->x0 before calling this and back
afterwards, so <code>forward</code> operates on x0 predictions.</p></div> <!> <p></p>`,1);function No(Pe,qe){Xo(qe,!1),Go(()=>{new URLSearchParams(window.location.search).get("fw")}),Uo();var F=Wo();jo("13w6sgs",d=>{var c=Vo();vo(c,"content",Bo),p(d,c)});var Q=e(m(F),2);t(Q,{title:"LTX-2",local:"ltx-2",headingTag:"h1"});var Y=e(Q,10);t(Y,{title:"Two-stages Generation",local:"two-stages-generation",headingTag:"h2"});var S=e(Y,10);s(S,{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwRmxvd01hdGNoRXVsZXJEaXNjcmV0ZVNjaGVkdWxlciUwQWZyb20lMjBkaWZmdXNlcnMucGlwZWxpbmVzLmx0eDIlMjBpbXBvcnQlMjBMVFgyUGlwZWxpbmUlMkMlMjBMVFgyTGF0ZW50VXBzYW1wbGVQaXBlbGluZSUwQWZyb20lMjBkaWZmdXNlcnMucGlwZWxpbmVzLmx0eDIubGF0ZW50X3Vwc2FtcGxlciUyMGltcG9ydCUyMExUWDJMYXRlbnRVcHNhbXBsZXJNb2RlbCUwQWZyb20lMjBkaWZmdXNlcnMucGlwZWxpbmVzLmx0eDIudXRpbHMlMjBpbXBvcnQlMjBTVEFHRV8yX0RJU1RJTExFRF9TSUdNQV9WQUxVRVMlMEFmcm9tJTIwZGlmZnVzZXJzLnV0aWxzJTIwaW1wb3J0JTIwZW5jb2RlX3ZpZGVvJTBBJTBBZGV2aWNlJTIwJTNEJTIwJTIyY3VkYSUzQTAlMjIlMEF3aWR0aCUyMCUzRCUyMDc2OCUwQWhlaWdodCUyMCUzRCUyMDUxMiUwQSUwQXB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jAlMjAlMjBmcHMlM0RmcmFtZV9yYXRlJTJDJTBBJTIwJTIwJTIwJTIwYXVkaW8lM0RhdWRpbyU1QjAlNUQuZmxvYXQoKS5jcHUoKSUyQyUwQSUyMCUyMCUyMCUyMGF1ZGlvX3NhbXBsZV9yYXRlJTNEcGlwZS52b2NvZGVyLmNvbmZpZy5vdXRwdXRfc2FtcGxpbmdfcmF0ZSUyQyUwQSUyMCUyMCUyMCUyMG91dHB1dF9wYXRoJTNEJTIybHR4Ml9sb3JhX2Rpc3RpbGxlZF9zYW1wbGUubXA0JTIyJTJDJTBBKQ==",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> FlowMatchEulerDiscreteScheduler
<span class="hljs-keyword">from</span> diffusers.pipelines.ltx2 <span class="hljs-keyword">import</span> LTX2Pipeline, LTX2LatentUpsamplePipeline
<span class="hljs-keyword">from</span> diffusers.pipelines.ltx2.latent_upsampler <span class="hljs-keyword">import</span> LTX2LatentUpsamplerModel
<span class="hljs-keyword">from</span> diffusers.pipelines.ltx2.utils <span class="hljs-keyword">import</span> STAGE_2_DISTILLED_SIGMA_VALUES
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> encode_video
device = <span class="hljs-string">&quot;cuda:0&quot;</span>
width = <span class="hljs-number">768</span>
height = <span class="hljs-number">512</span>
pipe = LTX2Pipeline.from_pretrained(
<span class="hljs-string">&quot;Lightricks/LTX-2&quot;</span>, dtype=torch.bfloat16
)
pipe.enable_sequential_cpu_offload(device=device)
prompt = <span class="hljs-string">&quot;A beautiful sunset over the ocean&quot;</span>
negative_prompt = <span class="hljs-string">&quot;shaky, glitchy, low quality, worst quality, deformed, distorted, disfigured, motion smear, motion artifacts, fused fingers, bad anatomy, weird hand, ugly, transition, static.&quot;</span>
<span class="hljs-comment"># Stage 1 default (non-distilled) inference</span>
frame_rate = <span class="hljs-number">24.0</span>
video_latent, audio_latent = pipe(
prompt=prompt,
negative_prompt=negative_prompt,
width=width,
height=height,
num_frames=<span class="hljs-number">121</span>,
frame_rate=frame_rate,
num_inference_steps=<span class="hljs-number">30</span>,
sigmas=<span class="hljs-literal">None</span>,
guidance_scale=<span class="hljs-number">3.0</span>,
output_type=<span class="hljs-string">&quot;latent&quot;</span>,
return_dict=<span class="hljs-literal">False</span>,
)
latent_upsampler = LTX2LatentUpsamplerModel.from_pretrained(
<span class="hljs-string">&quot;Lightricks/LTX-2&quot;</span>,
subfolder=<span class="hljs-string">&quot;latent_upsampler&quot;</span>,
dtype=torch.bfloat16,
)
upsample_pipe = LTX2LatentUpsamplePipeline(vae=pipe.vae, latent_upsampler=latent_upsampler)
upsample_pipe.enable_model_cpu_offload(device=device)
upscaled_video_latent = upsample_pipe(
latents=video_latent,
output_type=<span class="hljs-string">&quot;latent&quot;</span>,
return_dict=<span class="hljs-literal">False</span>,
)[<span class="hljs-number">0</span>]
<span class="hljs-comment"># Load Stage 2 distilled LoRA</span>
pipe.load_lora_weights(
<span class="hljs-string">&quot;Lightricks/LTX-2&quot;</span>, adapter_name=<span class="hljs-string">&quot;stage_2_distilled&quot;</span>, weight_name=<span class="hljs-string">&quot;ltx-2-19b-distilled-lora-384.safetensors&quot;</span>
)
pipe.set_adapters(<span class="hljs-string">&quot;stage_2_distilled&quot;</span>, <span class="hljs-number">1.0</span>)
<span class="hljs-comment"># VAE tiling is usually necessary to avoid OOM error when VAE decoding</span>
pipe.vae.enable_tiling()
<span class="hljs-comment"># Change scheduler to use Stage 2 distilled sigmas as is</span>
new_scheduler = FlowMatchEulerDiscreteScheduler.from_config(
pipe.scheduler.config, use_dynamic_shifting=<span class="hljs-literal">False</span>, shift_terminal=<span class="hljs-literal">None</span>
)
pipe.scheduler = new_scheduler
<span class="hljs-comment"># Stage 2 inference with distilled LoRA and sigmas</span>
video, audio = pipe(
latents=upscaled_video_latent,
audio_latents=audio_latent,
prompt=prompt,
negative_prompt=negative_prompt,
num_inference_steps=<span class="hljs-number">3</span>,
noise_scale=STAGE_2_DISTILLED_SIGMA_VALUES[<span class="hljs-number">0</span>], <span class="hljs-comment"># renoise with first sigma value https://github.com/Lightricks/LTX-2/blob/main/packages/ltx-pipelines/src/ltx_pipelines/ti2vid_two_stages.py#L218</span>
sigmas=STAGE_2_DISTILLED_SIGMA_VALUES,
guidance_scale=<span class="hljs-number">1.0</span>,
output_type=<span class="hljs-string">&quot;np&quot;</span>,
return_dict=<span class="hljs-literal">False</span>,
)
encode_video(
video[<span class="hljs-number">0</span>],
fps=frame_rate,
audio=audio[<span class="hljs-number">0</span>].<span class="hljs-built_in">float</span>().cpu(),
audio_sample_rate=pipe.vocoder.config.output_sampling_rate,
output_path=<span class="hljs-string">&quot;ltx2_lora_distilled_sample.mp4&quot;</span>,
)`,lang:"py",wrap:!1});var A=e(S,2);t(A,{title:"Distilled checkpoint generation",local:"distilled-checkpoint-generation",headingTag:"h2"});var z=e(A,4);s(z,{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzLnBpcGVsaW5lcy5sdHgyJTIwaW1wb3J0JTIwTFRYMlBpcGVsaW5lJTJDJTIwTFRYMkxhdGVudFVwc2FtcGxlUGlwZWxpbmUlMEFmcm9tJTIwZGlmZnVzZXJzLnBpcGVsaW5lcy5sdHgyLmxhdGVudF91cHNhbXBsZXIlMjBpbXBvcnQlMjBMVFgyTGF0ZW50VXBzYW1wbGVyTW9kZWwlMEFmcm9tJTIwZGlmZnVzZXJzLnBpcGVsaW5lcy5sdHgyLnV0aWxzJTIwaW1wb3J0JTIwRElTVElMTEVEX1NJR01BX1ZBTFVFUyUyQyUyMFNUQUdFXzJfRElTVElMTEVEX1NJR01BX1ZBTFVFUyUwQWZyb20lMjBkaWZmdXNlcnMudXRpbHMlMjBpbXBvcnQlMjBlbmNvZGVfdmlkZW8lMEElMEFkZXZpY2UlMjAlM0QlMjAlMjJjdWRhJTIyJTBBd2lkdGglMjAlM0QlMjA3NjglMEFoZWlnaHQlMjAlM0Q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QyUwQSUyMCUyMCUyMCUyMGd1aWRhbmNlX3NjYWxlJTNEMS4wJTJDJTBBJTIwJTIwJTIwJTIwb3V0cHV0X3R5cGUlM0QlMjJucCUyMiUyQyUwQSUyMCUyMCUyMCUyMHJldHVybl9kaWN0JTNERmFsc2UlMkMlMEEpJTBBJTBBZW5jb2RlX3ZpZGVvKCUwQSUyMCUyMCUyMCUyMHZpZGVvJTVCMCU1RCUyQyUwQSUyMCUyMCUyMCUyMGZwcyUzRGZyYW1lX3JhdGUlMkMlMEElMjAlMjAlMjAlMjBhdWRpbyUzRGF1ZGlvJTVCMCU1RC5mbG9hdCgpLmNwdSgpJTJDJTBBJTIwJTIwJTIwJTIwYXVkaW9fc2FtcGxlX3JhdGUlM0RwaXBlLnZvY29kZXIuY29uZmlnLm91dHB1dF9zYW1wbGluZ19yYXRlJTJDJTBBJTIwJTIwJTIwJTIwb3V0cHV0X3BhdGglM0QlMjJsdHgyX2Rpc3RpbGxlZF9zYW1wbGUubXA0JTIyJTJDJTBBKQ==",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers.pipelines.ltx2 <span class="hljs-keyword">import</span> LTX2Pipeline, LTX2LatentUpsamplePipeline
<span class="hljs-keyword">from</span> diffusers.pipelines.ltx2.latent_upsampler <span class="hljs-keyword">import</span> LTX2LatentUpsamplerModel
<span class="hljs-keyword">from</span> diffusers.pipelines.ltx2.utils <span class="hljs-keyword">import</span> DISTILLED_SIGMA_VALUES, STAGE_2_DISTILLED_SIGMA_VALUES
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> encode_video
device = <span class="hljs-string">&quot;cuda&quot;</span>
width = <span class="hljs-number">768</span>
height = <span class="hljs-number">512</span>
random_seed = <span class="hljs-number">42</span>
generator = torch.Generator(device).manual_seed(random_seed)
model_path = <span class="hljs-string">&quot;rootonchair/LTX-2-19b-distilled&quot;</span>
pipe = LTX2Pipeline.from_pretrained(
model_path, dtype=torch.bfloat16
)
pipe.enable_sequential_cpu_offload(device=device)
prompt = <span class="hljs-string">&quot;A beautiful sunset over the ocean&quot;</span>
negative_prompt = <span class="hljs-string">&quot;shaky, glitchy, low quality, worst quality, deformed, distorted, disfigured, motion smear, motion artifacts, fused fingers, bad anatomy, weird hand, ugly, transition, static.&quot;</span>
frame_rate = <span class="hljs-number">24.0</span>
video_latent, audio_latent = pipe(
prompt=prompt,
negative_prompt=negative_prompt,
width=width,
height=height,
num_frames=<span class="hljs-number">121</span>,
frame_rate=frame_rate,
num_inference_steps=<span class="hljs-number">8</span>,
sigmas=DISTILLED_SIGMA_VALUES,
guidance_scale=<span class="hljs-number">1.0</span>,
generator=generator,
output_type=<span class="hljs-string">&quot;latent&quot;</span>,
return_dict=<span class="hljs-literal">False</span>,
)
latent_upsampler = LTX2LatentUpsamplerModel.from_pretrained(
model_path,
subfolder=<span class="hljs-string">&quot;latent_upsampler&quot;</span>,
dtype=torch.bfloat16,
)
upsample_pipe = LTX2LatentUpsamplePipeline(vae=pipe.vae, latent_upsampler=latent_upsampler)
upsample_pipe.enable_model_cpu_offload(device=device)
upscaled_video_latent = upsample_pipe(
latents=video_latent,
output_type=<span class="hljs-string">&quot;latent&quot;</span>,
return_dict=<span class="hljs-literal">False</span>,
)[<span class="hljs-number">0</span>]
video, audio = pipe(
latents=upscaled_video_latent,
audio_latents=audio_latent,
prompt=prompt,
negative_prompt=negative_prompt,
num_inference_steps=<span class="hljs-number">3</span>,
noise_scale=STAGE_2_DISTILLED_SIGMA_VALUES[<span class="hljs-number">0</span>], <span class="hljs-comment"># renoise with first sigma value https://github.com/Lightricks/LTX-2/blob/main/packages/ltx-pipelines/src/ltx_pipelines/distilled.py#L178</span>
sigmas=STAGE_2_DISTILLED_SIGMA_VALUES,
generator=generator,
guidance_scale=<span class="hljs-number">1.0</span>,
output_type=<span class="hljs-string">&quot;np&quot;</span>,
return_dict=<span class="hljs-literal">False</span>,
)
encode_video(
video[<span class="hljs-number">0</span>],
fps=frame_rate,
audio=audio[<span class="hljs-number">0</span>].<span class="hljs-built_in">float</span>().cpu(),
audio_sample_rate=pipe.vocoder.config.output_sampling_rate,
output_path=<span class="hljs-string">&quot;ltx2_distilled_sample.mp4&quot;</span>,
)`,lang:"py",wrap:!1});var H=e(z,2);t(H,{title:"Condition Pipeline Generation",local:"condition-pipeline-generation",headingTag:"h2"});var D=e(H,4);s(D,{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwTFRYMkNvbmRpdGlvblBpcGVsaW5lJTJDJTIwTFRYMkxhdGVudFVwc2FtcGxlUGlwZWxpbmUlMEFmcm9tJTIwZGlmZnVzZXJzLnBpcGVsaW5lcy5sdHgyLmxhdGVudF91cHNhbXBsZXIlMjBpbXBvcnQlMjBMVFgyTGF0ZW50VXBzYW1wbGVyTW9kZWwlMEFmcm9tJTIwZGlmZnVzZXJzLnBpcGVsaW5lcy5sdHgyLnBpcGVsaW5lX2x0eDJfY29uZGl0aW9uJTIwaW1wb3J0JTIwTFRYMlZpZGVvQ29uZGl0aW9uJTBBZnJvbSUyMGRpZmZ1c2Vycy5waXBlbGluZXMubHR4Mi51dGlscyUyMGltcG9ydCUyMERJU1RJTExFRF9TSUdNQV9WQUxVRVMlMkMlMjBTVEFHRV8yX0RJU1RJTExFRF9TSUdNQV9WQUxVRVMlMEFmcm9tJTIwZGlmZnVzZXJzLnV0aWxzJTIwaW1wb3J0JTIwZW5jb2RlX3ZpZGVvJTBBZnJvbSUyMGRpZmZ1c2Vycy51dGlscyUyMGltcG9ydCUyMGxvYWRfaW1hZ2UlMEElMEFkZXZpY2UlMjAlM0QlMjAlMjJjdWRhJTIyJTBBd2lkdGglMjAlM0QlMjA3NjglMEFoZWlnaHQlMjAlM0QlMjA1MTIlMEFyYW5kb21fc2VlZCUyMCUzRCUyMDQyJTBBZ2VuZXJhdG9yJTIwJTNEJTIwdG9yY2guR2VuZXJhdG9yKGRldmljZSkubWFudWFsX3NlZWQocm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IwJTIwJTIwYXVkaW8lM0RhdWRpbyU1QjAlNUQuZmxvYXQoKS5jcHUoKSUyQyUwQSUyMCUyMCUyMCUyMGF1ZGlvX3NhbXBsZV9yYXRlJTNEcGlwZS52b2NvZGVyLmNvbmZpZy5vdXRwdXRfc2FtcGxpbmdfcmF0ZSUyQyUwQSUyMCUyMCUyMCUyMG91dHB1dF9wYXRoJTNEJTIybHR4Ml9kaXN0aWxsZWRfZmxmMnYubXA0JTIyJTJDJTBBKQ==",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> LTX2ConditionPipeline, LTX2LatentUpsamplePipeline
<span class="hljs-keyword">from</span> diffusers.pipelines.ltx2.latent_upsampler <span class="hljs-keyword">import</span> LTX2LatentUpsamplerModel
<span class="hljs-keyword">from</span> diffusers.pipelines.ltx2.pipeline_ltx2_condition <span class="hljs-keyword">import</span> LTX2VideoCondition
<span class="hljs-keyword">from</span> diffusers.pipelines.ltx2.utils <span class="hljs-keyword">import</span> DISTILLED_SIGMA_VALUES, STAGE_2_DISTILLED_SIGMA_VALUES
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> encode_video
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image
device = <span class="hljs-string">&quot;cuda&quot;</span>
width = <span class="hljs-number">768</span>
height = <span class="hljs-number">512</span>
random_seed = <span class="hljs-number">42</span>
generator = torch.Generator(device).manual_seed(random_seed)
model_path = <span class="hljs-string">&quot;rootonchair/LTX-2-19b-distilled&quot;</span>
pipe = LTX2ConditionPipeline.from_pretrained(model_path, dtype=torch.bfloat16)
pipe.enable_sequential_cpu_offload(device=device)
pipe.vae.enable_tiling()
prompt = (
<span class="hljs-string">&quot;CG animation style, a small blue bird takes off from the ground, flapping its wings. The bird&#x27;s feathers are &quot;</span>
<span class="hljs-string">&quot;delicate, with a unique pattern on its chest. The background shows a blue sky with white clouds under bright &quot;</span>
<span class="hljs-string">&quot;sunshine. The camera follows the bird upward, capturing its flight and the vastness of the sky from a close-up, &quot;</span>
<span class="hljs-string">&quot;low-angle perspective.&quot;</span>
)
first_image = load_image(
<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/flf2v_input_first_frame.png&quot;</span>,
)
last_image = load_image(
<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/flf2v_input_last_frame.png&quot;</span>,
)
first_cond = LTX2VideoCondition(frames=first_image, index=<span class="hljs-number">0</span>, strength=<span class="hljs-number">1.0</span>)
last_cond = LTX2VideoCondition(frames=last_image, index=-<span class="hljs-number">1</span>, strength=<span class="hljs-number">1.0</span>)
conditions = [first_cond, last_cond]
frame_rate = <span class="hljs-number">24.0</span>
video_latent, audio_latent = pipe(
conditions=conditions,
prompt=prompt,
width=width,
height=height,
num_frames=<span class="hljs-number">121</span>,
frame_rate=frame_rate,
num_inference_steps=<span class="hljs-number">8</span>,
sigmas=DISTILLED_SIGMA_VALUES,
guidance_scale=<span class="hljs-number">1.0</span>,
generator=generator,
output_type=<span class="hljs-string">&quot;latent&quot;</span>,
return_dict=<span class="hljs-literal">False</span>,
)
latent_upsampler = LTX2LatentUpsamplerModel.from_pretrained(
model_path,
subfolder=<span class="hljs-string">&quot;latent_upsampler&quot;</span>,
dtype=torch.bfloat16,
)
upsample_pipe = LTX2LatentUpsamplePipeline(vae=pipe.vae, latent_upsampler=latent_upsampler)
upsample_pipe.enable_model_cpu_offload(device=device)
upscaled_video_latent = upsample_pipe(
latents=video_latent,
output_type=<span class="hljs-string">&quot;latent&quot;</span>,
return_dict=<span class="hljs-literal">False</span>,
)[<span class="hljs-number">0</span>]
video, audio = pipe(
latents=upscaled_video_latent,
audio_latents=audio_latent,
prompt=prompt,
width=width * <span class="hljs-number">2</span>,
height=height * <span class="hljs-number">2</span>,
num_inference_steps=<span class="hljs-number">3</span>,
sigmas=STAGE_2_DISTILLED_SIGMA_VALUES,
generator=generator,
guidance_scale=<span class="hljs-number">1.0</span>,
output_type=<span class="hljs-string">&quot;np&quot;</span>,
return_dict=<span class="hljs-literal">False</span>,
)
encode_video(
video[<span class="hljs-number">0</span>],
fps=frame_rate,
audio=audio[<span class="hljs-number">0</span>].<span class="hljs-built_in">float</span>().cpu(),
audio_sample_rate=pipe.vocoder.config.output_sampling_rate,
output_path=<span class="hljs-string">&quot;ltx2_distilled_flf2v.mp4&quot;</span>,
)`,lang:"py",wrap:!1});var P=e(D,4);s(P,{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwTFRYMkNvbmRpdGlvblBpcGVsaW5lJTBBZnJvbSUyMGRpZmZ1c2Vycy5waXBlbGluZXMubHR4Mi5waXBlbGluZV9sdHgyX2NvbmRpdGlvbiUyMGltcG9ydCUyMExUWDJWaWRlb0NvbmRpdGlvbiUwQWZyb20lMjBkaWZmdXNlcnMudXRpbHMlMjBpbXBvcnQlMjBlbmNvZGVfdmlkZW8lMEFmcm9tJTIwZGlmZnVzZXJzLnBpcGVsaW5lcy5sdHgyLnV0aWxzJTIwaW1wb3J0JTIwREVGQVVMVF9ORUdBVElWRV9QUk9NUFQlMEFmcm9tJTIwZGlmZnVzZXJzLnV0aWxzJTIwaW1wb3J0JTIwbG9hZF9pbWFnZSUyQyUyMGxvYWRfdmlkZW8lMEElMEFkZXZpY2UlMjAlM0QlMjAlMjJjdWRhJTIyJTBBd2lkdGglMjAlM0QlMjA3NjglMEFoZWlnaHQlMjAlM0QlMjA1MTIlMEFyYW5kb21fc2VlZCUyMCUzRCUyMDQyJTBBZ2VuZXJhdG9yJTIwJTNEJTIwdG9yY2guR2VuZXJhdG9yKGRldmljZSkubWFudWFsX3NlZWQocmFuZG9tX3NlZWQpJTBBbW9kZWxfcGF0aCUyMCUzRCUyMCUyMnJvb3RvbmNoYWlyJTJGTFRYLTItMTliLWRpc3RpbGxlZCUyMiUwQSUwQXBpcGUlMjAlM0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0QzMCUyQyUwQSUyMCUyMCUyMCUyMGd1aWRhbmNlX3NjYWxlJTNEMy4wJTJDJTBBJTIwJTIwJTIwJTIwZ2VuZXJhdG9yJTNEZ2VuZXJhdG9yJTJDJTBBJTIwJTIwJTIwJTIwb3V0cHV0X3R5cGUlM0QlMjJucCUyMiUyQyUwQSUyMCUyMCUyMCUyMHJldHVybl9kaWN0JTNERmFsc2UlMkMlMEEpJTBBJTBBZW5jb2RlX3ZpZGVvKCUwQSUyMCUyMCUyMCUyMHZpZGVvJTVCMCU1RCUyQyUwQSUyMCUyMCUyMCUyMGZwcyUzRGZyYW1lX3JhdGUlMkMlMEElMjAlMjAlMjAlMjBhdWRpbyUzRGF1ZGlvJTVCMCU1RC5mbG9hdCgpLmNwdSgpJTJDJTBBJTIwJTIwJTIwJTIwYXVkaW9fc2FtcGxlX3JhdGUlM0RwaXBlLnZvY29kZXIuY29uZmlnLm91dHB1dF9zYW1wbGluZ19yYXRlJTJDJTBBJTIwJTIwJTIwJTIwb3V0cHV0X3BhdGglM0QlMjJsdHgyX2NvbmRfdmlkZW8ubXA0JTIyJTJDJTBBKQ==",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> LTX2ConditionPipeline
<span class="hljs-keyword">from</span> diffusers.pipelines.ltx2.pipeline_ltx2_condition <span class="hljs-keyword">import</span> LTX2VideoCondition
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> encode_video
<span class="hljs-keyword">from</span> diffusers.pipelines.ltx2.utils <span class="hljs-keyword">import</span> DEFAULT_NEGATIVE_PROMPT
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image, load_video
device = <span class="hljs-string">&quot;cuda&quot;</span>
width = <span class="hljs-number">768</span>
height = <span class="hljs-number">512</span>
random_seed = <span class="hljs-number">42</span>
generator = torch.Generator(device).manual_seed(random_seed)
model_path = <span class="hljs-string">&quot;rootonchair/LTX-2-19b-distilled&quot;</span>
pipe = LTX2ConditionPipeline.from_pretrained(model_path, dtype=torch.bfloat16)
pipe.enable_sequential_cpu_offload(device=device)
pipe.vae.enable_tiling()
prompt = (
<span class="hljs-string">&quot;The video depicts a long, straight highway stretching into the distance, flanked by metal guardrails. The road is &quot;</span>
<span class="hljs-string">&quot;divided into multiple lanes, with a few vehicles visible in the far distance. The surrounding landscape features &quot;</span>
<span class="hljs-string">&quot;dry, grassy fields on one side and rolling hills on the other. The sky is mostly clear with a few scattered &quot;</span>
<span class="hljs-string">&quot;clouds, suggesting a bright, sunny day. And then the camera switch to a winding mountain road covered in snow, &quot;</span>
<span class="hljs-string">&quot;with a single vehicle traveling along it. The road is flanked by steep, rocky cliffs and sparse vegetation. The &quot;</span>
<span class="hljs-string">&quot;landscape is characterized by rugged terrain and a river visible in the distance. The scene captures the &quot;</span>
<span class="hljs-string">&quot;solitude and beauty of a winter drive through a mountainous region.&quot;</span>
)
cond_video = load_video(
<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cosmos/cosmos-video2world-input-vid.mp4&quot;</span>
)
cond_image = load_image(
<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cosmos/cosmos-video2world-input.jpg&quot;</span>
)
video_cond = LTX2VideoCondition(frames=cond_video, index=<span class="hljs-number">0</span>, strength=<span class="hljs-number">1.0</span>)
image_cond = LTX2VideoCondition(frames=cond_image, index=<span class="hljs-number">8</span>, strength=<span class="hljs-number">1.0</span>)
conditions = [video_cond, image_cond]
frame_rate = <span class="hljs-number">24.0</span>
video, audio = pipe(
conditions=conditions,
prompt=prompt,
negative_prompt=DEFAULT_NEGATIVE_PROMPT,
width=width,
height=height,
num_frames=<span class="hljs-number">121</span>,
frame_rate=frame_rate,
num_inference_steps=<span class="hljs-number">30</span>,
guidance_scale=<span class="hljs-number">3.0</span>,
generator=generator,
output_type=<span class="hljs-string">&quot;np&quot;</span>,
return_dict=<span class="hljs-literal">False</span>,
)
encode_video(
video[<span class="hljs-number">0</span>],
fps=frame_rate,
audio=audio[<span class="hljs-number">0</span>].<span class="hljs-built_in">float</span>().cpu(),
audio_sample_rate=pipe.vocoder.config.output_sampling_rate,
output_path=<span class="hljs-string">&quot;ltx2_cond_video.mp4&quot;</span>,
)`,lang:"py",wrap:!1});var q=e(P,4);t(q,{title:"Multimodal Guidance",local:"multimodal-guidance",headingTag:"h2"});var K=e(q,8);s(K,{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwTFRYMkltYWdlVG9WaWRlb1BpcGVsaW5lJTBBZnJvbSUyMGRpZmZ1c2Vycy51dGlscyUyMGltcG9ydCUyMGVuY29kZV92aWRlbyUwQWZyb20lMjBkaWZmdXNlcnMucGlwZWxpbmVzLmx0eDIudXRpbHMlMjBpbXBvcnQlMjBERUZBVUxUX05FR0FUSVZFX1BST01QVCUwQWZyb20lMjBkaWZmdXNlcnMudXRpbHMlMjBpbXBvcnQlMjBsb2FkX2ltYWdlJTBBJTBBZGV2aWNlJTIwJTNEJTIwJTIyY3VkYSUyMiUwQXdpZHRoJTIwJTNEJTIwNzY4JTBBaGVpZ2h0JTIwJTNEJTIwNTEyJTBBcmFuZG9tX3NlZWQlMjAlM0QlMjA0MiUwQWZyYW1lX3JhdGUlMjAlM0QlMjAyNC4wJTBBZ2VuZXJhdG9yJTIwJTNEJTIwdG9yY2guR2VuZXJhdG9yKGRldmljZSkubWFudWFsX3NlZWQocmFuZG9tX3NlZWQpJTBBbW9kZWxfcGF0aCUyMCUzRCUyMCUyMmRpZmZ1c2VycyUyRkxUWC0yLjMtRGlmZnVzZXJzJTIyJTBBJTBBcGlwZSUyMCUzRCUyMExUWDJJbWFnZVRvVmlkZW9QaXBlbGluZS5mcm9tX3ByZXRyYWluZWQobW9kZWxfcGF0aCUyQyUyMGR0eXBlJTNEdG9yY2guYmZsb2F0MTYpJTBBcGlwZS5lbmFibGVfc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DEuMCUyQyUwQSUyMCUyMCUyMCUyMGF1ZGlvX21vZGFsaXR5X3NjYWxlJTNEMy4wJTJDJTBBJTIwJTIwJTIwJTIwYXVkaW9fZ3VpZGFuY2VfcmVzY2FsZSUzRDAuNyUyQyUwQSUyMCUyMCUyMCUyMHNwYXRpb190ZW1wb3JhbF9ndWlkYW5jZV9ibG9ja3MlM0QlNUIyOCU1RCUyQyUwQSUyMCUyMCUyMCUyMHVzZV9jcm9zc190aW1lc3RlcCUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjBnZW5lcmF0b3IlM0RnZW5lcmF0b3IlMkMlMEElMjAlMjAlMjAlMjBvdXRwdXRfdHlwZSUzRCUyMm5wJTIyJTJDJTBBJTIwJTIwJTIwJTIwcmV0dXJuX2RpY3QlM0RGYWxzZSUyQyUwQSklMEElMEFlbmNvZGVfdmlkZW8oJTBBJTIwJTIwJTIwJTIwdmlkZW8lNUIwJTVEJTJDJTBBJTIwJTIwJTIwJTIwZnBzJTNEZnJhbWVfcmF0ZSUyQyUwQSUyMCUyMCUyMCUyMGF1ZGlvJTNEYXVkaW8lNUIwJTVELmZsb2F0KCkuY3B1KCklMkMlMEElMjAlMjAlMjAlMjBhdWRpb19zYW1wbGVfcmF0ZSUzRHBpcGUudm9jb2Rlci5jb25maWcub3V0cHV0X3NhbXBsaW5nX3JhdGUlMkMlMEElMjAlMjAlMjAlMjBvdXRwdXRfcGF0aCUzRCUyMmx0eDJfM19pMnZfc3RhZ2VfMS5tcDQlMjIlMkMlMEEp",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> LTX2ImageToVideoPipeline
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> encode_video
<span class="hljs-keyword">from</span> diffusers.pipelines.ltx2.utils <span class="hljs-keyword">import</span> DEFAULT_NEGATIVE_PROMPT
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image
device = <span class="hljs-string">&quot;cuda&quot;</span>
width = <span class="hljs-number">768</span>
height = <span class="hljs-number">512</span>
random_seed = <span class="hljs-number">42</span>
frame_rate = <span class="hljs-number">24.0</span>
generator = torch.Generator(device).manual_seed(random_seed)
model_path = <span class="hljs-string">&quot;diffusers/LTX-2.3-Diffusers&quot;</span>
pipe = LTX2ImageToVideoPipeline.from_pretrained(model_path, dtype=torch.bfloat16)
pipe.enable_sequential_cpu_offload(device=device)
pipe.vae.enable_tiling()
prompt = (
<span class="hljs-string">&quot;An astronaut hatches from a fragile egg on the surface of the Moon, the shell cracking and peeling apart in &quot;</span>
<span class="hljs-string">&quot;gentle low-gravity motion. Fine lunar dust lifts and drifts outward with each movement, floating in slow arcs &quot;</span>
<span class="hljs-string">&quot;before settling back onto the ground. The astronaut pushes free in a deliberate, weightless motion, small &quot;</span>
<span class="hljs-string">&quot;fragments of the egg tumbling and spinning through the air. In the background, the deep darkness of space subtly &quot;</span>
<span class="hljs-string">&quot;shifts as stars glide with the camera&#x27;s movement, emphasizing vast depth and scale. The camera performs a &quot;</span>
<span class="hljs-string">&quot;smooth, cinematic slow push-in, with natural parallax between the foreground dust, the astronaut, and the &quot;</span>
<span class="hljs-string">&quot;distant starfield. Ultra-realistic detail, physically accurate low-gravity motion, cinematic lighting, and a &quot;</span>
<span class="hljs-string">&quot;breath-taking, movie-like shot.&quot;</span>
)
image = load_image(
<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/astronaut.jpg&quot;</span>,
)
video, audio = pipe(
image=image,
prompt=prompt,
negative_prompt=DEFAULT_NEGATIVE_PROMPT,
width=width,
height=height,
num_frames=<span class="hljs-number">121</span>,
frame_rate=frame_rate,
num_inference_steps=<span class="hljs-number">30</span>,
guidance_scale=<span class="hljs-number">3.0</span>, <span class="hljs-comment"># Recommended LTX-2.3 guidance parameters</span>
stg_scale=<span class="hljs-number">1.0</span>, <span class="hljs-comment"># Note that 0.0 (not 1.0) means that STG is disabled (all other guidance is disabled at 1.0)</span>
modality_scale=<span class="hljs-number">3.0</span>,
guidance_rescale=<span class="hljs-number">0.7</span>,
audio_guidance_scale=<span class="hljs-number">7.0</span>, <span class="hljs-comment"># Note that a higher CFG guidance scale is recommended for audio</span>
audio_stg_scale=<span class="hljs-number">1.0</span>,
audio_modality_scale=<span class="hljs-number">3.0</span>,
audio_guidance_rescale=<span class="hljs-number">0.7</span>,
spatio_temporal_guidance_blocks=[<span class="hljs-number">28</span>],
use_cross_timestep=<span class="hljs-literal">True</span>,
generator=generator,
output_type=<span class="hljs-string">&quot;np&quot;</span>,
return_dict=<span class="hljs-literal">False</span>,
)
encode_video(
video[<span class="hljs-number">0</span>],
fps=frame_rate,
audio=audio[<span class="hljs-number">0</span>].<span class="hljs-built_in">float</span>().cpu(),
audio_sample_rate=pipe.vocoder.config.output_sampling_rate,
output_path=<span class="hljs-string">&quot;ltx2_3_i2v_stage_1.mp4&quot;</span>,
)`,lang:"py",wrap:!1});var O=e(K,2);t(O,{title:"Prompt Enhancement",local:"prompt-enhancement",headingTag:"h2"});var $=e(O,4);s($,{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwR2VtbWEzUHJvY2Vzc29yJTBBZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMExUWDJQaXBlbGluZSUwQWZyb20lMjBkaWZmdXNlcnMudXRpbHMlMjBpbXBvcnQlMjBlbmNvZGVfdmlkZW8lMEFmcm9tJTIwZGlmZnVzZXJzLnBpcGVsaW5lcy5sdHgyLnV0aWxzJTIwaW1wb3J0JTIwREVGQVVMVF9ORUdBVElWRV9QUk9NUFQlMkMlMjBUMlZfREVGQVVMVF9TWVNURU1fUFJPTVBUJTBBJTBBZGV2aWNlJTIwJTNEJTIwJTIyY3VkYSUyMiUwQXdpZHRoJTIwJTNEJTIwNzY4JTBBaGVpZ2h0JTIwJTNEJTIwNTEyJTBBcmFuZG9tX3NlZWQlMjAl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VkaW9fbW9kYWxpdHlfc2NhbGUlM0QzLjAlMkMlMEElMjAlMjAlMjAlMjBhdWRpb19ndWlkYW5jZV9yZXNjYWxlJTNEMC43JTJDJTBBJTIwJTIwJTIwJTIwc3BhdGlvX3RlbXBvcmFsX2d1aWRhbmNlX2Jsb2NrcyUzRCU1QjI4JTVEJTJDJTBBJTIwJTIwJTIwJTIwdXNlX2Nyb3NzX3RpbWVzdGVwJTNEVHJ1ZSUyQyUwQSUyMCUyMCUyMCUyMGVuYWJsZV9wcm9tcHRfZW5oYW5jZW1lbnQlM0RUcnVlJTJDJTBBJTIwJTIwJTIwJTIwc3lzdGVtX3Byb21wdCUzRFQyVl9ERUZBVUxUX1NZU1RFTV9QUk9NUFQlMkMlMEElMjAlMjAlMjAlMjBnZW5lcmF0b3IlM0RnZW5lcmF0b3IlMkMlMEElMjAlMjAlMjAlMjBvdXRwdXRfdHlwZSUzRCUyMm5wJTIyJTJDJTBBJTIwJTIwJTIwJTIwcmV0dXJuX2RpY3QlM0RGYWxzZSUyQyUwQSklMEElMEFlbmNvZGVfdmlkZW8oJTBBJTIwJTIwJTIwJTIwdmlkZW8lNUIwJTVEJTJDJTBBJTIwJTIwJTIwJTIwZnBzJTNEZnJhbWVfcmF0ZSUyQyUwQSUyMCUyMCUyMCUyMGF1ZGlvJTNEYXVkaW8lNUIwJTVELmZsb2F0KCkuY3B1KCklMkMlMEElMjAlMjAlMjAlMjBhdWRpb19zYW1wbGVfcmF0ZSUzRHBpcGUudm9jb2Rlci5jb25maWcub3V0cHV0X3NhbXBsaW5nX3JhdGUlMkMlMEElMjAlMjAlMjAlMjBvdXRwdXRfcGF0aCUzRCUyMmx0eDJfM190MnZfc3RhZ2VfMS5tcDQlMjIlMkMlMEEp",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> Gemma3Processor
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> LTX2Pipeline
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> encode_video
<span class="hljs-keyword">from</span> diffusers.pipelines.ltx2.utils <span class="hljs-keyword">import</span> DEFAULT_NEGATIVE_PROMPT, T2V_DEFAULT_SYSTEM_PROMPT
device = <span class="hljs-string">&quot;cuda&quot;</span>
width = <span class="hljs-number">768</span>
height = <span class="hljs-number">512</span>
random_seed = <span class="hljs-number">42</span>
frame_rate = <span class="hljs-number">24.0</span>
generator = torch.Generator(device).manual_seed(random_seed)
model_path = <span class="hljs-string">&quot;diffusers/LTX-2.3-Diffusers&quot;</span>
pipe = LTX2Pipeline.from_pretrained(model_path, dtype=torch.bfloat16)
pipe.enable_model_cpu_offload(device=device)
pipe.vae.enable_tiling()
<span class="hljs-keyword">if</span> <span class="hljs-built_in">getattr</span>(pipe, <span class="hljs-string">&quot;processor&quot;</span>, <span class="hljs-literal">None</span>) <span class="hljs-keyword">is</span> <span class="hljs-literal">None</span>:
processor = Gemma3Processor.from_pretrained(<span class="hljs-string">&quot;google/gemma-3-12b-it-qat-q4_0-unquantized&quot;</span>)
pipe.processor = processor
prompt = (
<span class="hljs-string">&quot;An astronaut hatches from a fragile egg on the surface of the Moon, the shell cracking and peeling apart in &quot;</span>
<span class="hljs-string">&quot;gentle low-gravity motion. Fine lunar dust lifts and drifts outward with each movement, floating in slow arcs &quot;</span>
<span class="hljs-string">&quot;before settling back onto the ground. The astronaut pushes free in a deliberate, weightless motion, small &quot;</span>
<span class="hljs-string">&quot;fragments of the egg tumbling and spinning through the air. In the background, the deep darkness of space subtly &quot;</span>
<span class="hljs-string">&quot;shifts as stars glide with the camera&#x27;s movement, emphasizing vast depth and scale. The camera performs a &quot;</span>
<span class="hljs-string">&quot;smooth, cinematic slow push-in, with natural parallax between the foreground dust, the astronaut, and the &quot;</span>
<span class="hljs-string">&quot;distant starfield. Ultra-realistic detail, physically accurate low-gravity motion, cinematic lighting, and a &quot;</span>
<span class="hljs-string">&quot;breath-taking, movie-like shot.&quot;</span>
)
video, audio = pipe(
prompt=prompt,
negative_prompt=DEFAULT_NEGATIVE_PROMPT,
width=width,
height=height,
num_frames=<span class="hljs-number">121</span>,
frame_rate=frame_rate,
num_inference_steps=<span class="hljs-number">30</span>,
guidance_scale=<span class="hljs-number">3.0</span>,
stg_scale=<span class="hljs-number">1.0</span>,
modality_scale=<span class="hljs-number">3.0</span>,
guidance_rescale=<span class="hljs-number">0.7</span>,
audio_guidance_scale=<span class="hljs-number">7.0</span>,
audio_stg_scale=<span class="hljs-number">1.0</span>,
audio_modality_scale=<span class="hljs-number">3.0</span>,
audio_guidance_rescale=<span class="hljs-number">0.7</span>,
spatio_temporal_guidance_blocks=[<span class="hljs-number">28</span>],
use_cross_timestep=<span class="hljs-literal">True</span>,
enable_prompt_enhancement=<span class="hljs-literal">True</span>,
system_prompt=T2V_DEFAULT_SYSTEM_PROMPT,
generator=generator,
output_type=<span class="hljs-string">&quot;np&quot;</span>,
return_dict=<span class="hljs-literal">False</span>,
)
encode_video(
video[<span class="hljs-number">0</span>],
fps=frame_rate,
audio=audio[<span class="hljs-number">0</span>].<span class="hljs-built_in">float</span>().cpu(),
audio_sample_rate=pipe.vocoder.config.output_sampling_rate,
output_path=<span class="hljs-string">&quot;ltx2_3_t2v_stage_1.mp4&quot;</span>,
)`,lang:"py",wrap:!1});var ee=e($,2);t(ee,{title:"LTX-2.5",local:"ltx-25",headingTag:"h2"});var oe=e(ee,8);s(oe,{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwTFRYMlBpcGVsaW5lJTBBZnJvbSUyMGRpZmZ1c2Vycy51dGlscyUyMGltcG9ydCUyMGVuY29kZV92aWRlbyUwQWZyb20lMjBkaWZmdXNlcnMucGlwZWxpbmVzLmx0eDIudXRpbHMlMjBpbXBvcnQlMjBESVNUSUxMRURfU0lHTUFfVkFMVUVTJTBBJTBBZGV2aWNlJTIwJTNEJTIwJTIyY3VkYSUyMiUwQXdpZHRoJTI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U1RJTExFRF9TSUdNQV9WQUxVRVMlMkMlMEElMjAlMjAlMjAlMjBndWlkYW5jZV9zY2FsZSUzRDEuMCUyQyUwQSUyMCUyMCUyMCUyMGF1ZGlvX2d1aWRhbmNlX3NjYWxlJTNEMS4wJTJDJTBBJTIwJTIwJTIwJTIwZ2VuZXJhdG9yJTNEZ2VuZXJhdG9yJTJDJTBBJTIwJTIwJTIwJTIwb3V0cHV0X3R5cGUlM0QlMjJucCUyMiUyQyUwQSUyMCUyMCUyMCUyMHJldHVybl9kaWN0JTNERmFsc2UlMkMlMEEpJTBBJTBBZW5jb2RlX3ZpZGVvKCUwQSUyMCUyMCUyMCUyMHZpZGVvJTVCMCU1RCUyQyUwQSUyMCUyMCUyMCUyMGZwcyUzRGZyYW1lX3JhdGUlMkMlMEElMjAlMjAlMjAlMjBhdWRpbyUzRGF1ZGlvJTVCMCU1RC5mbG9hdCgpLmNwdSgpJTJDJTBBJTIwJTIwJTIwJTIwYXVkaW9fc2FtcGxlX3JhdGUlM0RwaXBlLnZvY29kZXIuY29uZmlnLm91dHB1dF9zYW1wbGluZ19yYXRlJTJDJTBBJTIwJTIwJTIwJTIwb3V0cHV0X3BhdGglM0QlMjJsdHgyXzVfdDJ2Lm1wNCUyMiUyQyUwQSk=",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> LTX2Pipeline
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> encode_video
<span class="hljs-keyword">from</span> diffusers.pipelines.ltx2.utils <span class="hljs-keyword">import</span> DISTILLED_SIGMA_VALUES
device = <span class="hljs-string">&quot;cuda&quot;</span>
width = <span class="hljs-number">768</span>
height = <span class="hljs-number">512</span>
random_seed = <span class="hljs-number">42</span>
frame_rate = <span class="hljs-number">24.0</span>
generator = torch.Generator(device).manual_seed(random_seed)
model_path = <span class="hljs-string">&quot;Lightricks/LTX-2.5-Diffusers&quot;</span>
pipe = LTX2Pipeline.from_pretrained(model_path, dtype=torch.bfloat16)
pipe.enable_sequential_cpu_offload(device=device)
pipe.vae.enable_tiling()
prompt = <span class="hljs-string">&quot;A cinematic shot of a red fox walking through a snowy forest at dawn, golden light filtering through pine trees.&quot;</span>
video, audio = pipe(
prompt=prompt,
width=width,
height=height,
num_frames=<span class="hljs-number">121</span>,
frame_rate=frame_rate,
sigmas=DISTILLED_SIGMA_VALUES,
guidance_scale=<span class="hljs-number">1.0</span>,
audio_guidance_scale=<span class="hljs-number">1.0</span>,
generator=generator,
output_type=<span class="hljs-string">&quot;np&quot;</span>,
return_dict=<span class="hljs-literal">False</span>,
)
encode_video(
video[<span class="hljs-number">0</span>],
fps=frame_rate,
audio=audio[<span class="hljs-number">0</span>].<span class="hljs-built_in">float</span>().cpu(),
audio_sample_rate=pipe.vocoder.config.output_sampling_rate,
output_path=<span class="hljs-string">&quot;ltx2_5_t2v.mp4&quot;</span>,
)`,lang:"py",wrap:!1});var ne=e(oe,2);t(ne,{title:"Two-stage generation for LTX-2.5",local:"two-stage-generation-for-ltx-25",headingTag:"h3"});var ae=e(ne,8);s(ae,{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzLnBpcGVsaW5lcy5sdHgyJTIwaW1wb3J0JTIwTFRYMlBpcGVsaW5lJTJDJTIwTFRYMkxhdGVudFVwc2FtcGxlUGlwZWxpbmUlMEFmcm9tJTIwZGlmZnVzZXJzLnBpcGVsaW5lcy5sdHgyLmxhdGVudF91cHNhbXBsZXIlMjBpbXBvcnQlMjBMVFgyTGF0ZW50VXBzYW1wbGVyTW9kZWwlMEFmcm9tJTIwZGlmZnVzZXJzLnBpcGVsaW5lcy5sdHgyLnV0aWxzJTIwaW1wb3J0JTIwRElTVElMTEVEX1NJR01BX1ZBTFVFUyUyQyUyMFNUQUdFXzJfRElTVElMTEVEX1NJR01BX1ZBTFVFUyUwQWZyb20lMjBkaWZmdXNlcnMudXRpbHMlMjBpbXBvcnQlMjBlbmNvZG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GUlM0QlMjJucCUyMiUyQyUwQSUyMCUyMCUyMCUyMHJldHVybl9kaWN0JTNERmFsc2UlMkMlMEEpJTBBJTBBZW5jb2RlX3ZpZGVvKCUwQSUyMCUyMCUyMCUyMHZpZGVvJTVCMCU1RCUyQyUwQSUyMCUyMCUyMCUyMGZwcyUzRGZyYW1lX3JhdGUlMkMlMEElMjAlMjAlMjAlMjBhdWRpbyUzRGF1ZGlvJTVCMCU1RC5mbG9hdCgpLmNwdSgpJTJDJTBBJTIwJTIwJTIwJTIwYXVkaW9fc2FtcGxlX3JhdGUlM0RwaXBlLnZvY29kZXIuY29uZmlnLm91dHB1dF9zYW1wbGluZ19yYXRlJTJDJTBBJTIwJTIwJTIwJTIwb3V0cHV0X3BhdGglM0QlMjJsdHgyXzVfdDJ2X3R3b19zdGFnZXMubXA0JTIyJTJDJTBBKQ==",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers.pipelines.ltx2 <span class="hljs-keyword">import</span> LTX2Pipeline, LTX2LatentUpsamplePipeline
<span class="hljs-keyword">from</span> diffusers.pipelines.ltx2.latent_upsampler <span class="hljs-keyword">import</span> LTX2LatentUpsamplerModel
<span class="hljs-keyword">from</span> diffusers.pipelines.ltx2.utils <span class="hljs-keyword">import</span> DISTILLED_SIGMA_VALUES, STAGE_2_DISTILLED_SIGMA_VALUES
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> encode_video
device = <span class="hljs-string">&quot;cuda&quot;</span>
width = <span class="hljs-number">1536</span>
height = <span class="hljs-number">1024</span>
num_frames = <span class="hljs-number">121</span>
frame_rate = <span class="hljs-number">24.0</span>
model_path = <span class="hljs-string">&quot;Lightricks/LTX-2.5-Diffusers&quot;</span>
<span class="hljs-comment"># One generator for the whole call, threaded through both stages, so stage 2 continues the noise</span>
<span class="hljs-comment"># stream instead of repeating stage 1&#x27;s draw.</span>
generator = torch.Generator(device).manual_seed(<span class="hljs-number">42</span>)
pipe = LTX2Pipeline.from_pretrained(model_path, dtype=torch.bfloat16)
pipe.enable_sequential_cpu_offload(device=device)
prompt = <span class="hljs-string">&quot;A cinematic shot of a red fox walking through a snowy forest at dawn, golden light filtering through pine trees.&quot;</span>
<span class="hljs-comment"># Stage 1: half resolution, 8 distilled sigmas</span>
video_latent, audio_latent = pipe(
prompt=prompt,
width=width // <span class="hljs-number">2</span>,
height=height // <span class="hljs-number">2</span>,
num_frames=num_frames,
frame_rate=frame_rate,
sigmas=DISTILLED_SIGMA_VALUES,
guidance_scale=<span class="hljs-number">1.0</span>,
audio_guidance_scale=<span class="hljs-number">1.0</span>,
generator=generator,
output_type=<span class="hljs-string">&quot;latent&quot;</span>,
return_dict=<span class="hljs-literal">False</span>,
)
latent_upsampler = LTX2LatentUpsamplerModel.from_pretrained(
model_path,
subfolder=<span class="hljs-string">&quot;latent_upsampler&quot;</span>,
dtype=torch.bfloat16,
)
upsample_pipe = LTX2LatentUpsamplePipeline(vae=pipe.vae, latent_upsampler=latent_upsampler)
upsample_pipe.enable_model_cpu_offload(device=device)
<span class="hljs-comment"># \`latents_normalized=False\`: \`output_type=&quot;latent&quot;\` already applied the latent statistics, and the</span>
<span class="hljs-comment"># upsampler is trained on denormalized latents. Stage 2 renormalizes them in \`prepare_latents\`.</span>
upscaled_video_latent = upsample_pipe(
latents=video_latent,
latents_normalized=<span class="hljs-literal">False</span>,
output_type=<span class="hljs-string">&quot;latent&quot;</span>,
return_dict=<span class="hljs-literal">False</span>,
)[<span class="hljs-number">0</span>]
<span class="hljs-comment"># Stage 2: full resolution, 3 sigmas, reseeded from stage 1. Pass \`num_frames\` explicitly here --</span>
<span class="hljs-comment"># omitting it would run the duration head a second time instead of using the stage 1 length.</span>
pipe.vae.enable_tiling()
video, audio = pipe(
prompt=prompt,
latents=upscaled_video_latent,
audio_latents=audio_latent,
width=width,
height=height,
num_frames=num_frames,
frame_rate=frame_rate,
sigmas=STAGE_2_DISTILLED_SIGMA_VALUES,
noise_scale=STAGE_2_DISTILLED_SIGMA_VALUES[<span class="hljs-number">0</span>], <span class="hljs-comment"># renoise with the stage 2 entry sigma</span>
guidance_scale=<span class="hljs-number">1.0</span>,
audio_guidance_scale=<span class="hljs-number">1.0</span>,
generator=generator,
output_type=<span class="hljs-string">&quot;np&quot;</span>,
return_dict=<span class="hljs-literal">False</span>,
)
encode_video(
video[<span class="hljs-number">0</span>],
fps=frame_rate,
audio=audio[<span class="hljs-number">0</span>].<span class="hljs-built_in">float</span>().cpu(),
audio_sample_rate=pipe.vocoder.config.output_sampling_rate,
output_path=<span class="hljs-string">&quot;ltx2_5_t2v_two_stages.mp4&quot;</span>,
)`,lang:"py",wrap:!1});var te=e(ae,4);s(te,{code:"bnVtX2ZyYW1lcyUyMCUzRCUyMCh2aWRlb19sYXRlbnQuc2hhcGUlNUIyJTVEJTIwLSUyMDEpJTIwKiUyMHBpcGUudmFlX3RlbXBvcmFsX2NvbXByZXNzaW9uX3JhdGlvJTIwJTJCJTIwMQ==",highlighted:'num_frames = (video_latent.shape[<span class="hljs-number">2</span>] - <span class="hljs-number">1</span>) * pipe.vae_temporal_compression_ratio + <span class="hljs-number">1</span>',lang:"py",wrap:!1});var se=e(te,2);t(se,{title:"Stage 2 with the distilled LoRA",local:"stage-2-with-the-distilled-lora",headingTag:"h4"});var le=e(se,4);s(le,{code:"cGlwZS5sb2FkX2xvcmFfd2VpZ2h0cyglMEElMjAlMjAlMjAlMjAlMjJMaWdodHJpY2tzJTJGTFRYLTIuNS1EaWZmdXNlcnMlMjIlMkMlMEElMjAlMjAlMjAlMjBhZGFwdGVyX25hbWUlM0QlMjJzdGFnZV8yX2Rpc3RpbGxlZCUyMiUyQyUwQSUyMCUyMCUyMCUyMHdlaWdodF9uYW1lJTNEJTIybHR4LTIuNS0yMmItZGlzdGlsbGVkLWxvcmEtNDUwLWJmMTYuc2FmZXRlbnNvcnMlMjIlMkMlMEEpJTBBcGlwZS5zZXRfYWRhcHRlcnMoJTIyc3RhZ2VfMl9kaXN0aWxsZWQlMjIlMkMlMjAxLjApJTBBcGlwZS52YWUuZW5hYmxlX3RpbGluZygpJTBBJTBBcGlwZS5zY2hlZHVsZXIlMjAlM0QlMjBGbG93TWF0Y2hFdWxlckRpc2NyZXRlU2NoZWR1bGVyLmZyb21fY29uZmlnKCUwQSUyMCUyMCUyMCUyMHBpcGUuc2NoZWR1bGVyLmNvbmZpZyUyQyUyMHVzZV9keW5hbWljX3NoaWZ0aW5nJTNERmFsc2UlMkMlMjBzaGlmdF90ZXJtaW5hbCUzRE5vbmUlMEEp",highlighted:`pipe.load_lora_weights(
<span class="hljs-string">&quot;Lightricks/LTX-2.5-Diffusers&quot;</span>,
adapter_name=<span class="hljs-string">&quot;stage_2_distilled&quot;</span>,
weight_name=<span class="hljs-string">&quot;ltx-2.5-22b-distilled-lora-450-bf16.safetensors&quot;</span>,
)
pipe.set_adapters(<span class="hljs-string">&quot;stage_2_distilled&quot;</span>, <span class="hljs-number">1.0</span>)
pipe.vae.enable_tiling()
pipe.scheduler = FlowMatchEulerDiscreteScheduler.from_config(
pipe.scheduler.config, use_dynamic_shifting=<span class="hljs-literal">False</span>, shift_terminal=<span class="hljs-literal">None</span>
)`,lang:"py",wrap:!1});var ie=e(le,4);t(ie,{title:"Convolutional and diffusion decoding",local:"convolutional-and-diffusion-decoding",headingTag:"h3"});var de=e(ie,10);s(de,{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwTFRYMlBpcGVsaW5lJTJDJTIwTFRYMlZpZGVvRGlmZnVzaW9uRGVjb2RlUGlwZWxpbmUlMkMlMjBMVFgyVmlkZW9EaWZmdXNpb25EZWNvZGVyTW9kZWwlMEFmcm9tJTIwZGlmZnVzZXJzLm1vZGVscy5hdXRvZW5jb2RlcnMubHR4Ml9kaWZmdXNpb25fZGVjb2RlciUyMGltcG9ydCUyMExUWDJWaWRlb1ZhZU5laWdoYm9yaG9vZE5hdHRlblByb2Nlc3NvciUwQWZyb20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lMkMlMEElMjAlMjAlMjAlMjBhdWRpbyUzRGF1ZGlvJTVCMCU1RC5mbG9hdCgpLmNwdSgpJTJDJTBBJTIwJTIwJTIwJTIwYXVkaW9fc2FtcGxlX3JhdGUlM0RwaXBlLnZvY29kZXIuY29uZmlnLm91dHB1dF9zYW1wbGluZ19yYXRlJTJDJTBBJTIwJTIwJTIwJTIwb3V0cHV0X3BhdGglM0QlMjJsdHgyXzVfdDJ2X2RpZmZ1c2lvbl9kZWNvZGUubXA0JTIyJTJDJTBBKQ==",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> LTX2Pipeline, LTX2VideoDiffusionDecodePipeline, LTX2VideoDiffusionDecoderModel
<span class="hljs-keyword">from</span> diffusers.models.autoencoders.ltx2_diffusion_decoder <span class="hljs-keyword">import</span> LTX2VideoVaeNeighborhoodNattenProcessor
<span class="hljs-keyword">from</span> diffusers.pipelines.ltx2.utils <span class="hljs-keyword">import</span> DISTILLED_SIGMA_VALUES
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> encode_video
device = <span class="hljs-string">&quot;cuda&quot;</span>
frame_rate = <span class="hljs-number">24.0</span>
generator = torch.Generator(device).manual_seed(<span class="hljs-number">42</span>)
model_path = <span class="hljs-string">&quot;Lightricks/LTX-2.5-Diffusers&quot;</span>
pipe = LTX2Pipeline.from_pretrained(model_path, dtype=torch.bfloat16)
pipe.enable_model_cpu_offload(device=device)
prompt = <span class="hljs-string">&quot;A cinematic shot of a red fox walking through a snowy forest at dawn, golden light filtering through pine trees.&quot;</span>
latents, audio_latents = pipe(
prompt=prompt,
width=<span class="hljs-number">960</span>,
height=<span class="hljs-number">544</span>,
num_frames=<span class="hljs-number">121</span>,
frame_rate=frame_rate,
sigmas=DISTILLED_SIGMA_VALUES,
guidance_scale=<span class="hljs-number">1.0</span>,
audio_guidance_scale=<span class="hljs-number">1.0</span>,
generator=generator,
output_type=<span class="hljs-string">&quot;latent&quot;</span>,
return_dict=<span class="hljs-literal">False</span>,
)
<span class="hljs-comment"># \`output_type=&quot;latent&quot;\` skips the vocoder, so finish the audio by hand. These latents are already</span>
<span class="hljs-comment"># denormalized, which is what \`audio_vae.decode\` expects.</span>
mel = pipe.audio_vae.decode(audio_latents.to(pipe.audio_vae.dtype), return_dict=<span class="hljs-literal">False</span>)[<span class="hljs-number">0</span>]
audio = pipe.vocoder(mel)
decoder = LTX2VideoDiffusionDecoderModel.from_pretrained(
model_path, subfolder=<span class="hljs-string">&quot;diffusion_decoder&quot;</span>, dtype=torch.bfloat16
).to(device)
<span class="hljs-comment"># The decoder runs on the \`flex\` backend by default, and uncompiled \`flex_attention\` materializes the</span>
<span class="hljs-comment"># full score matrix -- tens of GB at video resolutions. NATTEN&#x27;s kernels are what the original</span>
<span class="hljs-comment"># implementation uses; they are fetched from the Hub by \`kernels\` (\`pip install kernels\`), not from a</span>
<span class="hljs-comment"># local NATTEN build. Switching the attention *backend* instead raises: only \`flex\` takes the BlockMask.</span>
decoder.set_attn_processor(LTX2VideoVaeNeighborhoodNattenProcessor())
<span class="hljs-comment"># Decode in overlapping tiles so peak memory scales with the tile size rather than the video size.</span>
decoder.enable_tiling()
decode_pipe = LTX2VideoDiffusionDecodePipeline(diffusion_decoder=decoder, scheduler=pipe.scheduler)
<span class="hljs-comment"># \`denormalize=False\`: \`output_type=&quot;latent&quot;\` already applied the latent statistics, so applying them</span>
<span class="hljs-comment"># again would rescale every channel by its std a second time. The decoder draws the noise it denoises,</span>
<span class="hljs-comment"># so pass a generator to make decoding reproducible.</span>
video = decode_pipe(
latents, generator=generator, output_type=<span class="hljs-string">&quot;np&quot;</span>, denormalize=<span class="hljs-literal">False</span>, return_dict=<span class="hljs-literal">False</span>
)[<span class="hljs-number">0</span>]
encode_video(
video[<span class="hljs-number">0</span>],
fps=frame_rate,
audio=audio[<span class="hljs-number">0</span>].<span class="hljs-built_in">float</span>().cpu(),
audio_sample_rate=pipe.vocoder.config.output_sampling_rate,
output_path=<span class="hljs-string">&quot;ltx2_5_t2v_diffusion_decode.mp4&quot;</span>,
)`,lang:"py",wrap:!1});var re=e(de,8);t(re,{title:"Full / SFT transformer",local:"full--sft-transformer",headingTag:"h3"});var ce=e(re,4);s(ce,{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwRmxvd01hdGNoRXVsZXJEaXNjcmV0ZVNjaGVkdWxlciUyQyUyMExUWDJQaXBlbGluZSUyQyUyMExUWDJWaWRlb1RyYW5zZm9ybWVyM0RNb2RlbCUwQWZyb20lMjBkaWZmdXNlcnMucGlwZWxpbmVzLmx0eDIudXRpbHMlMjBpbXBvcnQlMjBERUZBVUxUX05FR0FUSVZFX1BST01QVCUwQSUwQWRldmljZSUyMCUzRCUyMCUyMmN1ZGElMjIlMEFtb2RlbF9wYXRoJTIwJTNEJTIwJTIyTGlnaHRyaWNrcyUyRkxUWC0yLjUtRGlmZnVzZXJzJTIyJTBBJTBBJTIzJTIwUGFzc2luZyUyMCU2MHRyYW5zZm9ybWVyJTNEJTYwJTIwa2VlcHMlMjAlNjBmcm9tX3ByZXRyYWluZWQlNjAlMjBmcm9tJTIwZmV0Y2hpbmclMjB0aGUlMjBkaXN0aWxsZWQlMjBmb2xkZXIlMjBhcyUyMHdlbGwuJTBBdHJhbnNmb3JtZXIlMjAlM0QlMjBMVFgyVmlkZW9UcmFuc2Zvcm1lcjNETW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMG1vZGVsX3BhdGglMkMlMjBzdWJmb2xkZXIlM0QlMjJ0cmFuc2Zvcm1lcl9mdWxsJTIyJTJDJTIwZHR5cGUlM0R0b3JjaC5iZmxvYXQxNiUwQSklMEFwaXBlJTIwJTNEJTIwTFRYMlBpcGVsaW5lLmZyb21fcHJldHJhaW5lZChtb2RlbF9wYXRoJTJDJTIwdHJhbnNmb3JtZXIlM0R0cmFuc2Zvcm1lciUyQy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JTIwZnJhbWVfcmF0ZSUzRDI0LjAlMkMlMEElMjAlMjAlMjAlMjBudW1faW5mZXJlbmNlX3N0ZXBzJTNEMzAlMkMlMEElMjAlMjAlMjAlMjBndWlkYW5jZV9zY2FsZSUzRDMuMCUyQyUwQSUyMCUyMCUyMCUyMHN0Z19zY2FsZSUzRDEuMCUyQyUwQSUyMCUyMCUyMCUyMG1vZGFsaXR5X3NjYWxlJTNEMy4wJTJDJTBBJTIwJTIwJTIwJTIwZ3VpZGFuY2VfcmVzY2FsZSUzRDAuNyUyQyUwQSUyMCUyMCUyMCUyMGF1ZGlvX2d1aWRhbmNlX3NjYWxlJTNENy4wJTJDJTBBJTIwJTIwJTIwJTIwYXVkaW9fc3RnX3NjYWxlJTNEMS4wJTJDJTBBJTIwJTIwJTIwJTIwYXVkaW9fbW9kYWxpdHlfc2NhbGUlM0QzLjAlMkMlMEElMjAlMjAlMjAlMjBhdWRpb19ndWlkYW5jZV9yZXNjYWxlJTNEMC43JTJDJTBBJTIwJTIwJTIwJTIwc3BhdGlvX3RlbXBvcmFsX2d1aWRhbmNlX2Jsb2NrcyUzRCU1QjI4JTVEJTJDJTBBJTIwJTIwJTIwJTIwdXNlX2Nyb3NzX3RpbWVzdGVwJTNEVHJ1ZSUyQyUwQSUyMCUyMCUyMCUyMGdlbmVyYXRvciUzRHRvcmNoLkdlbmVyYXRvcihkZXZpY2UpLm1hbnVhbF9zZWVkKDQyKSUyQyUwQSUyMCUyMCUyMCUyMG91dHB1dF90eXBlJTNEJTIybnAlMjIlMkMlMEElMjAlMjAlMjAlMjByZXR1cm5fZGljdCUzREZhbHNlJTJDJTBBKQ==",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> FlowMatchEulerDiscreteScheduler, LTX2Pipeline, LTX2VideoTransformer3DModel
<span class="hljs-keyword">from</span> diffusers.pipelines.ltx2.utils <span class="hljs-keyword">import</span> DEFAULT_NEGATIVE_PROMPT
device = <span class="hljs-string">&quot;cuda&quot;</span>
model_path = <span class="hljs-string">&quot;Lightricks/LTX-2.5-Diffusers&quot;</span>
<span class="hljs-comment"># Passing \`transformer=\` keeps \`from_pretrained\` from fetching the distilled folder as well.</span>
transformer = LTX2VideoTransformer3DModel.from_pretrained(
model_path, subfolder=<span class="hljs-string">&quot;transformer_full&quot;</span>, dtype=torch.bfloat16
)
pipe = LTX2Pipeline.from_pretrained(model_path, transformer=transformer, dtype=torch.bfloat16)
pipe.enable_sequential_cpu_offload(device=device)
pipe.vae.enable_tiling()
<span class="hljs-comment"># Re-enable dynamic shifting and the terminal shift, which the distilled configuration turns off.</span>
pipe.scheduler = FlowMatchEulerDiscreteScheduler.from_config(
pipe.scheduler.config, use_dynamic_shifting=<span class="hljs-literal">True</span>, shift_terminal=<span class="hljs-number">0.1</span>
)
video, audio = pipe(
prompt=<span class="hljs-string">&quot;A cinematic shot of a red fox walking through a snowy forest at dawn, golden light filtering through pine trees.&quot;</span>,
negative_prompt=DEFAULT_NEGATIVE_PROMPT,
width=<span class="hljs-number">768</span>,
height=<span class="hljs-number">512</span>,
num_frames=<span class="hljs-number">121</span>,
frame_rate=<span class="hljs-number">24.0</span>,
num_inference_steps=<span class="hljs-number">30</span>,
guidance_scale=<span class="hljs-number">3.0</span>,
stg_scale=<span class="hljs-number">1.0</span>,
modality_scale=<span class="hljs-number">3.0</span>,
guidance_rescale=<span class="hljs-number">0.7</span>,
audio_guidance_scale=<span class="hljs-number">7.0</span>,
audio_stg_scale=<span class="hljs-number">1.0</span>,
audio_modality_scale=<span class="hljs-number">3.0</span>,
audio_guidance_rescale=<span class="hljs-number">0.7</span>,
spatio_temporal_guidance_blocks=[<span class="hljs-number">28</span>],
use_cross_timestep=<span class="hljs-literal">True</span>,
generator=torch.Generator(device).manual_seed(<span class="hljs-number">42</span>),
output_type=<span class="hljs-string">&quot;np&quot;</span>,
return_dict=<span class="hljs-literal">False</span>,
)`,lang:"py",wrap:!1});var pe=e(ce,4);t(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MlMEElMjAlMjAlMjAlMjBlbmFibGVfcHJvbXB0X2VuaGFuY2VtZW50JTNEVHJ1ZSUyQyUwQSUyMCUyMCUyMCUyMCUyMyUyME5vJTIwJTYwc3lzdGVtX3Byb21wdCUzRCU2MCUyMG5lZWRlZCUyMC0tJTIwZGVmYXVsdHMlMjB0byUyMCU2MExUWDJfNV9UMlZfREVGQVVMVF9TWVNURU1fUFJPTVBUJTYwJTIwd2hlbiUyMCU2MHByb21wdF9lbmhhbmNlciU2MCUyMGlzJTIwc2V0LiUwQSUyMCUyMCUyMCUyMGdlbmVyYXRvciUzRGdlbmVyYXRvciUyQyUwQSUyMCUyMCUyMCUyMG91dHB1dF90eXBlJTNEJTIybnAlMjIlMkMlMEElMjAlMjAlMjAlMjByZXR1cm5fZGljdCUzREZhbHNlJTJDJTBBKSUwQSUwQWVuY29kZV92aWRlbyglMEElMjAlMjAlMjAlMjB2aWRlbyU1QjAlNUQlMkMlMEElMjAlMjAlMjAlMjBmcHMlM0RmcmFtZV9yYXRlJTJDJTBBJTIwJTIwJTIwJTIwYXVkaW8lM0RhdWRpbyU1QjAlNUQuZmxvYXQoKS5jcHUoKSUyQyUwQSUyMCUyMCUyMCUyMGF1ZGlvX3NhbXBsZV9yYXRlJTNEcGlwZS52b2NvZGVyLmNvbmZpZy5vdXRwdXRfc2FtcGxpbmdfcmF0ZSUyQyUwQSUyMCUyMCUyMCUyMG91dHB1dF9wYXRoJTNEJTIybHR4Ml81X3Qydl9lbmhhbmNlZC5tcDQlMjIlMkMlMEEp",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForImageTextToText, AutoProcessor
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> LTX2Pipeline
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> encode_video
<span class="hljs-keyword">from</span> diffusers.pipelines.ltx2.utils <span class="hljs-keyword">import</span> DISTILLED_SIGMA_VALUES
device = <span class="hljs-string">&quot;cuda&quot;</span>
width = <span class="hljs-number">768</span>
height = <span class="hljs-number">512</span>
random_seed = <span class="hljs-number">42</span>
frame_rate = <span class="hljs-number">24.0</span>
generator = torch.Generator(device).manual_seed(random_seed)
model_path = <span class="hljs-string">&quot;Lightricks/LTX-2.5-Diffusers&quot;</span>
enhancer_model_id = <span class="hljs-string">&quot;google/gemma-4-E2B-it&quot;</span>
pipe = LTX2Pipeline.from_pretrained(model_path, dtype=torch.bfloat16)
pipe.enable_model_cpu_offload(device=device)
pipe.vae.enable_tiling()
<span class="hljs-keyword">if</span> <span class="hljs-built_in">getattr</span>(pipe, <span class="hljs-string">&quot;prompt_enhancer&quot;</span>, <span class="hljs-literal">None</span>) <span class="hljs-keyword">is</span> <span class="hljs-literal">None</span>:
pipe.prompt_enhancer = AutoModelForImageTextToText.from_pretrained(enhancer_model_id)
pipe.processor = AutoProcessor.from_pretrained(enhancer_model_id)
prompt = <span class="hljs-string">&quot;A cinematic shot of a red fox walking through a snowy forest at dawn, golden light filtering through pine trees.&quot;</span>
video, audio = pipe(
prompt=prompt,
width=width,
height=height,
num_frames=<span class="hljs-number">121</span>,
frame_rate=frame_rate,
sigmas=DISTILLED_SIGMA_VALUES,
guidance_scale=<span class="hljs-number">1.0</span>,
audio_guidance_scale=<span class="hljs-number">1.0</span>,
enable_prompt_enhancement=<span class="hljs-literal">True</span>,
<span class="hljs-comment"># No \`system_prompt=\` needed -- defaults to \`LTX2_5_T2V_DEFAULT_SYSTEM_PROMPT\` when \`prompt_enhancer\` is set.</span>
generator=generator,
output_type=<span class="hljs-string">&quot;np&quot;</span>,
return_dict=<span class="hljs-literal">False</span>,
)
encode_video(
video[<span class="hljs-number">0</span>],
fps=frame_rate,
audio=audio[<span class="hljs-number">0</span>].<span class="hljs-built_in">float</span>().cpu(),
audio_sample_rate=pipe.vocoder.config.output_sampling_rate,
output_path=<span class="hljs-string">&quot;ltx2_5_t2v_enhanced.mp4&quot;</span>,
)`,lang:"py",wrap:!1});var ue=e(me,4);t(ue,{title:"Automatic duration for LTX-2.5",local:"automatic-duration-for-ltx-25",headingTag:"h3"});var he=e(ue,4);s(he,{code:"dmlkZW8lMkMlMjBhdWRpbyUyMCUzRCUyMHBpcGUocHJvbXB0JTNEcHJvbXB0JTJDJTIwb3V0cHV0X3R5cGUlM0QlMjJucCUyMiUyQyUyMHJldHVybl9kaWN0JTNERmFsc2Up",highlighted:'video, audio = pipe(prompt=prompt, output_type=<span class="hljs-string">&quot;np&quot;</span>, return_dict=<span class="hljs-literal">False</span>)',lang:"py",wrap:!1});var Me=e(he,4);s(Me,{code:"dmlkZW8lMkMlMjBhdWRpbyUyMCUzRCUyMHBpcGUocHJvbXB0JTNEcHJvbXB0JTJDJTIwbnVtX2ZyYW1lcyUzRDEyMSUyQyUyMG91dHB1dF90eXBlJTNEJTIybnAlMjIlMkMlMjByZXR1cm5fZGljdCUzREZhbHNlKQ==",highlighted:'video, audio = pipe(prompt=prompt, num_frames=<span class="hljs-number">121</span>, output_type=<span class="hljs-string">&quot;np&quot;</span>, return_dict=<span class="hljs-literal">False</span>)',lang:"py",wrap:!1});var fe=e(Me,6);s(fe,{code:"dmlkZW8lMkMlMjBhdWRpbyUyMCUzRCUyMHBpcGUoJTBBJTIwJTIwJTIwJTIwcHJvbXB0JTNEcHJvbXB0JTJDJTBBJTIwJTIwJTIwJTIwbWluX3NlY29uZHMlM0QyLjAlMkMlMEElMjAlMjAlMjAlMjBtYXhfc2Vjb25kcyUzRDEwLjAlMkMlMEElMjAlMjAlMjAlMjBmcmFtZV9yYXRlJTNEZnJhbWVfcmF0ZSUyQyUwQSUyMCUyMCUyMCUyMG91dHB1dF90eXBlJTNEJTIybnAlMjIlMkMlMEElMjAlMjAlMjAlMjByZXR1cm5fZGljdCUzREZhbHNlJTJDJTBBKQ==",highlighted:`video, audio = pipe(
prompt=prompt,
min_seconds=<span class="hljs-number">2.0</span>,
max_seconds=<span class="hljs-number">10.0</span>,
frame_rate=frame_rate,
output_type=<span class="hljs-string">&quot;np&quot;</span>,
return_dict=<span class="hljs-literal">False</span>,
)`,lang:"py",wrap:!1});var ge=e(fe,8);s(ge,{code:"cHJvbXB0X2VtYmVkcyUyQyUyMHByb21wdF9hdHRlbnRpb25fbWFzayUyQyUyMF8lMkMlMjBfJTIwJTNEJTIwcGlwZS5lbmNvZGVfcHJvbXB0KHByb21wdCUyQyUyMGRvX2NsYXNzaWZpZXJfZnJlZV9ndWlkYW5jZSUzREZhbHNlKSUwQXZpZGVvX3Rva2VucyUyQyUyMGF1ZGlvX3Rva2VucyUyQyUyMF8lMjAlM0QlMjBwaXBlLmNvbm5lY3RvcnMocHJvbXB0X2VtYmVkcyUyQyUyMHByb21wdF9hdHRlbnRpb25fbWFzayklMEElMEFudW1fZnJhbWVzJTIwJTNEJTIwcGlwZS5kdXJhdGlvbl9oZWFkLnByZWRpY3RfbnVtX2ZyYW1lcyglMEElMjAlMjAlMjAlMjB2aWRlb190b2tlbnMlMkMlMEElMjAlMjAlMjAlMjBhdWRpb190b2tlbnMlMkMlMEElMjAlMjAlMjAlMjBmcmFtZV9yYXRlJTNEMjQuMCUyQyUwQSUyMCUyMCUyMCUyMHRlbXBvcmFsX2NvbXByZXNzaW9uX3JhdGlvJTNEcGlwZS52YWVfdGVtcG9yYWxfY29tcHJlc3Npb25fcmF0aW8lMkMlMEEpJTBBc2Vjb25kcyUyMCUzRCUyMHBpcGUuZHVyYXRpb25faGVhZCh2aWRlb190b2tlbnMlMkMlMjBhdWRpb190b2tlbnMpLml0ZW0oKSUyMCUyMCUyMyUyMHJhdyUyQyUyMGJlZm9yZSUyMGNsYW1waW5nJTBBcHJpbnQoZiUyMnByZWRpY3RlZCUyMCU3QnNlY29uZHMlM0EuMmYlN0RzJTIwLSUzRSUyMCU3Qm51bV9mcmFtZXMlN0QlMjBmcmFtZXMlMjIp",highlighted:`prompt_embeds, prompt_attention_mask, _, _ = pipe.encode_prompt(prompt, do_classifier_free_guidance=<span class="hljs-literal">False</span>)
video_tokens, audio_tokens, _ = pipe.connectors(prompt_embeds, prompt_attention_mask)
num_frames = pipe.duration_head.predict_num_frames(
video_tokens,
audio_tokens,
frame_rate=<span class="hljs-number">24.0</span>,
temporal_compression_ratio=pipe.vae_temporal_compression_ratio,
)
seconds = pipe.duration_head(video_tokens, audio_tokens).item() <span class="hljs-comment"># raw, before clamping</span>
<span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;predicted <span class="hljs-subst">{seconds:<span class="hljs-number">.2</span>f}</span>s -&gt; <span class="hljs-subst">{num_frames}</span> frames&quot;</span>)`,lang:"py",wrap:!1});var Te=e(ge,4);t(Te,{title:"LTX-2.5 Modular",local:"ltx-25-modular",headingTag:"h3"});var _e=e(Te,4);s(_e,{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwTW9kdWxhclBpcGVsaW5lJTJDJTIwQ29tcG9uZW50c01hbmFnZXIlMEFmcm9tJTIwZGlmZnVzZXJzLm1vZGVscy5hdXRvZW5jb2RlcnMubHR4Ml9kaWZmdXNpb25fZGVjb2RlciUyMGltcG9ydCUyMExUWDJWaWRlb1ZhZU5laWdoYm9yaG9vZE5hdHRlblByb2Nlc3NvciUwQWZyb20lMjBkaWZmdXNlcnMucGlwZWxpbmVzLmx0eDIudXRpbHMlMjBpbXBvcnQlMjBERUZBVUxUX05FR0FUSVZFX1BST01QVCUwQWZyb20lMjBkaWZmdXNlcnMudXRpbHMlMjBpbXBvcnQlMjBlbmNvZGVfdmlkZW8lMEElMEFkZXZpY2UlMjAlM0QlMjAlMjJjdWRhJTIyJTBBZnJhbWVfcmF0ZSUyMCUzRCUyMDI0LjAlMEFyYW5kb21fc2VlZCUyMCUzRCUyMDQyJTBBZ2VuZXJhdG9yJTIwJTNEJTIwdG9yY2guR2VuZXJhdG9yKGRldmljZSkubWFudWFsX3NlZWQocmFuZG9tX3NlZWQpJTBBJTBBbW9kZWxfcGF0aCUyMCUzRC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V0KCUyMmF1ZGlvJTIyKSUwQSUwQWVuY29kZV92aWRlbyglMEElMjAlMjAlMjAlMjB2aWRlbyU1QjAlNUQlMkMlMEElMjAlMjAlMjAlMjBmcHMlM0RmcmFtZV9yYXRlJTJDJTBBJTIwJTIwJTIwJTIwYXVkaW8lM0RhdWRpbyU1QjAlNUQuZmxvYXQoKS5jcHUoKSUyQyUwQSUyMCUyMCUyMCUyMGF1ZGlvX3NhbXBsZV9yYXRlJTNEcGlwZS52b2NvZGVyLmNvbmZpZy5vdXRwdXRfc2FtcGxpbmdfcmF0ZSUyQyUwQSUyMCUyMCUyMCUyMG91dHB1dF9wYXRoJTNEJTIybHR4Ml81X21vZHVsYXJfdDJ2Lm1wNCUyMiUyQyUwQSk=",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> ModularPipeline, ComponentsManager
<span class="hljs-keyword">from</span> diffusers.models.autoencoders.ltx2_diffusion_decoder <span class="hljs-keyword">import</span> LTX2VideoVaeNeighborhoodNattenProcessor
<span class="hljs-keyword">from</span> diffusers.pipelines.ltx2.utils <span class="hljs-keyword">import</span> DEFAULT_NEGATIVE_PROMPT
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> encode_video
device = <span class="hljs-string">&quot;cuda&quot;</span>
frame_rate = <span class="hljs-number">24.0</span>
random_seed = <span class="hljs-number">42</span>
generator = torch.Generator(device).manual_seed(random_seed)
model_path = <span class="hljs-string">&quot;Lightricks/LTX-2.5-Diffusers&quot;</span>
cm = ComponentsManager()
pipe = ModularPipeline.from_pretrained(model_path, components_manager=cm)
pipe.load_components(dtype=torch.bfloat16)
<span class="hljs-comment"># Set memory_reserve_margin higher to more aggressively offload component models</span>
cm.enable_auto_cpu_offload(device=device, memory_reserve_margin=<span class="hljs-string">&quot;20GB&quot;</span>)
<span class="hljs-comment"># The NATTEN processor works if \`kernels\` is available (\`pip install kernels\`)</span>
<span class="hljs-comment"># Otherwise omit the below line to use the Flex Attention processor</span>
pipe.diffusion_decoder.set_attn_processor(LTX2VideoVaeNeighborhoodNattenProcessor())
pipe.diffusion_decoder.enable_tiling()
prompt = (
<span class="hljs-string">&quot;A cinematic shot of a red fox walking through a snowy forest at dawn, golden light filtering through pine trees.&quot;</span>
)
output_state = pipe(
prompt=prompt,
negative_prompt=DEFAULT_NEGATIVE_PROMPT,
width=<span class="hljs-number">768</span>,
height=<span class="hljs-number">512</span>,
num_frames=<span class="hljs-literal">None</span>, <span class="hljs-comment"># Set to an int (e.g. 121) to specify a fixed video length</span>
frame_rate=frame_rate,
num_inference_steps=<span class="hljs-number">30</span>,
use_cross_timestep=<span class="hljs-literal">True</span>,
enable_prompt_enhancement=<span class="hljs-literal">True</span>,
generator=generator,
output_type=<span class="hljs-string">&quot;np&quot;</span>,
)
video = output_state.get(<span class="hljs-string">&quot;videos&quot;</span>)
audio = output_state.get(<span class="hljs-string">&quot;audio&quot;</span>)
encode_video(
video[<span class="hljs-number">0</span>],
fps=frame_rate,
audio=audio[<span class="hljs-number">0</span>].<span class="hljs-built_in">float</span>().cpu(),
audio_sample_rate=pipe.vocoder.config.output_sampling_rate,
output_path=<span class="hljs-string">&quot;ltx2_5_modular_t2v.mp4&quot;</span>,
)`,lang:"py",wrap:!1});var ye=e(_e,4);s(ye,{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwTW9kdWxhclBpcGVsaW5lJTJDJTIwQ29tcG9uZW50c01hbmFnZXIlMEFmcm9tJTIwZGlmZnVzZXJzLm1vZGVscy5hdXRvZW5jb2RlcnMubHR4Ml9kaWZmdXNpb25fZGVjb2RlciUyMGltcG9ydCUyMExUWDJWaWRlb1ZhZU5laWdoYm9yaG9vZE5hdHRlblByb2Nlc3NvciUwQWZyb20lMjBkaWZmdXNlcnMucGlwZWxpbmVzLmx0eDIudXRpbHMlMjBpbXBvcnQlMjBERUZBVUxUX05FR0FUSVZFX1BST01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SUyMCUyMCUyMCUyMGVuYWJsZV9wcm9tcHRfZW5oYW5jZW1lbnQlM0RUcnVlJTJDJTBBJTIwJTIwJTIwJTIwZ2VuZXJhdG9yJTNEZ2VuZXJhdG9yJTJDJTBBJTIwJTIwJTIwJTIwb3V0cHV0X3R5cGUlM0QlMjJucCUyMiUyQyUwQSklMEF2aWRlbyUyMCUzRCUyMG91dHB1dF9zdGF0ZS5nZXQoJTIydmlkZW9zJTIyKSUwQWF1ZGlvJTIwJTNEJTIwb3V0cHV0X3N0YXRlLmdldCglMjJhdWRpbyUyMiklMEElMEFlbmNvZGVfdmlkZW8oJTBBJTIwJTIwJTIwJTIwdmlkZW8lNUIwJTVEJTJDJTBBJTIwJTIwJTIwJTIwZnBzJTNEZnJhbWVfcmF0ZSUyQyUwQSUyMCUyMCUyMCUyMGF1ZGlvJTNEYXVkaW8lNUIwJTVELmZsb2F0KCkuY3B1KCklMkMlMEElMjAlMjAlMjAlMjBhdWRpb19zYW1wbGVfcmF0ZSUzRHBpcGUudm9jb2Rlci5jb25maWcub3V0cHV0X3NhbXBsaW5nX3JhdGUlMkMlMEElMjAlMjAlMjAlMjBvdXRwdXRfcGF0aCUzRCUyMmx0eDJfNV9tb2R1bGFyX2kydi5tcDQlMjIlMkMlMEEp",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> ModularPipeline, ComponentsManager
<span class="hljs-keyword">from</span> diffusers.models.autoencoders.ltx2_diffusion_decoder <span class="hljs-keyword">import</span> LTX2VideoVaeNeighborhoodNattenProcessor
<span class="hljs-keyword">from</span> diffusers.pipelines.ltx2.utils <span class="hljs-keyword">import</span> DEFAULT_NEGATIVE_PROMPT
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> encode_video, load_image
device = <span class="hljs-string">&quot;cuda&quot;</span>
frame_rate = <span class="hljs-number">24.0</span>
random_seed = <span class="hljs-number">42</span>
generator = torch.Generator(device).manual_seed(random_seed)
model_path = <span class="hljs-string">&quot;Lightricks/LTX-2.5-Diffusers&quot;</span>
cm = ComponentsManager()
pipe = ModularPipeline.from_pretrained(model_path, components_manager=cm)
pipe.load_components(dtype=torch.bfloat16)
cm.enable_auto_cpu_offload(device=device, memory_reserve_margin=<span class="hljs-string">&quot;20GB&quot;</span>)
pipe.diffusion_decoder.set_attn_processor(LTX2VideoVaeNeighborhoodNattenProcessor())
pipe.diffusion_decoder.enable_tiling()
prompt = (
<span class="hljs-string">&quot;An astronaut hatches from a fragile egg on the surface of the Moon, the shell cracking and peeling apart in &quot;</span>
<span class="hljs-string">&quot;gentle low-gravity motion.&quot;</span>
)
image_path = <span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/astronaut.jpg&quot;</span>
image = load_image(image_path)
output_state = pipe(
image=image,
prompt=prompt,
negative_prompt=DEFAULT_NEGATIVE_PROMPT,
width=<span class="hljs-number">768</span>,
height=<span class="hljs-number">512</span>,
num_frames=<span class="hljs-literal">None</span>, <span class="hljs-comment"># Set to an int (e.g. 121) to specify a fixed video length</span>
frame_rate=frame_rate,
num_inference_steps=<span class="hljs-number">30</span>,
use_cross_timestep=<span class="hljs-literal">True</span>,
enable_prompt_enhancement=<span class="hljs-literal">True</span>,
generator=generator,
output_type=<span class="hljs-string">&quot;np&quot;</span>,
)
video = output_state.get(<span class="hljs-string">&quot;videos&quot;</span>)
audio = output_state.get(<span class="hljs-string">&quot;audio&quot;</span>)
encode_video(
video[<span class="hljs-number">0</span>],
fps=frame_rate,
audio=audio[<span class="hljs-number">0</span>].<span class="hljs-built_in">float</span>().cpu(),
audio_sample_rate=pipe.vocoder.config.output_sampling_rate,
output_path=<span class="hljs-string">&quot;ltx2_5_modular_i2v.mp4&quot;</span>,
)`,lang:"py",wrap:!1});var Je=e(ye,4);t(Je,{title:"LTX2Pipeline",local:"diffusers.LTX2Pipeline",headingTag:"h2"});var M=e(Je,2),we=n(M);o(we,{name:"class diffusers.LTX2Pipeline",anchor:"diffusers.LTX2Pipeline",source:"https://github.com/huggingface/diffusers/blob/vr_14588/src/diffusers/pipelines/ltx2/pipeline_ltx2.py#L206",parameters:[{name:"scheduler",val:": FlowMatchEulerDiscreteScheduler"},{name:"vae",val:": AutoencoderKLLTX2Video"},{name:"audio_vae",val:": AutoencoderKLLTX2Audio"},{name:"text_encoder",val:": transformers.models.gemma3.modeling_gemma3.Gemma3ForConditionalGeneration | transformers.models.gemma4_unified.modeling_gemma4_unified.Gemma4UnifiedForConditionalGeneration"},{name:"tokenizer",val:": GemmaTokenizer"},{name:"connectors",val:": LTX2TextConnectors"},{name:"transformer",val:": LTX2VideoTransformer3DModel"},{name:"vocoder",val:": diffusers.pipelines.ltx2.vocoder.LTX2Vocoder | diffusers.pipelines.ltx2.vocoder.LTX2VocoderWithBWE"},{name:"processor",val:": transformers.processing_utils.ProcessorMixin | None = None"},{name:"prompt_enhancer",val:": transformers.models.gemma4.modeling_gemma4.Gemma4ForConditionalGeneration | None = None"},{name:"duration_head",val:": diffusers.pipelines.ltx2.duration_head.LTX2DurationHead | None = None"}],parametersDescription:[{anchor:"diffusers.LTX2Pipeline.transformer",description:`<strong>transformer</strong> (<a href="/docs/diffusers/pr_14588/en/api/models/ltx_video_transformer3d#diffusers.LTXVideoTransformer3DModel">LTXVideoTransformer3DModel</a>) &#x2014;
Conditional Transformer architecture to denoise the encoded video latents.`,name:"transformer"},{anchor:"diffusers.LTX2Pipeline.scheduler",description:`<strong>scheduler</strong> (<a href="/docs/diffusers/pr_14588/en/api/schedulers/flow_match_euler_discrete#diffusers.FlowMatchEulerDiscreteScheduler">FlowMatchEulerDiscreteScheduler</a>) &#x2014;
A scheduler to be used in combination with <code>transformer</code> to denoise the encoded image latents.`,name:"scheduler"},{anchor:"diffusers.LTX2Pipeline.vae",description:`<strong>vae</strong> (<a href="/docs/diffusers/pr_14588/en/api/models/autoencoderkl_ltx_video#diffusers.AutoencoderKLLTXVideo">AutoencoderKLLTXVideo</a>) &#x2014;
Variational Auto-Encoder (VAE) Model to encode and decode images to and from latent representations.`,name:"vae"},{anchor:"diffusers.LTX2Pipeline.text_encoder",description:`<strong>text_encoder</strong> (<code>T5EncoderModel</code>) &#x2014;
<a href="https://huggingface.co/docs/transformers/en/model_doc/t5#transformers.T5EncoderModel" rel="nofollow">T5</a>, specifically
the <a href="https://huggingface.co/google/t5-v1_1-xxl" rel="nofollow">google/t5-v1_1-xxl</a> variant.`,name:"text_encoder"},{anchor:"diffusers.LTX2Pipeline.tokenizer",description:`<strong>tokenizer</strong> (<code>CLIPTokenizer</code>) &#x2014;
Tokenizer of class
<a href="https://huggingface.co/docs/transformers/en/model_doc/clip#transformers.CLIPTokenizer" rel="nofollow">CLIPTokenizer</a>.`,name:"tokenizer"},{anchor:"diffusers.LTX2Pipeline.tokenizer",description:`<strong>tokenizer</strong> (<code>T5TokenizerFast</code>) &#x2014;
Second Tokenizer of class
<a href="https://huggingface.co/docs/transformers/en/model_doc/t5#transformers.T5TokenizerFast" rel="nofollow">T5TokenizerFast</a>.`,name:"tokenizer"},{anchor:"diffusers.LTX2Pipeline.connectors",description:`<strong>connectors</strong> (<code>LTX2TextConnectors</code>) &#x2014;
Text connector stack used to adapt text encoder hidden states for the video and audio branches.`,name:"connectors"}]});var f=e(we,6),be=n(f);o(be,{name:"__call__",anchor:"diffusers.LTX2Pipeline.__call__",source:"https://github.com/huggingface/diffusers/blob/vr_14588/src/diffusers/pipelines/ltx2/pipeline_ltx2.py#L926",parameters:[{name:"prompt",val:": str | list[str] = None"},{name:"negative_prompt",val:": str | list[str] | None = None"},{name:"height",val:": int = 512"},{name:"width",val:": int = 768"},{name:"num_frames",val:": int | None = None"},{name:"min_seconds",val:": float = 1.0"},{name:"max_seconds",val:": float = 20.0"},{name:"frame_rate",val:": float = 24.0"},{name:"num_inference_steps",val:": int = 30"},{name:"sigmas",val:": list[float] | None = None"},{name:"timesteps",val:": list = None"},{name:"guidance_scale",val:": float = 3.0"},{name:"stg_scale",val:": float = 1.0"},{name:"modality_scale",val:": float = 3.0"},{name:"guidance_rescale",val:": float = 0.7"},{name:"audio_guidance_scale",val:": float | None = 7.0"},{name:"audio_stg_scale",val:": float | None = 1.0"},{name:"audio_modality_scale",val:": float | None = 3.0"},{name:"audio_guidance_rescale",val:": float | None = 0.7"},{name:"spatio_temporal_guidance_blocks",val:": list[int] | None = [28]"},{name:"noise_scale",val:": float = 0.0"},{name:"num_videos_per_prompt",val:": int = 1"},{name:"generator",val:": typing.Union[torch.Generator, list[torch.Generator], NoneType] = None"},{name:"latents",val:": typing.Optional[torch.Tensor] = None"},{name:"audio_latents",val:": typing.Optional[torch.Tensor] = None"},{name:"prompt_embeds",val:": typing.Optional[torch.Tensor] = None"},{name:"prompt_attention_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"negative_prompt_embeds",val:": typing.Optional[torch.Tensor] = None"},{name:"negative_prompt_attention_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"decode_timestep",val:": float | list[float] = 0.0"},{name:"decode_noise_scale",val:": float | list[float] | None = None"},{name:"use_cross_timestep",val:": bool = True"},{name:"system_prompt",val:": str | None = None"},{name:"enable_prompt_enhancement",val:": bool = False"},{name:"prompt_max_new_tokens",val:": int | None = None"},{name:"prompt_enhancement_kwargs",val:": dict[str, typing.Any] | None = None"},{name:"prompt_enhancement_seed",val:": int = 10"},{name:"output_type",val:": str = 'pil'"},{name:"return_dict",val:": bool = True"},{name:"attention_kwargs",val:": dict[str, typing.Any] | None = None"},{name:"callback_on_step_end",val:": typing.Optional[typing.Callable[[int, int], NoneType]] = None"},{name:"callback_on_step_end_tensor_inputs",val:": list = ['latents']"},{name:"max_sequence_length",val:": int = 1024"}],parametersDescription:[{anchor:"diffusers.LTX2Pipeline.__call__.prompt",description:`<strong>prompt</strong> (<code>str</code> or <code>list[str]</code>, <em>optional</em>) &#x2014;
The prompt or prompts to guide the image generation. If not defined, one has to pass <code>prompt_embeds</code>.
instead.`,name:"prompt"},{anchor:"diffusers.LTX2Pipeline.__call__.negative_prompt",description:`<strong>negative_prompt</strong> (<code>str</code> or <code>list[str]</code>, <em>optional</em>) &#x2014;
The prompt or prompts not to guide the image generation. If not defined, one has to pass
<code>negative_prompt_embeds</code> instead. Ignored when not using guidance (<code>guidance_scale &lt; 1</code>).`,name:"negative_prompt"},{anchor:"diffusers.LTX2Pipeline.__call__.height",description:`<strong>height</strong> (<code>int</code>, <em>optional</em>, defaults to <code>512</code>) &#x2014;
The height in pixels of the generated image. This is set to 480 by default for the best results.`,name:"height"},{anchor:"diffusers.LTX2Pipeline.__call__.width",description:`<strong>width</strong> (<code>int</code>, <em>optional</em>, defaults to <code>768</code>) &#x2014;
The width in pixels of the generated image. This is set to 848 by default for the best results.`,name:"width"},{anchor:"diffusers.LTX2Pipeline.__call__.num_frames",description:`<strong>num_frames</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The number of video frames to generate. If not supplied, defaults to an auto-predicted duration when
this pipeline has a <code>duration_head</code> component (LTX-2.5 checkpoints and later), and to <code>121</code> otherwise.
Pass an integer to set the length explicitly. Auto-predicted counts are snapped to the VAE&#x2019;s causal
temporal grid, so the realized duration is quantized (roughly 0.33s at 24 fps).`,name:"num_frames"},{anchor:"diffusers.LTX2Pipeline.__call__.min_seconds",description:`<strong>min_seconds</strong> (<code>float</code>, <em>optional</em>, defaults to <code>1.0</code>) &#x2014;
Lower bound on the auto-predicted duration when <code>num_frames</code> is omitted and a <code>duration_head</code> is
present. Ignored when <code>num_frames</code> is set explicitly.`,name:"min_seconds"},{anchor:"diffusers.LTX2Pipeline.__call__.max_seconds",description:`<strong>max_seconds</strong> (<code>float</code>, <em>optional</em>, defaults to <code>20.0</code>) &#x2014;
Upper bound on the auto-predicted duration when <code>num_frames</code> is omitted and a <code>duration_head</code> is
present. Ignored when <code>num_frames</code> is set explicitly. Must be strictly greater than <code>min_seconds</code>.`,name:"max_seconds"},{anchor:"diffusers.LTX2Pipeline.__call__.frame_rate",description:`<strong>frame_rate</strong> (<code>float</code>, <em>optional</em>, defaults to <code>24.0</code>) &#x2014;
The frames per second (FPS) of the generated video.`,name:"frame_rate"},{anchor:"diffusers.LTX2Pipeline.__call__.num_inference_steps",description:`<strong>num_inference_steps</strong> (<code>int</code>, <em>optional</em>, defaults to 30) &#x2014;
The number of denoising steps. More denoising steps usually lead to a higher quality image at the
expense of slower inference.`,name:"num_inference_steps"},{anchor:"diffusers.LTX2Pipeline.__call__.sigmas",description:`<strong>sigmas</strong> (<code>List[float]</code>, <em>optional</em>) &#x2014;
Custom sigmas to use for the denoising process with schedulers which support a <code>sigmas</code> argument in
their <code>set_timesteps</code> method. If not defined, the default behavior when <code>num_inference_steps</code> is passed
will be used.`,name:"sigmas"},{anchor:"diffusers.LTX2Pipeline.__call__.timesteps",description:`<strong>timesteps</strong> (<code>list[int]</code>, <em>optional</em>) &#x2014;
Custom timesteps to use for the denoising process with schedulers which support a <code>timesteps</code> argument
in their <code>set_timesteps</code> method. If not defined, the default behavior when <code>num_inference_steps</code> is
passed will be used. Must be in descending order.`,name:"timesteps"},{anchor:"diffusers.LTX2Pipeline.__call__.guidance_scale",description:`<strong>guidance_scale</strong> (<code>float</code>, <em>optional</em>, defaults to <code>4.0</code>) &#x2014;
Guidance scale as defined in <a href="https://huggingface.co/papers/2207.12598" rel="nofollow">Classifier-Free Diffusion
Guidance</a>. <code>guidance_scale</code> is defined as <code>w</code> of equation 2.
of <a href="https://huggingface.co/papers/2205.11487" rel="nofollow">Imagen Paper</a>. Guidance scale is enabled by setting
<code>guidance_scale &gt; 1</code>. Higher guidance scale encourages to generate images that are closely linked to
the text <code>prompt</code>, usually at the expense of lower image quality. Used for the video modality (there is
a separate value <code>audio_guidance_scale</code> for the audio modality).`,name:"guidance_scale"},{anchor:"diffusers.LTX2Pipeline.__call__.stg_scale",description:`<strong>stg_scale</strong> (<code>float</code>, <em>optional</em>, defaults to <code>0.0</code>) &#x2014;
Video guidance scale for Spatio-Temporal Guidance (STG), proposed in <a href="https://arxiv.org/abs/2411.18664" rel="nofollow">Spatiotemporal Skip Guidance for
Enhanced Video Diffusion Sampling</a>. STG uses a CFG-like estimate
where we move the sample away from a weak sample from a perturbed version of the denoising model.
Enabling STG will result in an additional denoising model forward pass; the default value of <code>0.0</code>
means that STG is disabled.`,name:"stg_scale"},{anchor:"diffusers.LTX2Pipeline.__call__.modality_scale",description:`<strong>modality_scale</strong> (<code>float</code>, <em>optional</em>, defaults to <code>1.0</code>) &#x2014;
Video guidance scale for LTX-2.X modality isolation guidance, where we move the sample away from a
weaker sample generated by the denoising model withy cross-modality (audio-to-video and video-to-audio)
cross attention disabled using a CFG-like estimate. Enabling modality guidance will result in an
additional denoising model forward pass; the default value of <code>1.0</code> means that modality guidance is
disabled.`,name:"modality_scale"},{anchor:"diffusers.LTX2Pipeline.__call__.guidance_rescale",description:`<strong>guidance_rescale</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
Guidance rescale factor proposed by <a href="https://huggingface.co/papers/2305.08891" rel="nofollow">Common Diffusion Noise Schedules and Sample Steps are
Flawed</a> <code>guidance_scale</code> is defined as <code>&#x3C6;</code> in equation 16. of
<a href="https://huggingface.co/papers/2305.08891" rel="nofollow">Common Diffusion Noise Schedules and Sample Steps are
Flawed</a>. Guidance rescale factor should fix overexposure when
using zero terminal SNR. Used for the video modality.`,name:"guidance_rescale"},{anchor:"diffusers.LTX2Pipeline.__call__.audio_guidance_scale",description:`<strong>audio_guidance_scale</strong> (<code>float</code>, <em>optional</em> defaults to <code>None</code>) &#x2014;
Audio guidance scale for CFG with respect to the negative prompt. The CFG update rule is the same for
video and audio, but they can use different values for the guidance scale. The LTX-2.X authors suggest
that the <code>audio_guidance_scale</code> should be higher relative to the video <code>guidance_scale</code> (e.g. for
LTX-2.3 they suggest 3.0 for video and 7.0 for audio). If <code>None</code>, defaults to the video value
<code>guidance_scale</code>.`,name:"audio_guidance_scale"},{anchor:"diffusers.LTX2Pipeline.__call__.audio_stg_scale",description:`<strong>audio_stg_scale</strong> (<code>float</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
Audio guidance scale for STG. As with CFG, the STG update rule is otherwise the same for video and
audio. For LTX-2.3, a value of 1.0 is suggested for both video and audio. If <code>None</code>, defaults to the
video value <code>stg_scale</code>.`,name:"audio_stg_scale"},{anchor:"diffusers.LTX2Pipeline.__call__.audio_modality_scale",description:`<strong>audio_modality_scale</strong> (<code>float</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
Audio guidance scale for LTX-2.X modality isolation guidance. As with CFG, the modality guidance rule
is otherwise the same for video and audio. For LTX-2.3, a value of 3.0 is suggested for both video and
audio. If <code>None</code>, defaults to the video value <code>modality_scale</code>.`,name:"audio_modality_scale"},{anchor:"diffusers.LTX2Pipeline.__call__.audio_guidance_rescale",description:`<strong>audio_guidance_rescale</strong> (<code>float</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
A separate guidance rescale factor for the audio modality. If <code>None</code>, defaults to the video value
<code>guidance_rescale</code>.`,name:"audio_guidance_rescale"},{anchor:"diffusers.LTX2Pipeline.__call__.spatio_temporal_guidance_blocks",description:`<strong>spatio_temporal_guidance_blocks</strong> (<code>list[int]</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
The zero-indexed transformer block indices at which to apply STG. Must be supplied if STG is used
(<code>stg_scale</code> or <code>audio_stg_scale</code> is greater than <code>0</code>). A value of <code>[29]</code> is recommended for LTX-2.0
and <code>[28]</code> is recommended for LTX-2.3.`,name:"spatio_temporal_guidance_blocks"},{anchor:"diffusers.LTX2Pipeline.__call__.noise_scale",description:`<strong>noise_scale</strong> (<code>float</code>, <em>optional</em>, defaults to <code>0.0</code>) &#x2014;
The interpolation factor between random noise and denoised latents at each timestep. Applying noise to
the <code>latents</code> and <code>audio_latents</code> before continue denoising.`,name:"noise_scale"},{anchor:"diffusers.LTX2Pipeline.__call__.num_videos_per_prompt",description:`<strong>num_videos_per_prompt</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
The number of videos to generate per prompt.`,name:"num_videos_per_prompt"},{anchor:"diffusers.LTX2Pipeline.__call__.generator",description:`<strong>generator</strong> (<code>torch.Generator</code> or <code>list[torch.Generator]</code>, <em>optional</em>) &#x2014;
One or a list of <a href="https://pytorch.org/docs/stable/generated/torch.Generator.html" rel="nofollow">torch generator(s)</a>
to make generation deterministic.`,name:"generator"},{anchor:"diffusers.LTX2Pipeline.__call__.latents",description:`<strong>latents</strong> (<code>torch.Tensor</code>, <em>optional</em>) &#x2014;
Pre-generated noisy latents, sampled from a Gaussian distribution, to be used as inputs for video
generation. Can be used to tweak the same generation with different prompts. If not provided, a latents
tensor will be generated by sampling using the supplied random <code>generator</code>.`,name:"latents"},{anchor:"diffusers.LTX2Pipeline.__call__.audio_latents",description:`<strong>audio_latents</strong> (<code>torch.Tensor</code>, <em>optional</em>) &#x2014;
Pre-generated noisy latents, sampled from a Gaussian distribution, to be used as inputs for audio
generation. Can be used to tweak the same generation with different prompts. If not provided, a latents
tensor will be generated by sampling using the supplied random <code>generator</code>.`,name:"audio_latents"},{anchor:"diffusers.LTX2Pipeline.__call__.prompt_embeds",description:`<strong>prompt_embeds</strong> (<code>torch.Tensor</code>, <em>optional</em>) &#x2014;
Pre-generated text embeddings. Can be used to easily tweak text inputs, <em>e.g.</em> prompt weighting. If not
provided, text embeddings will be generated from <code>prompt</code> input argument.`,name:"prompt_embeds"},{anchor:"diffusers.LTX2Pipeline.__call__.prompt_attention_mask",description:`<strong>prompt_attention_mask</strong> (<code>torch.Tensor</code>, <em>optional</em>) &#x2014;
Pre-generated attention mask for text embeddings.`,name:"prompt_attention_mask"},{anchor:"diffusers.LTX2Pipeline.__call__.negative_prompt_embeds",description:`<strong>negative_prompt_embeds</strong> (<code>torch.FloatTensor</code>, <em>optional</em>) &#x2014;
Pre-generated negative text embeddings. For PixArt-Sigma this negative prompt should be &quot;&quot;. If not
provided, negative_prompt_embeds will be generated from <code>negative_prompt</code> input argument.`,name:"negative_prompt_embeds"},{anchor:"diffusers.LTX2Pipeline.__call__.negative_prompt_attention_mask",description:`<strong>negative_prompt_attention_mask</strong> (<code>torch.FloatTensor</code>, <em>optional</em>) &#x2014;
Pre-generated attention mask for negative text embeddings.`,name:"negative_prompt_attention_mask"},{anchor:"diffusers.LTX2Pipeline.__call__.decode_timestep",description:`<strong>decode_timestep</strong> (<code>float</code>, defaults to <code>0.0</code>) &#x2014;
The timestep at which generated video is decoded.`,name:"decode_timestep"},{anchor:"diffusers.LTX2Pipeline.__call__.decode_noise_scale",description:`<strong>decode_noise_scale</strong> (<code>float</code>, defaults to <code>None</code>) &#x2014;
The interpolation factor between random noise and denoised latents at the decode timestep.`,name:"decode_noise_scale"},{anchor:"diffusers.LTX2Pipeline.__call__.use_cross_timestep",description:`<strong>use_cross_timestep</strong> (<code>bool</code> <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to use the cross modality (audio is the cross modality of video, and vice versa) sigma when
calculating the cross attention modulation parameters. <code>True</code> is the LTX-2.3/2.5 behavior; <code>False</code> is
the legacy LTX-2.0 behavior.`,name:"use_cross_timestep"},{anchor:"diffusers.LTX2Pipeline.__call__.system_prompt",description:`<strong>system_prompt</strong> (<code>str</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
Optional system prompt to use for prompt enhancement. The system prompt will be used by the prompt
enhancer (a Gemma conditional-generation model &#x2014; the dedicated <code>prompt_enhancer</code> component if one is
configured, otherwise the main <code>text_encoder</code>) to generate an enhanced prompt from the original
<code>prompt</code> to condition generation. If not supplied and a dedicated <code>prompt_enhancer</code> is configured
(LTX-2.5), defaults to <code>LTX2_5_T2V_DEFAULT_SYSTEM_PROMPT</code> (from <code>diffusers.pipelines.ltx2.utils</code>) &#x2014;
see <code>enable_prompt_enhancement</code>.`,name:"system_prompt"},{anchor:"diffusers.LTX2Pipeline.__call__.enable_prompt_enhancement",description:`<strong>enable_prompt_enhancement</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to run prompt enhancement. Opt-in, matching the Lightricks reference pipelines. When <code>True</code> and
<code>system_prompt</code> is omitted, LTX-2.5 uses <code>LTX2_5_T2V_DEFAULT_SYSTEM_PROMPT</code> if a dedicated
<code>prompt_enhancer</code> is configured; LTX-2.0/2.3 require an explicit <code>system_prompt</code>.`,name:"enable_prompt_enhancement"},{anchor:"diffusers.LTX2Pipeline.__call__.prompt_max_new_tokens",description:`<strong>prompt_max_new_tokens</strong> (<code>int</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
The maximum number of new tokens to generate when performing prompt enhancement. If not supplied, uses
600 for a dedicated Gemma 4 <code>prompt_enhancer</code> (LTX-2.5) or 512 for the Gemma 3 <code>text_encoder</code> fallback
(LTX-2.0/2.3).`,name:"prompt_max_new_tokens"},{anchor:"diffusers.LTX2Pipeline.__call__.prompt_enhancement_kwargs",description:`<strong>prompt_enhancement_kwargs</strong> (<code>dict[str, Any]</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
Keyword arguments for the prompt enhancer&#x2019;s <code>.generate</code> call. If not supplied, always matches whichever
model is doing the enhancing: <code>do_sample=False, no_repeat_ngram_size=5</code> (greedy) when using a dedicated
<code>prompt_enhancer</code> (LTX-2.5), or <code>do_sample=True, temperature=0.7</code> for the <code>text_encoder</code> fallback
(LTX-2.0/2.3). See
<a href="https://huggingface.co/docs/transformers/main/en/main_classes/text_generation#transformers.GenerationMixin.generate" rel="nofollow">https://huggingface.co/docs/transformers/main/en/main_classes/text_generation#transformers.GenerationMixin.generate</a>
for more details.`,name:"prompt_enhancement_kwargs"},{anchor:"diffusers.LTX2Pipeline.__call__.prompt_enhancement_seed",description:`<strong>prompt_enhancement_seed</strong> (<code>int</code>, <em>optional</em>, defaults to <code>10</code>) &#x2014;
Random seed for any random operations during prompt enhancement.`,name:"prompt_enhancement_seed"},{anchor:"diffusers.LTX2Pipeline.__call__.output_type",description:`<strong>output_type</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;pil&quot;</code>) &#x2014;
The output format of the generate image. Choose between
<a href="https://pillow.readthedocs.io/en/stable/" rel="nofollow">PIL</a>: <code>PIL.Image.Image</code> or <code>np.array</code>.`,name:"output_type"},{anchor:"diffusers.LTX2Pipeline.__call__.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to return a <code>~pipelines.ltx.LTX2PipelineOutput</code> instead of a plain tuple.`,name:"return_dict"},{anchor:"diffusers.LTX2Pipeline.__call__.attention_kwargs",description:`<strong>attention_kwargs</strong> (<code>dict</code>, <em>optional</em>) &#x2014;
A kwargs dictionary that if specified is passed along to the <code>AttentionProcessor</code> as defined under
<code>self.processor</code> in
<a href="https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/attention_processor.py" rel="nofollow">diffusers.models.attention_processor</a>.`,name:"attention_kwargs"},{anchor:"diffusers.LTX2Pipeline.__call__.callback_on_step_end",description:`<strong>callback_on_step_end</strong> (<code>Callable</code>, <em>optional</em>) &#x2014;
A function that calls at the end of each denoising steps during the inference. The function is called
with the following arguments: <code>callback_on_step_end(self: DiffusionPipeline, step: int, timestep: int, callback_kwargs: Dict)</code>. <code>callback_kwargs</code> will include a list of all tensors as specified by
<code>callback_on_step_end_tensor_inputs</code>.`,name:"callback_on_step_end"},{anchor:"diffusers.LTX2Pipeline.__call__.callback_on_step_end_tensor_inputs",description:`<strong>callback_on_step_end_tensor_inputs</strong> (<code>List</code>, <em>optional</em>, defaults to <code>[&quot;latents&quot;]</code>) &#x2014;
The list of tensor inputs for the <code>callback_on_step_end</code> function. The tensors specified in the list
will be passed as <code>callback_kwargs</code> argument. You will only be able to include variables listed in the
<code>._callback_tensor_inputs</code> attribute of your pipeline class.`,name:"callback_on_step_end_tensor_inputs"},{anchor:"diffusers.LTX2Pipeline.__call__.max_sequence_length",description:`<strong>max_sequence_length</strong> (<code>int</code>, <em>optional</em>, defaults to <code>1024</code>) &#x2014;
Maximum sequence length to use with the <code>prompt</code>.`,name:"max_sequence_length"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>
<p>If <code>return_dict</code> is <code>True</code>, <code>~pipelines.ltx.LTX2PipelineOutput</code> is returned, otherwise a <code>tuple</code> is
returned where the first element is a list with the generated images.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>
<p><code>~pipelines.ltx.LTX2PipelineOutput</code> or <code>tuple</code></p>
`});var Ke=e(be,4);u(Ke,{anchor:"diffusers.LTX2Pipeline.__call__.example",children:(d,c)=>{var i=h(),r=e(m(i),2);s(r,{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwTFRYMlBpcGVsaW5lJTBBZnJvbSUyMGRpZmZ1c2Vycy51dGlscyUyMGltcG9ydCUyMGVuY29kZV92aWRlbyUwQSUwQXBpcGUlMjAlM0QlMjBMVFgyUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUyMkxpZ2h0cmlja3MlMkZMVFgtMiUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guYmZsb2F0MTYpJTBBcGlwZS5lbmFibGVfbW9kZWxfY3B1X29mZmxvYWQoKSUwQSUwQXByb21wdCUyMCUzRCUyMCUyMkElMjB3b21hbiUyMHdpdGglMjBsb25nJTIwYnJvd24lMjBoYWlyJTIwYW5kJTIwbGlnaHQlMjBza2luJTIwc21pbGVzJTIwYXQlMjBhbm90aGVyJTIwd29tYW4lMjB3aXRoJTIwbG9uZyUyMGJsb25kZSUyMGhhaXIuJTIwVGhlJTIwd29tYW4lMjB3aXRoJTIwYnJvd24lMjBoYWlyJTIwd2VhcnMlMjBhJTIwYmxhY2slMjBqYWNrZXQlMjBhbmQlMjBoYXMlMjBhJTIwc21hbGwlMkMlMjBiYXJlbHklMjBub3RpY2VhYmxlJTIwbW9sZSUyMG9uJTIwaGVyJTIwcmlnaHQlMjBjaGVlay4lMjBUaGUlMjBjYW1lcmElMjBhbmdsZSUyMGlzJTIwYSUyMGNsb3NlLXVwJTJDJTIwZm9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yMCUyMCUyMCUyMHJldHVybl9kaWN0JTNERmFsc2UlMkMlMEEpJTBBJTBBZW5jb2RlX3ZpZGVvKCUwQSUyMCUyMCUyMCUyMHZpZGVvJTVCMCU1RCUyQyUwQSUyMCUyMCUyMCUyMGZwcyUzRGZyYW1lX3JhdGUlMkMlMEElMjAlMjAlMjAlMjBhdWRpbyUzRGF1ZGlvJTVCMCU1RC5mbG9hdCgpLmNwdSgpJTJDJTBBJTIwJTIwJTIwJTIwYXVkaW9fc2FtcGxlX3JhdGUlM0RwaXBlLnZvY29kZXIuY29uZmlnLm91dHB1dF9zYW1wbGluZ19yYXRlJTJDJTIwJTIwJTIzJTIwc2hvdWxkJTIwYmUlMjAyNDAwMCUwQSUyMCUyMCUyMCUyMG91dHB1dF9wYXRoJTNEJTIydmlkZW8ubXA0JTIyJTJDJTBBKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> LTX2Pipeline
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> encode_video
<span class="hljs-meta">&gt;&gt;&gt; </span>pipe = LTX2Pipeline.from_pretrained(<span class="hljs-string">&quot;Lightricks/LTX-2&quot;</span>, torch_dtype=torch.bfloat16)
<span class="hljs-meta">&gt;&gt;&gt; </span>pipe.enable_model_cpu_offload()
<span class="hljs-meta">&gt;&gt;&gt; </span>prompt = <span class="hljs-string">&quot;A woman with long brown hair and light skin smiles at another woman with long blonde hair. The woman with brown hair wears a black jacket and has a small, barely noticeable mole on her right cheek. The camera angle is a close-up, focused on the woman with brown hair&#x27;s face. The lighting is warm and natural, likely from the setting sun, casting a soft glow on the scene. The scene appears to be real-life footage&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>negative_prompt = <span class="hljs-string">&quot;worst quality, inconsistent motion, blurry, jittery, distorted&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>frame_rate = <span class="hljs-number">24.0</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>video, audio = pipe(
<span class="hljs-meta">... </span> prompt=prompt,
<span class="hljs-meta">... </span> negative_prompt=negative_prompt,
<span class="hljs-meta">... </span> width=<span class="hljs-number">768</span>,
<span class="hljs-meta">... </span> height=<span class="hljs-number">512</span>,
<span class="hljs-meta">... </span> num_frames=<span class="hljs-number">121</span>,
<span class="hljs-meta">... </span> frame_rate=frame_rate,
<span class="hljs-meta">... </span> num_inference_steps=<span class="hljs-number">30</span>,
<span class="hljs-meta">... </span> guidance_scale=<span class="hljs-number">3.0</span>,
<span class="hljs-meta">... </span> output_type=<span class="hljs-string">&quot;np&quot;</span>,
<span class="hljs-meta">... </span> return_dict=<span class="hljs-literal">False</span>,
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>encode_video(
<span class="hljs-meta">... </span> video[<span class="hljs-number">0</span>],
<span class="hljs-meta">... </span> fps=frame_rate,
<span class="hljs-meta">... </span> audio=audio[<span class="hljs-number">0</span>].<span class="hljs-built_in">float</span>().cpu(),
<span class="hljs-meta">... </span> audio_sample_rate=pipe.vocoder.config.output_sampling_rate, <span class="hljs-comment"># should be 24000</span>
<span class="hljs-meta">... </span> output_path=<span class="hljs-string">&quot;video.mp4&quot;</span>,
<span class="hljs-meta">... </span>)`,lang:"py",wrap:!1}),p(d,i)},$$slots:{default:!0}}),a(f);var g=e(f,2),Oe=n(g);o(Oe,{name:"encode_prompt",anchor:"diffusers.LTX2Pipeline.encode_prompt",source:"https://github.com/huggingface/diffusers/blob/vr_14588/src/diffusers/pipelines/ltx2/pipeline_ltx2.py#L364",parameters:[{name:"prompt",val:": str | list[str]"},{name:"negative_prompt",val:": str | list[str] | None = None"},{name:"do_classifier_free_guidance",val:": bool = True"},{name:"num_videos_per_prompt",val:": int = 1"},{name:"prompt_embeds",val:": typing.Optional[torch.Tensor] = None"},{name:"negative_prompt_embeds",val:": typing.Optional[torch.Tensor] = None"},{name:"prompt_attention_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"negative_prompt_attention_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"max_sequence_length",val:": int = 1024"},{name:"scale_factor",val:": int = 8"},{name:"device",val:": typing.Optional[torch.device] = None"},{name:"dtype",val:": typing.Optional[torch.dtype] = None"}],parametersDescription:[{anchor:"diffusers.LTX2Pipeline.encode_prompt.prompt",description:`<strong>prompt</strong> (<code>str</code> or <code>list[str]</code>, <em>optional</em>) &#x2014;
prompt to be encoded`,name:"prompt"},{anchor:"diffusers.LTX2Pipeline.encode_prompt.negative_prompt",description:`<strong>negative_prompt</strong> (<code>str</code> or <code>list[str]</code>, <em>optional</em>) &#x2014;
The prompt or prompts not to guide the image generation. If not defined, one has to pass
<code>negative_prompt_embeds</code> instead. Ignored when not using guidance (i.e., ignored if <code>guidance_scale</code> is
less than <code>1</code>).`,name:"negative_prompt"},{anchor:"diffusers.LTX2Pipeline.encode_prompt.do_classifier_free_guidance",description:`<strong>do_classifier_free_guidance</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to use classifier free guidance or not.`,name:"do_classifier_free_guidance"},{anchor:"diffusers.LTX2Pipeline.encode_prompt.num_videos_per_prompt",description:`<strong>num_videos_per_prompt</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
Number of videos that should be generated per prompt. torch device to place the resulting embeddings on`,name:"num_videos_per_prompt"},{anchor:"diffusers.LTX2Pipeline.encode_prompt.prompt_embeds",description:`<strong>prompt_embeds</strong> (<code>torch.Tensor</code>, <em>optional</em>) &#x2014;
Pre-generated text embeddings. Can be used to easily tweak text inputs, <em>e.g.</em> prompt weighting. If not
provided, text embeddings will be generated from <code>prompt</code> input argument.`,name:"prompt_embeds"},{anchor:"diffusers.LTX2Pipeline.encode_prompt.negative_prompt_embeds",description:`<strong>negative_prompt_embeds</strong> (<code>torch.Tensor</code>, <em>optional</em>) &#x2014;
Pre-generated negative text embeddings. Can be used to easily tweak text inputs, <em>e.g.</em> prompt
weighting. If not provided, negative_prompt_embeds will be generated from <code>negative_prompt</code> input
argument.`,name:"negative_prompt_embeds"},{anchor:"diffusers.LTX2Pipeline.encode_prompt.device",description:`<strong>device</strong> &#x2014; (<code>torch.device</code>, <em>optional</em>):
torch device`,name:"device"},{anchor:"diffusers.LTX2Pipeline.encode_prompt.dtype",description:`<strong>dtype</strong> &#x2014; (<code>torch.dtype</code>, <em>optional</em>):
torch dtype`,name:"dtype"}]}),l(2),a(g);var Ue=e(g,2),$e=n(Ue);o($e,{name:"enhance_prompt",anchor:"diffusers.LTX2Pipeline.enhance_prompt",source:"https://github.com/huggingface/diffusers/blob/vr_14588/src/diffusers/pipelines/ltx2/pipeline_ltx2.py#L571",parameters:[{name:"prompt",val:": str"},{name:"system_prompt",val:": str"},{name:"max_new_tokens",val:": int | None = None"},{name:"seed",val:": int = 10"},{name:"generator",val:": typing.Optional[torch.Generator] = None"},{name:"generation_kwargs",val:": dict[str, typing.Any] | None = None"},{name:"device",val:": typing.Union[torch.device, str, NoneType] = None"},{name:"image",val:": typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor], NoneType] = None"}]}),l(4),a(Ue),a(M);var je=e(M,2);t(je,{title:"LTX2ImageToVideoPipeline",local:"diffusers.LTX2ImageToVideoPipeline",headingTag:"h2"});var T=e(je,2),Ze=n(T);o(Ze,{name:"class diffusers.LTX2ImageToVideoPipeline",anchor:"diffusers.LTX2ImageToVideoPipeline",source:"https://github.com/huggingface/diffusers/blob/vr_14588/src/diffusers/pipelines/ltx2/pipeline_ltx2_image2video.py#L226",parameters:[{name:"scheduler",val:": FlowMatchEulerDiscreteScheduler"},{name:"vae",val:": AutoencoderKLLTX2Video"},{name:"audio_vae",val:": AutoencoderKLLTX2Audio"},{name:"text_encoder",val:": transformers.models.gemma3.modeling_gemma3.Gemma3ForConditionalGeneration | transformers.models.gemma4_unified.modeling_gemma4_unified.Gemma4UnifiedForConditionalGeneration"},{name:"tokenizer",val:": GemmaTokenizer"},{name:"connectors",val:": LTX2TextConnectors"},{name:"transformer",val:": LTX2VideoTransformer3DModel"},{name:"vocoder",val:": diffusers.pipelines.ltx2.vocoder.LTX2Vocoder | diffusers.pipelines.ltx2.vocoder.LTX2VocoderWithBWE"},{name:"processor",val:": transformers.processing_utils.ProcessorMixin | None = None"},{name:"prompt_enhancer",val:": transformers.models.gemma4.modeling_gemma4.Gemma4ForConditionalGeneration | None = None"},{name:"duration_head",val:": diffusers.pipelines.ltx2.duration_head.LTX2DurationHead | None = None"}]});var _=e(Ze,8),ve=n(_);o(ve,{name:"__call__",anchor:"diffusers.LTX2ImageToVideoPipeline.__call__",source:"https://github.com/huggingface/diffusers/blob/vr_14588/src/diffusers/pipelines/ltx2/pipeline_ltx2_image2video.py#L980",parameters:[{name:"image",val:": typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor]] = None"},{name:"prompt",val:": str | list[str] = None"},{name:"negative_prompt",val:": str | list[str] | None = None"},{name:"height",val:": int = 512"},{name:"width",val:": int = 768"},{name:"num_frames",val:": int | None = None"},{name:"min_seconds",val:": float = 1.0"},{name:"max_seconds",val:": float = 20.0"},{name:"frame_rate",val:": float = 24.0"},{name:"num_inference_steps",val:": int = 30"},{name:"sigmas",val:": list[float] | None = None"},{name:"timesteps",val:": list[int] | None = None"},{name:"guidance_scale",val:": float = 3.0"},{name:"stg_scale",val:": float = 1.0"},{name:"modality_scale",val:": float = 3.0"},{name:"guidance_rescale",val:": float = 0.7"},{name:"audio_guidance_scale",val:": float | None = 7.0"},{name:"audio_stg_scale",val:": float | None = 1.0"},{name:"audio_modality_scale",val:": float | None = 3.0"},{name:"audio_guidance_rescale",val:": float | None = 0.7"},{name:"spatio_temporal_guidance_blocks",val:": list[int] | None = [28]"},{name:"noise_scale",val:": float = 0.0"},{name:"num_videos_per_prompt",val:": int = 1"},{name:"generator",val:": typing.Union[torch.Generator, list[torch.Generator], NoneType] = None"},{name:"latents",val:": typing.Optional[torch.Tensor] = None"},{name:"audio_latents",val:": typing.Optional[torch.Tensor] = None"},{name:"prompt_embeds",val:": typing.Optional[torch.Tensor] = None"},{name:"prompt_attention_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"negative_prompt_embeds",val:": typing.Optional[torch.Tensor] = None"},{name:"negative_prompt_attention_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"decode_timestep",val:": float | list[float] = 0.0"},{name:"decode_noise_scale",val:": float | list[float] | None = None"},{name:"use_cross_timestep",val:": bool = True"},{name:"system_prompt",val:": str | None = None"},{name:"enable_prompt_enhancement",val:": bool = False"},{name:"prompt_max_new_tokens",val:": int | None = None"},{name:"prompt_enhancement_kwargs",val:": dict[str, typing.Any] | None = None"},{name:"prompt_enhancement_seed",val:": int = 10"},{name:"image_crf",val:": int | None = None"},{name:"output_type",val:": str = 'pil'"},{name:"return_dict",val:": bool = True"},{name:"attention_kwargs",val:": dict[str, typing.Any] | None = None"},{name:"callback_on_step_end",val:": typing.Optional[typing.Callable[[int, int], NoneType]] = None"},{name:"callback_on_step_end_tensor_inputs",val:": list = ['latents']"},{name:"max_sequence_length",val:": int = 1024"}],parametersDescription:[{anchor:"diffusers.LTX2ImageToVideoPipeline.__call__.image",description:`<strong>image</strong> (<code>PipelineImageInput</code>) &#x2014;
The input image to condition the generation on. Must be an image, a list of images or a <code>torch.Tensor</code>.`,name:"image"},{anchor:"diffusers.LTX2ImageToVideoPipeline.__call__.prompt",description:`<strong>prompt</strong> (<code>str</code> or <code>list[str]</code>, <em>optional</em>) &#x2014;
The prompt or prompts to guide the image generation. If not defined, one has to pass <code>prompt_embeds</code>.
instead.`,name:"prompt"},{anchor:"diffusers.LTX2ImageToVideoPipeline.__call__.negative_prompt",description:`<strong>negative_prompt</strong> (<code>str</code> or <code>list[str]</code>, <em>optional</em>) &#x2014;
The prompt or prompts not to guide the image generation. If not defined, one has to pass
<code>negative_prompt_embeds</code> instead. Ignored when not using guidance (<code>guidance_scale &lt; 1</code>).`,name:"negative_prompt"},{anchor:"diffusers.LTX2ImageToVideoPipeline.__call__.height",description:`<strong>height</strong> (<code>int</code>, <em>optional</em>, defaults to <code>512</code>) &#x2014;
The height in pixels of the generated image. This is set to 480 by default for the best results.`,name:"height"},{anchor:"diffusers.LTX2ImageToVideoPipeline.__call__.width",description:`<strong>width</strong> (<code>int</code>, <em>optional</em>, defaults to <code>768</code>) &#x2014;
The width in pixels of the generated image. This is set to 848 by default for the best results.`,name:"width"},{anchor:"diffusers.LTX2ImageToVideoPipeline.__call__.num_frames",description:`<strong>num_frames</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The number of video frames to generate. If not supplied, defaults to an auto-predicted duration when
this pipeline has a <code>duration_head</code> component (LTX-2.5 checkpoints and later), and to <code>121</code> otherwise.
Pass an integer to set the length explicitly. Auto-predicted counts are snapped to the VAE&#x2019;s causal
temporal grid, so the realized duration is quantized (roughly 0.33s at 24 fps).`,name:"num_frames"},{anchor:"diffusers.LTX2ImageToVideoPipeline.__call__.min_seconds",description:`<strong>min_seconds</strong> (<code>float</code>, <em>optional</em>, defaults to <code>1.0</code>) &#x2014;
Lower bound on the auto-predicted duration when <code>num_frames</code> is omitted and a <code>duration_head</code> is
present. Ignored when <code>num_frames</code> is set explicitly.`,name:"min_seconds"},{anchor:"diffusers.LTX2ImageToVideoPipeline.__call__.max_seconds",description:`<strong>max_seconds</strong> (<code>float</code>, <em>optional</em>, defaults to <code>20.0</code>) &#x2014;
Upper bound on the auto-predicted duration when <code>num_frames</code> is omitted and a <code>duration_head</code> is
present. Ignored when <code>num_frames</code> is set explicitly. Must be strictly greater than <code>min_seconds</code>.`,name:"max_seconds"},{anchor:"diffusers.LTX2ImageToVideoPipeline.__call__.frame_rate",description:`<strong>frame_rate</strong> (<code>float</code>, <em>optional</em>, defaults to <code>24.0</code>) &#x2014;
The frames per second (FPS) of the generated video.`,name:"frame_rate"},{anchor:"diffusers.LTX2ImageToVideoPipeline.__call__.num_inference_steps",description:`<strong>num_inference_steps</strong> (<code>int</code>, <em>optional</em>, defaults to 30) &#x2014;
The number of denoising steps. More denoising steps usually lead to a higher quality image at the
expense of slower inference.`,name:"num_inference_steps"},{anchor:"diffusers.LTX2ImageToVideoPipeline.__call__.sigmas",description:`<strong>sigmas</strong> (<code>List[float]</code>, <em>optional</em>) &#x2014;
Custom sigmas to use for the denoising process with schedulers which support a <code>sigmas</code> argument in
their <code>set_timesteps</code> method. If not defined, the default behavior when <code>num_inference_steps</code> is passed
will be used.`,name:"sigmas"},{anchor:"diffusers.LTX2ImageToVideoPipeline.__call__.timesteps",description:`<strong>timesteps</strong> (<code>List[int]</code>, <em>optional</em>) &#x2014;
Custom timesteps to use for the denoising process with schedulers which support a <code>timesteps</code> argument
in their <code>set_timesteps</code> method. If not defined, the default behavior when <code>num_inference_steps</code> is
passed will be used. Must be in descending order.`,name:"timesteps"},{anchor:"diffusers.LTX2ImageToVideoPipeline.__call__.guidance_scale",description:`<strong>guidance_scale</strong> (<code>float</code>, <em>optional</em>, defaults to <code>4.0</code>) &#x2014;
Guidance scale as defined in <a href="https://huggingface.co/papers/2207.12598" rel="nofollow">Classifier-Free Diffusion
Guidance</a>. <code>guidance_scale</code> is defined as <code>w</code> of equation 2.
of <a href="https://huggingface.co/papers/2205.11487" rel="nofollow">Imagen Paper</a>. Guidance scale is enabled by setting
<code>guidance_scale &gt; 1</code>. Higher guidance scale encourages to generate images that are closely linked to
the text <code>prompt</code>, usually at the expense of lower image quality. Used for the video modality (there is
a separate value <code>audio_guidance_scale</code> for the audio modality).`,name:"guidance_scale"},{anchor:"diffusers.LTX2ImageToVideoPipeline.__call__.stg_scale",description:`<strong>stg_scale</strong> (<code>float</code>, <em>optional</em>, defaults to <code>0.0</code>) &#x2014;
Video guidance scale for Spatio-Temporal Guidance (STG), proposed in <a href="https://arxiv.org/abs/2411.18664" rel="nofollow">Spatiotemporal Skip Guidance for
Enhanced Video Diffusion Sampling</a>. STG uses a CFG-like estimate
where we move the sample away from a weak sample from a perturbed version of the denoising model.
Enabling STG will result in an additional denoising model forward pass; the default value of <code>0.0</code>
means that STG is disabled.`,name:"stg_scale"},{anchor:"diffusers.LTX2ImageToVideoPipeline.__call__.modality_scale",description:`<strong>modality_scale</strong> (<code>float</code>, <em>optional</em>, defaults to <code>1.0</code>) &#x2014;
Video guidance scale for LTX-2.X modality isolation guidance, where we move the sample away from a
weaker sample generated by the denoising model withy cross-modality (audio-to-video and video-to-audio)
cross attention disabled using a CFG-like estimate. Enabling modality guidance will result in an
additional denoising model forward pass; the default value of <code>1.0</code> means that modality guidance is
disabled.`,name:"modality_scale"},{anchor:"diffusers.LTX2ImageToVideoPipeline.__call__.guidance_rescale",description:`<strong>guidance_rescale</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
Guidance rescale factor proposed by <a href="https://huggingface.co/papers/2305.08891" rel="nofollow">Common Diffusion Noise Schedules and Sample Steps are
Flawed</a> <code>guidance_scale</code> is defined as <code>&#x3C6;</code> in equation 16. of
<a href="https://huggingface.co/papers/2305.08891" rel="nofollow">Common Diffusion Noise Schedules and Sample Steps are
Flawed</a>. Guidance rescale factor should fix overexposure when
using zero terminal SNR. Used for the video modality.`,name:"guidance_rescale"},{anchor:"diffusers.LTX2ImageToVideoPipeline.__call__.audio_guidance_scale",description:`<strong>audio_guidance_scale</strong> (<code>float</code>, <em>optional</em> defaults to <code>None</code>) &#x2014;
Audio guidance scale for CFG with respect to the negative prompt. The CFG update rule is the same for
video and audio, but they can use different values for the guidance scale. The LTX-2.X authors suggest
that the <code>audio_guidance_scale</code> should be higher relative to the video <code>guidance_scale</code> (e.g. for
LTX-2.3 they suggest 3.0 for video and 7.0 for audio). If <code>None</code>, defaults to the video value
<code>guidance_scale</code>.`,name:"audio_guidance_scale"},{anchor:"diffusers.LTX2ImageToVideoPipeline.__call__.audio_stg_scale",description:`<strong>audio_stg_scale</strong> (<code>float</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
Audio guidance scale for STG. As with CFG, the STG update rule is otherwise the same for video and
audio. For LTX-2.3, a value of 1.0 is suggested for both video and audio. If <code>None</code>, defaults to the
video value <code>stg_scale</code>.`,name:"audio_stg_scale"},{anchor:"diffusers.LTX2ImageToVideoPipeline.__call__.audio_modality_scale",description:`<strong>audio_modality_scale</strong> (<code>float</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
Audio guidance scale for LTX-2.X modality isolation guidance. As with CFG, the modality guidance rule
is otherwise the same for video and audio. For LTX-2.3, a value of 3.0 is suggested for both video and
audio. If <code>None</code>, defaults to the video value <code>modality_scale</code>.`,name:"audio_modality_scale"},{anchor:"diffusers.LTX2ImageToVideoPipeline.__call__.audio_guidance_rescale",description:`<strong>audio_guidance_rescale</strong> (<code>float</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
A separate guidance rescale factor for the audio modality. If <code>None</code>, defaults to the video value
<code>guidance_rescale</code>.`,name:"audio_guidance_rescale"},{anchor:"diffusers.LTX2ImageToVideoPipeline.__call__.spatio_temporal_guidance_blocks",description:`<strong>spatio_temporal_guidance_blocks</strong> (<code>list[int]</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
The zero-indexed transformer block indices at which to apply STG. Must be supplied if STG is used
(<code>stg_scale</code> or <code>audio_stg_scale</code> is greater than <code>0</code>). A value of <code>[29]</code> is recommended for LTX-2.0
and <code>[28]</code> is recommended for LTX-2.3.`,name:"spatio_temporal_guidance_blocks"},{anchor:"diffusers.LTX2ImageToVideoPipeline.__call__.noise_scale",description:`<strong>noise_scale</strong> (<code>float</code>, <em>optional</em>, defaults to <code>0.0</code>) &#x2014;
The interpolation factor between random noise and denoised latents at each timestep. Applying noise to
the <code>latents</code> and <code>audio_latents</code> before continue denoising.`,name:"noise_scale"},{anchor:"diffusers.LTX2ImageToVideoPipeline.__call__.num_videos_per_prompt",description:`<strong>num_videos_per_prompt</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
The number of videos to generate per prompt.`,name:"num_videos_per_prompt"},{anchor:"diffusers.LTX2ImageToVideoPipeline.__call__.generator",description:`<strong>generator</strong> (<code>torch.Generator</code> or <code>list[torch.Generator]</code>, <em>optional</em>) &#x2014;
One or a list of <a href="https://pytorch.org/docs/stable/generated/torch.Generator.html" rel="nofollow">torch generator(s)</a>
to make generation deterministic.`,name:"generator"},{anchor:"diffusers.LTX2ImageToVideoPipeline.__call__.latents",description:`<strong>latents</strong> (<code>torch.Tensor</code>, <em>optional</em>) &#x2014;
Pre-generated noisy latents, sampled from a Gaussian distribution, to be used as inputs for video
generation. Can be used to tweak the same generation with different prompts. If not provided, a latents
tensor will be generated by sampling using the supplied random <code>generator</code>.`,name:"latents"},{anchor:"diffusers.LTX2ImageToVideoPipeline.__call__.audio_latents",description:`<strong>audio_latents</strong> (<code>torch.Tensor</code>, <em>optional</em>) &#x2014;
Pre-generated noisy latents, sampled from a Gaussian distribution, to be used as inputs for audio
generation. Can be used to tweak the same generation with different prompts. If not provided, a latents
tensor will be generated by sampling using the supplied random <code>generator</code>.`,name:"audio_latents"},{anchor:"diffusers.LTX2ImageToVideoPipeline.__call__.prompt_embeds",description:`<strong>prompt_embeds</strong> (<code>torch.Tensor</code>, <em>optional</em>) &#x2014;
Pre-generated text embeddings. Can be used to easily tweak text inputs, <em>e.g.</em> prompt weighting. If not
provided, text embeddings will be generated from <code>prompt</code> input argument.`,name:"prompt_embeds"},{anchor:"diffusers.LTX2ImageToVideoPipeline.__call__.prompt_attention_mask",description:`<strong>prompt_attention_mask</strong> (<code>torch.Tensor</code>, <em>optional</em>) &#x2014;
Pre-generated attention mask for text embeddings.`,name:"prompt_attention_mask"},{anchor:"diffusers.LTX2ImageToVideoPipeline.__call__.negative_prompt_embeds",description:`<strong>negative_prompt_embeds</strong> (<code>torch.FloatTensor</code>, <em>optional</em>) &#x2014;
Pre-generated negative text embeddings. For PixArt-Sigma this negative prompt should be &quot;&quot;. If not
provided, negative_prompt_embeds will be generated from <code>negative_prompt</code> input argument.`,name:"negative_prompt_embeds"},{anchor:"diffusers.LTX2ImageToVideoPipeline.__call__.negative_prompt_attention_mask",description:`<strong>negative_prompt_attention_mask</strong> (<code>torch.FloatTensor</code>, <em>optional</em>) &#x2014;
Pre-generated attention mask for negative text embeddings.`,name:"negative_prompt_attention_mask"},{anchor:"diffusers.LTX2ImageToVideoPipeline.__call__.decode_timestep",description:`<strong>decode_timestep</strong> (<code>float</code>, defaults to <code>0.0</code>) &#x2014;
The timestep at which generated video is decoded.`,name:"decode_timestep"},{anchor:"diffusers.LTX2ImageToVideoPipeline.__call__.decode_noise_scale",description:`<strong>decode_noise_scale</strong> (<code>float</code>, defaults to <code>None</code>) &#x2014;
The interpolation factor between random noise and denoised latents at the decode timestep.`,name:"decode_noise_scale"},{anchor:"diffusers.LTX2ImageToVideoPipeline.__call__.use_cross_timestep",description:`<strong>use_cross_timestep</strong> (<code>bool</code> <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to use the cross modality (audio is the cross modality of video, and vice versa) sigma when
calculating the cross attention modulation parameters. <code>True</code> is the LTX-2.3/2.5 behavior; <code>False</code> is
the legacy LTX-2.0 behavior.`,name:"use_cross_timestep"},{anchor:"diffusers.LTX2ImageToVideoPipeline.__call__.system_prompt",description:`<strong>system_prompt</strong> (<code>str</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
Optional system prompt to use for prompt enhancement. The system prompt will be used by the prompt
enhancer (a Gemma conditional-generation model &#x2014; the dedicated <code>prompt_enhancer</code> component if one is
configured, otherwise the main <code>text_encoder</code>) to generate an enhanced prompt from the original
<code>prompt</code> and the first <code>image</code> to condition generation. If not supplied and a dedicated
<code>prompt_enhancer</code> is configured (LTX-2.5), defaults to <code>LTX2_5_I2V_DEFAULT_SYSTEM_PROMPT</code> (from
<code>diffusers.pipelines.ltx2.utils</code>) &#x2014; see <code>enable_prompt_enhancement</code>.`,name:"system_prompt"},{anchor:"diffusers.LTX2ImageToVideoPipeline.__call__.enable_prompt_enhancement",description:`<strong>enable_prompt_enhancement</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to run prompt enhancement. Opt-in, matching the Lightricks reference pipelines. When <code>True</code> and
<code>system_prompt</code> is omitted, LTX-2.5 uses <code>LTX2_5_I2V_DEFAULT_SYSTEM_PROMPT</code> if a dedicated
<code>prompt_enhancer</code> is configured; LTX-2.0/2.3 require an explicit <code>system_prompt</code>.`,name:"enable_prompt_enhancement"},{anchor:"diffusers.LTX2ImageToVideoPipeline.__call__.prompt_max_new_tokens",description:`<strong>prompt_max_new_tokens</strong> (<code>int</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
The maximum number of new tokens to generate when performing prompt enhancement. If not supplied, uses
600 for a dedicated Gemma 4 <code>prompt_enhancer</code> (LTX-2.5) or 512 for the Gemma 3 <code>text_encoder</code> fallback
(LTX-2.0/2.3).`,name:"prompt_max_new_tokens"},{anchor:"diffusers.LTX2ImageToVideoPipeline.__call__.prompt_enhancement_kwargs",description:`<strong>prompt_enhancement_kwargs</strong> (<code>dict[str, Any]</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
Keyword arguments for the prompt enhancer&#x2019;s <code>.generate</code> call. If not supplied, always matches whichever
model is doing the enhancing: <code>do_sample=False, no_repeat_ngram_size=3</code> (greedy) when using a dedicated
<code>prompt_enhancer</code> (LTX-2.5), or <code>do_sample=True, temperature=0.7</code> for the <code>text_encoder</code> fallback
(LTX-2.0/2.3). See
<a href="https://huggingface.co/docs/transformers/main/en/main_classes/text_generation#transformers.GenerationMixin.generate" rel="nofollow">https://huggingface.co/docs/transformers/main/en/main_classes/text_generation#transformers.GenerationMixin.generate</a>
for more details.`,name:"prompt_enhancement_kwargs"},{anchor:"diffusers.LTX2ImageToVideoPipeline.__call__.prompt_enhancement_seed",description:`<strong>prompt_enhancement_seed</strong> (<code>int</code>, <em>optional</em>, defaults to <code>10</code>) &#x2014;
Random seed for any random operations during prompt enhancement.`,name:"prompt_enhancement_seed"},{anchor:"diffusers.LTX2ImageToVideoPipeline.__call__.image_crf",description:`<strong>image_crf</strong> (<code>int</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
H.264 CRF used to re-compress the conditioning <code>image</code> before VAE encode, matching the compression the
model was trained against. <code>None</code> means &#x201C;use the model default&#x201D; (33 through LTX-2.3, 18 for LTX-2.5).
Pass <code>0</code> to skip re-compression. Requires a <code>PIL.Image.Image</code> when re-compression runs.`,name:"image_crf"},{anchor:"diffusers.LTX2ImageToVideoPipeline.__call__.output_type",description:`<strong>output_type</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;pil&quot;</code>) &#x2014;
The output format of the generate image. Choose between
<a href="https://pillow.readthedocs.io/en/stable/" rel="nofollow">PIL</a>: <code>PIL.Image.Image</code> or <code>np.array</code>.`,name:"output_type"},{anchor:"diffusers.LTX2ImageToVideoPipeline.__call__.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to return a <code>~pipelines.ltx.LTX2PipelineOutput</code> instead of a plain tuple.`,name:"return_dict"},{anchor:"diffusers.LTX2ImageToVideoPipeline.__call__.attention_kwargs",description:`<strong>attention_kwargs</strong> (<code>dict</code>, <em>optional</em>) &#x2014;
A kwargs dictionary that if specified is passed along to the <code>AttentionProcessor</code> as defined under
<code>self.processor</code> in
<a href="https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/attention_processor.py" rel="nofollow">diffusers.models.attention_processor</a>.`,name:"attention_kwargs"},{anchor:"diffusers.LTX2ImageToVideoPipeline.__call__.callback_on_step_end",description:`<strong>callback_on_step_end</strong> (<code>Callable</code>, <em>optional</em>) &#x2014;
A function that calls at the end of each denoising steps during the inference. The function is called
with the following arguments: <code>callback_on_step_end(self: DiffusionPipeline, step: int, timestep: int, callback_kwargs: Dict)</code>. <code>callback_kwargs</code> will include a list of all tensors as specified by
<code>callback_on_step_end_tensor_inputs</code>.`,name:"callback_on_step_end"},{anchor:"diffusers.LTX2ImageToVideoPipeline.__call__.callback_on_step_end_tensor_inputs",description:`<strong>callback_on_step_end_tensor_inputs</strong> (<code>List</code>, <em>optional</em>) &#x2014;
The list of tensor inputs for the <code>callback_on_step_end</code> function. The tensors specified in the list
will be passed as <code>callback_kwargs</code> argument. You will only be able to include variables listed in the
<code>._callback_tensor_inputs</code> attribute of your pipeline class.`,name:"callback_on_step_end_tensor_inputs"},{anchor:"diffusers.LTX2ImageToVideoPipeline.__call__.max_sequence_length",description:`<strong>max_sequence_length</strong> (<code>int</code>, <em>optional</em>, defaults to <code>1024</code>) &#x2014;
Maximum sequence length to use with the <code>prompt</code>.`,name:"max_sequence_length"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>
<p>If <code>return_dict</code> is <code>True</code>, <code>~pipelines.ltx.LTX2PipelineOutput</code> is returned, otherwise a <code>tuple</code> is
returned where the first element is a list with the generated images.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>
<p><code>~pipelines.ltx.LTX2PipelineOutput</code> or <code>tuple</code></p>
`});var eo=e(ve,4);u(eo,{anchor:"diffusers.LTX2ImageToVideoPipeline.__call__.example",children:(d,c)=>{var i=h(),r=e(m(i),2);s(r,{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwTFRYMkltYWdlVG9WaWRlb1BpcGVsaW5lJTBBZnJvbSUyMGRpZmZ1c2Vycy51dGlscyUyMGltcG9ydCUyMGVuY29kZV92aWRlbyUwQWZyb20lMjBkaWZmdXNlcnMudXRpbHMlMjBpbXBvcnQlMjBsb2FkX2ltYWdlJTBBJTBBcGlwZSUyMCUzRCUyMExUWDJJbWFnZVRvVmlkZW9QaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTIyTGlnaHRyaWNrcyUyRkxUWC0yJTIyJTJDJTIwdG9yY2hfZHR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X2ZyYW1lcyUzRDEyMSUyQyUwQSUyMCUyMCUyMCUyMGZyYW1lX3JhdGUlM0RmcmFtZV9yYXRlJTJDJTBBJTIwJTIwJTIwJTIwbnVtX2luZmVyZW5jZV9zdGVwcyUzRDMwJTJDJTBBJTIwJTIwJTIwJTIwZ3VpZGFuY2Vfc2NhbGUlM0QzLjAlMkMlMEElMjAlMjAlMjAlMjBvdXRwdXRfdHlwZSUzRCUyMm5wJTIyJTJDJTBBJTIwJTIwJTIwJTIwcmV0dXJuX2RpY3QlM0RGYWxzZSUyQyUwQSklMEElMEFlbmNvZGVfdmlkZW8oJTBBJTIwJTIwJTIwJTIwdmlkZW8lNUIwJTVEJTJDJTBBJTIwJTIwJTIwJTIwZnBzJTNEZnJhbWVfcmF0ZSUyQyUwQSUyMCUyMCUyMCUyMGF1ZGlvJTNEYXVkaW8lNUIwJTVELmZsb2F0KCkuY3B1KCklMkMlMEElMjAlMjAlMjAlMjBhdWRpb19zYW1wbGVfcmF0ZSUzRHBpcGUudm9jb2Rlci5jb25maWcub3V0cHV0X3NhbXBsaW5nX3JhdGUlMkMlMjAlMjAlMjMlMjBzaG91bGQlMjBiZSUyMDI0MDAwJTBBJTIwJTIwJTIwJTIwb3V0cHV0X3BhdGglM0QlMjJ2aWRlby5tcDQlMjIlMkMlMEEp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> LTX2ImageToVideoPipeline
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> encode_video
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image
<span class="hljs-meta">&gt;&gt;&gt; </span>pipe = LTX2ImageToVideoPipeline.from_pretrained(<span class="hljs-string">&quot;Lightricks/LTX-2&quot;</span>, torch_dtype=torch.bfloat16)
<span class="hljs-meta">&gt;&gt;&gt; </span>pipe.enable_model_cpu_offload()
<span class="hljs-meta">&gt;&gt;&gt; </span>image = load_image(
<span class="hljs-meta">... </span> <span class="hljs-string">&quot;https://huggingface.co/datasets/a-r-r-o-w/tiny-meme-dataset-captioned/resolve/main/images/8.png&quot;</span>
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>prompt = <span class="hljs-string">&quot;A young girl stands calmly in the foreground, looking directly at the camera, as a house fire rages in the background.&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>negative_prompt = <span class="hljs-string">&quot;worst quality, inconsistent motion, blurry, jittery, distorted&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>frame_rate = <span class="hljs-number">24.0</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>video, audio = pipe(
<span class="hljs-meta">... </span> image=image,
<span class="hljs-meta">... </span> prompt=prompt,
<span class="hljs-meta">... </span> negative_prompt=negative_prompt,
<span class="hljs-meta">... </span> width=<span class="hljs-number">768</span>,
<span class="hljs-meta">... </span> height=<span class="hljs-number">512</span>,
<span class="hljs-meta">... </span> num_frames=<span class="hljs-number">121</span>,
<span class="hljs-meta">... </span> frame_rate=frame_rate,
<span class="hljs-meta">... </span> num_inference_steps=<span class="hljs-number">30</span>,
<span class="hljs-meta">... </span> guidance_scale=<span class="hljs-number">3.0</span>,
<span class="hljs-meta">... </span> output_type=<span class="hljs-string">&quot;np&quot;</span>,
<span class="hljs-meta">... </span> return_dict=<span class="hljs-literal">False</span>,
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>encode_video(
<span class="hljs-meta">... </span> video[<span class="hljs-number">0</span>],
<span class="hljs-meta">... </span> fps=frame_rate,
<span class="hljs-meta">... </span> audio=audio[<span class="hljs-number">0</span>].<span class="hljs-built_in">float</span>().cpu(),
<span class="hljs-meta">... </span> audio_sample_rate=pipe.vocoder.config.output_sampling_rate, <span class="hljs-comment"># should be 24000</span>
<span class="hljs-meta">... </span> output_path=<span class="hljs-string">&quot;video.mp4&quot;</span>,
<span class="hljs-meta">... </span>)`,lang:"py",wrap:!1}),p(d,i)},$$slots:{default:!0}}),a(_);var y=e(_,2),oo=n(y);o(oo,{name:"encode_prompt",anchor:"diffusers.LTX2ImageToVideoPipeline.encode_prompt",source:"https://github.com/huggingface/diffusers/blob/vr_14588/src/diffusers/pipelines/ltx2/pipeline_ltx2_image2video.py#L369",parameters:[{name:"prompt",val:": str | list[str]"},{name:"negative_prompt",val:": str | list[str] | None = None"},{name:"do_classifier_free_guidance",val:": bool = True"},{name:"num_videos_per_prompt",val:": int = 1"},{name:"prompt_embeds",val:": typing.Optional[torch.Tensor] = None"},{name:"negative_prompt_embeds",val:": typing.Optional[torch.Tensor] = None"},{name:"prompt_attention_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"negative_prompt_attention_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"max_sequence_length",val:": int = 1024"},{name:"scale_factor",val:": int = 8"},{name:"device",val:": typing.Optional[torch.device] = None"},{name:"dtype",val:": typing.Optional[torch.dtype] = None"}],parametersDescription:[{anchor:"diffusers.LTX2ImageToVideoPipeline.encode_prompt.prompt",description:`<strong>prompt</strong> (<code>str</code> or <code>list[str]</code>, <em>optional</em>) &#x2014;
prompt to be encoded`,name:"prompt"},{anchor:"diffusers.LTX2ImageToVideoPipeline.encode_prompt.negative_prompt",description:`<strong>negative_prompt</strong> (<code>str</code> or <code>list[str]</code>, <em>optional</em>) &#x2014;
The prompt or prompts not to guide the image generation. If not defined, one has to pass
<code>negative_prompt_embeds</code> instead. Ignored when not using guidance (i.e., ignored if <code>guidance_scale</code> is
less than <code>1</code>).`,name:"negative_prompt"},{anchor:"diffusers.LTX2ImageToVideoPipeline.encode_prompt.do_classifier_free_guidance",description:`<strong>do_classifier_free_guidance</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to use classifier free guidance or not.`,name:"do_classifier_free_guidance"},{anchor:"diffusers.LTX2ImageToVideoPipeline.encode_prompt.num_videos_per_prompt",description:`<strong>num_videos_per_prompt</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
Number of videos that should be generated per prompt. torch device to place the resulting embeddings on`,name:"num_videos_per_prompt"},{anchor:"diffusers.LTX2ImageToVideoPipeline.encode_prompt.prompt_embeds",description:`<strong>prompt_embeds</strong> (<code>torch.Tensor</code>, <em>optional</em>) &#x2014;
Pre-generated text embeddings. Can be used to easily tweak text inputs, <em>e.g.</em> prompt weighting. If not
provided, text embeddings will be generated from <code>prompt</code> input argument.`,name:"prompt_embeds"},{anchor:"diffusers.LTX2ImageToVideoPipeline.encode_prompt.negative_prompt_embeds",description:`<strong>negative_prompt_embeds</strong> (<code>torch.Tensor</code>, <em>optional</em>) &#x2014;
Pre-generated negative text embeddings. Can be used to easily tweak text inputs, <em>e.g.</em> prompt
weighting. If not provided, negative_prompt_embeds will be generated from <code>negative_prompt</code> input
argument.`,name:"negative_prompt_embeds"},{anchor:"diffusers.LTX2ImageToVideoPipeline.encode_prompt.device",description:`<strong>device</strong> &#x2014; (<code>torch.device</code>, <em>optional</em>):
torch device`,name:"device"},{anchor:"diffusers.LTX2ImageToVideoPipeline.encode_prompt.dtype",description:`<strong>dtype</strong> &#x2014; (<code>torch.dtype</code>, <em>optional</em>):
torch dtype`,name:"dtype"}]}),l(2),a(y);var Xe=e(y,2),no=n(Xe);o(no,{name:"enhance_prompt",anchor:"diffusers.LTX2ImageToVideoPipeline.enhance_prompt",source:"https://github.com/huggingface/diffusers/blob/vr_14588/src/diffusers/pipelines/ltx2/pipeline_ltx2_image2video.py#L577",parameters:[{name:"prompt",val:": str"},{name:"system_prompt",val:": str"},{name:"max_new_tokens",val:": int | None = None"},{name:"seed",val:": int = 10"},{name:"generator",val:": typing.Optional[torch.Generator] = None"},{name:"generation_kwargs",val:": dict[str, typing.Any] | None = None"},{name:"device",val:": typing.Union[torch.device, str, NoneType] = None"},{name:"image",val:": typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor], NoneType] = None"}]}),l(4),a(Xe),a(T);var Ge=e(T,2);t(Ge,{title:"LTX2ConditionPipeline",local:"diffusers.LTX2ConditionPipeline",headingTag:"h2"});var J=e(Ge,2),Ie=n(J);o(Ie,{name:"class diffusers.LTX2ConditionPipeline",anchor:"diffusers.LTX2ConditionPipeline",source:"https://github.com/huggingface/diffusers/blob/vr_14588/src/diffusers/pipelines/ltx2/pipeline_ltx2_condition.py#L263",parameters:[{name:"scheduler",val:": FlowMatchEulerDiscreteScheduler"},{name:"vae",val:": AutoencoderKLLTX2Video"},{name:"audio_vae",val:": AutoencoderKLLTX2Audio"},{name:"text_encoder",val:": transformers.models.gemma3.modeling_gemma3.Gemma3ForConditionalGeneration | transformers.models.gemma4_unified.modeling_gemma4_unified.Gemma4UnifiedForConditionalGeneration"},{name:"tokenizer",val:": GemmaTokenizer"},{name:"connectors",val:": LTX2TextConnectors"},{name:"transformer",val:": LTX2VideoTransformer3DModel"},{name:"vocoder",val:": diffusers.pipelines.ltx2.vocoder.LTX2Vocoder | diffusers.pipelines.ltx2.vocoder.LTX2VocoderWithBWE"},{name:"audio_scheduler",val:": diffusers.schedulers.scheduling_flow_match_euler_discrete.FlowMatchEulerDiscreteScheduler | None = None"},{name:"processor",val:": transformers.processing_utils.ProcessorMixin | None = None"},{name:"prompt_enhancer",val:": transformers.models.gemma4.modeling_gemma4.Gemma4ForConditionalGeneration | None = None"},{name:"duration_head",val:": diffusers.pipelines.ltx2.duration_head.LTX2DurationHead | None = None"}]});var w=e(Ie,8),Be=n(w);o(Be,{name:"__call__",anchor:"diffusers.LTX2ConditionPipeline.__call__",source:"https://github.com/huggingface/diffusers/blob/vr_14588/src/diffusers/pipelines/ltx2/pipeline_ltx2_condition.py#L1345",parameters:[{name:"conditions",val:": diffusers.pipelines.ltx2.pipeline_ltx2_condition.LTX2VideoCondition | list[diffusers.pipelines.ltx2.pipeline_ltx2_condition.LTX2VideoCondition] | None = None"},{name:"prompt",val:": str | list[str] = None"},{name:"negative_prompt",val:": str | list[str] | None = None"},{name:"height",val:": int = 512"},{name:"width",val:": int = 768"},{name:"num_frames",val:": int | None = None"},{name:"min_seconds",val:": float = 1.0"},{name:"max_seconds",val:": float = 20.0"},{name:"frame_rate",val:": float = 24.0"},{name:"num_inference_steps",val:": int = 30"},{name:"sigmas",val:": list[float] | None = None"},{name:"timesteps",val:": list[float] | None = None"},{name:"guidance_scale",val:": float = 3.0"},{name:"stg_scale",val:": float = 1.0"},{name:"modality_scale",val:": float = 3.0"},{name:"guidance_rescale",val:": float = 0.7"},{name:"audio_guidance_scale",val:": float | None = 7.0"},{name:"audio_stg_scale",val:": float | None = 1.0"},{name:"audio_modality_scale",val:": float | None = 3.0"},{name:"audio_guidance_rescale",val:": float | None = 0.7"},{name:"spatio_temporal_guidance_blocks",val:": list[int] | None = [28]"},{name:"noise_scale",val:": float | None = None"},{name:"num_videos_per_prompt",val:": int | None = 1"},{name:"generator",val:": typing.Union[torch.Generator, list[torch.Generator], NoneType] = None"},{name:"latents",val:": typing.Optional[torch.Tensor] = None"},{name:"audio_latents",val:": typing.Optional[torch.Tensor] = None"},{name:"prompt_embeds",val:": typing.Optional[torch.Tensor] = None"},{name:"prompt_attention_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"negative_prompt_embeds",val:": typing.Optional[torch.Tensor] = None"},{name:"negative_prompt_attention_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"decode_timestep",val:": float | list[float] = 0.0"},{name:"decode_noise_scale",val:": float | list[float] | None = None"},{name:"use_cross_timestep",val:": bool = True"},{name:"system_prompt",val:": str | None = None"},{name:"enable_prompt_enhancement",val:": bool = False"},{name:"prompt_max_new_tokens",val:": int | None = None"},{name:"prompt_enhancement_kwargs",val:": dict[str, typing.Any] | None = None"},{name:"prompt_enhancement_seed",val:": int = 10"},{name:"output_type",val:": str = 'pil'"},{name:"return_dict",val:": bool = True"},{name:"attention_kwargs",val:": dict[str, typing.Any] | None = None"},{name:"callback_on_step_end",val:": typing.Optional[typing.Callable[[int, int], NoneType]] = None"},{name:"callback_on_step_end_tensor_inputs",val:": list = ['latents']"},{name:"max_sequence_length",val:": int = 1024"}],parametersDescription:[{anchor:"diffusers.LTX2ConditionPipeline.__call__.conditions",description:`<strong>conditions</strong> (<code>List[LTXVideoCondition], *optional*</code>) &#x2014;
The list of frame-conditioning items for the video generation.`,name:"conditions"},{anchor:"diffusers.LTX2ConditionPipeline.__call__.prompt",description:`<strong>prompt</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>) &#x2014;
The prompt or prompts to guide the image generation. If not defined, one has to pass <code>prompt_embeds</code>.
instead.`,name:"prompt"},{anchor:"diffusers.LTX2ConditionPipeline.__call__.negative_prompt",description:`<strong>negative_prompt</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>) &#x2014;
The prompt or prompts not to guide the image generation. If not defined, one has to pass
<code>negative_prompt_embeds</code> instead. Ignored when not using guidance (<code>guidance_scale &lt; 1</code>).`,name:"negative_prompt"},{anchor:"diffusers.LTX2ConditionPipeline.__call__.height",description:`<strong>height</strong> (<code>int</code>, <em>optional</em>, defaults to <code>512</code>) &#x2014;
The height in pixels of the generated image. This is set to 480 by default for the best results.`,name:"height"},{anchor:"diffusers.LTX2ConditionPipeline.__call__.width",description:`<strong>width</strong> (<code>int</code>, <em>optional</em>, defaults to <code>768</code>) &#x2014;
The width in pixels of the generated image. This is set to 848 by default for the best results.`,name:"width"},{anchor:"diffusers.LTX2ConditionPipeline.__call__.num_frames",description:`<strong>num_frames</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The number of video frames to generate. If not supplied, defaults to an auto-predicted duration when
this pipeline has a <code>duration_head</code> component (LTX-2.5 checkpoints and later), and to <code>121</code> otherwise.
Pass an integer to set the length explicitly. Auto-predicted counts are snapped to the VAE&#x2019;s causal
temporal grid, so the realized duration is quantized (roughly 0.33s at 24 fps).`,name:"num_frames"},{anchor:"diffusers.LTX2ConditionPipeline.__call__.min_seconds",description:`<strong>min_seconds</strong> (<code>float</code>, <em>optional</em>, defaults to <code>1.0</code>) &#x2014;
Lower bound on the auto-predicted duration when <code>num_frames</code> is omitted and a <code>duration_head</code> is
present. Ignored when <code>num_frames</code> is set explicitly.`,name:"min_seconds"},{anchor:"diffusers.LTX2ConditionPipeline.__call__.max_seconds",description:`<strong>max_seconds</strong> (<code>float</code>, <em>optional</em>, defaults to <code>20.0</code>) &#x2014;
Upper bound on the auto-predicted duration when <code>num_frames</code> is omitted and a <code>duration_head</code> is
present. Ignored when <code>num_frames</code> is set explicitly. Must be strictly greater than <code>min_seconds</code>.`,name:"max_seconds"},{anchor:"diffusers.LTX2ConditionPipeline.__call__.frame_rate",description:`<strong>frame_rate</strong> (<code>float</code>, <em>optional</em>, defaults to <code>24.0</code>) &#x2014;
The frames per second (FPS) of the generated video.`,name:"frame_rate"},{anchor:"diffusers.LTX2ConditionPipeline.__call__.num_inference_steps",description:`<strong>num_inference_steps</strong> (<code>int</code>, <em>optional</em>, defaults to 30) &#x2014;
The number of denoising steps. More denoising steps usually lead to a higher quality image at the
expense of slower inference.`,name:"num_inference_steps"},{anchor:"diffusers.LTX2ConditionPipeline.__call__.sigmas",description:`<strong>sigmas</strong> (<code>List[float]</code>, <em>optional</em>) &#x2014;
Custom sigmas to use for the denoising process with schedulers which support a <code>sigmas</code> argument in
their <code>set_timesteps</code> method. If not defined, the default behavior when <code>num_inference_steps</code> is passed
will be used.`,name:"sigmas"},{anchor:"diffusers.LTX2ConditionPipeline.__call__.timesteps",description:`<strong>timesteps</strong> (<code>List[int]</code>, <em>optional</em>) &#x2014;
Custom timesteps to use for the denoising process with schedulers which support a <code>timesteps</code> argument
in their <code>set_timesteps</code> method. If not defined, the default behavior when <code>num_inference_steps</code> is
passed will be used. Must be in descending order.`,name:"timesteps"},{anchor:"diffusers.LTX2ConditionPipeline.__call__.guidance_scale",description:`<strong>guidance_scale</strong> (<code>float</code>, <em>optional</em>, defaults to <code>4.0</code>) &#x2014;
Guidance scale as defined in <a href="https://huggingface.co/papers/2207.12598" rel="nofollow">Classifier-Free Diffusion
Guidance</a>. <code>guidance_scale</code> is defined as <code>w</code> of equation 2.
of <a href="https://huggingface.co/papers/2205.11487" rel="nofollow">Imagen Paper</a>. Guidance scale is enabled by setting
<code>guidance_scale &gt; 1</code>. Higher guidance scale encourages to generate images that are closely linked to
the text <code>prompt</code>, usually at the expense of lower image quality. Used for the video modality (there is
a separate value <code>audio_guidance_scale</code> for the audio modality).`,name:"guidance_scale"},{anchor:"diffusers.LTX2ConditionPipeline.__call__.stg_scale",description:`<strong>stg_scale</strong> (<code>float</code>, <em>optional</em>, defaults to <code>0.0</code>) &#x2014;
Video guidance scale for Spatio-Temporal Guidance (STG), proposed in <a href="https://arxiv.org/abs/2411.18664" rel="nofollow">Spatiotemporal Skip Guidance for
Enhanced Video Diffusion Sampling</a>. STG uses a CFG-like estimate
where we move the sample away from a weak sample from a perturbed version of the denoising model.
Enabling STG will result in an additional denoising model forward pass; the default value of <code>0.0</code>
means that STG is disabled.`,name:"stg_scale"},{anchor:"diffusers.LTX2ConditionPipeline.__call__.modality_scale",description:`<strong>modality_scale</strong> (<code>float</code>, <em>optional</em>, defaults to <code>1.0</code>) &#x2014;
Video guidance scale for LTX-2.X modality isolation guidance, where we move the sample away from a
weaker sample generated by the denoising model withy cross-modality (audio-to-video and video-to-audio)
cross attention disabled using a CFG-like estimate. Enabling modality guidance will result in an
additional denoising model forward pass; the default value of <code>1.0</code> means that modality guidance is
disabled.`,name:"modality_scale"},{anchor:"diffusers.LTX2ConditionPipeline.__call__.guidance_rescale",description:`<strong>guidance_rescale</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
Guidance rescale factor proposed by <a href="https://huggingface.co/papers/2305.08891" rel="nofollow">Common Diffusion Noise Schedules and Sample Steps are
Flawed</a> <code>guidance_scale</code> is defined as <code>&#x3C6;</code> in equation 16. of
<a href="https://huggingface.co/papers/2305.08891" rel="nofollow">Common Diffusion Noise Schedules and Sample Steps are
Flawed</a>. Guidance rescale factor should fix overexposure when
using zero terminal SNR. Used for the video modality.`,name:"guidance_rescale"},{anchor:"diffusers.LTX2ConditionPipeline.__call__.audio_guidance_scale",description:`<strong>audio_guidance_scale</strong> (<code>float</code>, <em>optional</em> defaults to <code>None</code>) &#x2014;
Audio guidance scale for CFG with respect to the negative prompt. The CFG update rule is the same for
video and audio, but they can use different values for the guidance scale. The LTX-2.X authors suggest
that the <code>audio_guidance_scale</code> should be higher relative to the video <code>guidance_scale</code> (e.g. for
LTX-2.3 they suggest 3.0 for video and 7.0 for audio). If <code>None</code>, defaults to the video value
<code>guidance_scale</code>.`,name:"audio_guidance_scale"},{anchor:"diffusers.LTX2ConditionPipeline.__call__.audio_stg_scale",description:`<strong>audio_stg_scale</strong> (<code>float</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
Audio guidance scale for STG. As with CFG, the STG update rule is otherwise the same for video and
audio. For LTX-2.3, a value of 1.0 is suggested for both video and audio. If <code>None</code>, defaults to the
video value <code>stg_scale</code>.`,name:"audio_stg_scale"},{anchor:"diffusers.LTX2ConditionPipeline.__call__.audio_modality_scale",description:`<strong>audio_modality_scale</strong> (<code>float</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
Audio guidance scale for LTX-2.X modality isolation guidance. As with CFG, the modality guidance rule
is otherwise the same for video and audio. For LTX-2.3, a value of 3.0 is suggested for both video and
audio. If <code>None</code>, defaults to the video value <code>modality_scale</code>.`,name:"audio_modality_scale"},{anchor:"diffusers.LTX2ConditionPipeline.__call__.audio_guidance_rescale",description:`<strong>audio_guidance_rescale</strong> (<code>float</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
A separate guidance rescale factor for the audio modality. If <code>None</code>, defaults to the video value
<code>guidance_rescale</code>.`,name:"audio_guidance_rescale"},{anchor:"diffusers.LTX2ConditionPipeline.__call__.spatio_temporal_guidance_blocks",description:`<strong>spatio_temporal_guidance_blocks</strong> (<code>list[int]</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
The zero-indexed transformer block indices at which to apply STG. Must be supplied if STG is used
(<code>stg_scale</code> or <code>audio_stg_scale</code> is greater than <code>0</code>). A value of <code>[29]</code> is recommended for LTX-2.0
and <code>[28]</code> is recommended for LTX-2.3.`,name:"spatio_temporal_guidance_blocks"},{anchor:"diffusers.LTX2ConditionPipeline.__call__.noise_scale",description:`<strong>noise_scale</strong> (<code>float</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
The interpolation factor between random noise and denoised latents at each timestep. Applying noise to
the <code>latents</code> and <code>audio_latents</code> before continue denoising. If not set, will be inferred from the
sigma schedule.`,name:"noise_scale"},{anchor:"diffusers.LTX2ConditionPipeline.__call__.num_videos_per_prompt",description:`<strong>num_videos_per_prompt</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
The number of videos to generate per prompt.`,name:"num_videos_per_prompt"},{anchor:"diffusers.LTX2ConditionPipeline.__call__.generator",description:`<strong>generator</strong> (<code>torch.Generator</code> or <code>List[torch.Generator]</code>, <em>optional</em>) &#x2014;
One or a list of <a href="https://pytorch.org/docs/stable/generated/torch.Generator.html" rel="nofollow">torch generator(s)</a>
to make generation deterministic.`,name:"generator"},{anchor:"diffusers.LTX2ConditionPipeline.__call__.latents",description:`<strong>latents</strong> (<code>torch.Tensor</code>, <em>optional</em>) &#x2014;
Pre-generated noisy latents, sampled from a Gaussian distribution, to be used as inputs for video
generation. Can be used to tweak the same generation with different prompts. If not provided, a latents
tensor will be generated by sampling using the supplied random <code>generator</code>.`,name:"latents"},{anchor:"diffusers.LTX2ConditionPipeline.__call__.audio_latents",description:`<strong>audio_latents</strong> (<code>torch.Tensor</code>, <em>optional</em>) &#x2014;
Pre-generated noisy latents, sampled from a Gaussian distribution, to be used as inputs for audio
generation. Can be used to tweak the same generation with different prompts. If not provided, a latents
tensor will be generated by sampling using the supplied random <code>generator</code>.`,name:"audio_latents"},{anchor:"diffusers.LTX2ConditionPipeline.__call__.prompt_embeds",description:`<strong>prompt_embeds</strong> (<code>torch.Tensor</code>, <em>optional</em>) &#x2014;
Pre-generated text embeddings. Can be used to easily tweak text inputs, <em>e.g.</em> prompt weighting. If not
provided, text embeddings will be generated from <code>prompt</code> input argument.`,name:"prompt_embeds"},{anchor:"diffusers.LTX2ConditionPipeline.__call__.prompt_attention_mask",description:`<strong>prompt_attention_mask</strong> (<code>torch.Tensor</code>, <em>optional</em>) &#x2014;
Pre-generated attention mask for text embeddings.`,name:"prompt_attention_mask"},{anchor:"diffusers.LTX2ConditionPipeline.__call__.negative_prompt_embeds",description:`<strong>negative_prompt_embeds</strong> (<code>torch.FloatTensor</code>, <em>optional</em>) &#x2014;
Pre-generated negative text embeddings. For PixArt-Sigma this negative prompt should be &quot;&quot;. If not
provided, negative_prompt_embeds will be generated from <code>negative_prompt</code> input argument.`,name:"negative_prompt_embeds"},{anchor:"diffusers.LTX2ConditionPipeline.__call__.negative_prompt_attention_mask",description:`<strong>negative_prompt_attention_mask</strong> (<code>torch.FloatTensor</code>, <em>optional</em>) &#x2014;
Pre-generated attention mask for negative text embeddings.`,name:"negative_prompt_attention_mask"},{anchor:"diffusers.LTX2ConditionPipeline.__call__.decode_timestep",description:`<strong>decode_timestep</strong> (<code>float</code>, defaults to <code>0.0</code>) &#x2014;
The timestep at which generated video is decoded.`,name:"decode_timestep"},{anchor:"diffusers.LTX2ConditionPipeline.__call__.decode_noise_scale",description:`<strong>decode_noise_scale</strong> (<code>float</code>, defaults to <code>None</code>) &#x2014;
The interpolation factor between random noise and denoised latents at the decode timestep.`,name:"decode_noise_scale"},{anchor:"diffusers.LTX2ConditionPipeline.__call__.use_cross_timestep",description:`<strong>use_cross_timestep</strong> (<code>bool</code> <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to use the cross modality (audio is the cross modality of video, and vice versa) sigma when
calculating the cross attention modulation parameters. <code>True</code> is the LTX-2.3/2.5 behavior; <code>False</code> is
the legacy LTX-2.0 behavior.`,name:"use_cross_timestep"},{anchor:"diffusers.LTX2ConditionPipeline.__call__.system_prompt",description:`<strong>system_prompt</strong> (<code>str</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
Optional system prompt to use for prompt enhancement. The system prompt will be used by the prompt
enhancer (a Gemma conditional-generation model &#x2014; the dedicated <code>prompt_enhancer</code> component if one is
configured, otherwise the main <code>text_encoder</code>) to generate an enhanced prompt from the original
<code>prompt</code> (and a conditioning image when one is available) to condition generation. If not supplied and
a dedicated <code>prompt_enhancer</code> is configured (LTX-2.5), defaults to <code>LTX2_5_I2V_DEFAULT_SYSTEM_PROMPT</code>
when a conditioning image is available, otherwise <code>LTX2_5_T2V_DEFAULT_SYSTEM_PROMPT</code> &#x2014; see
<code>enable_prompt_enhancement</code>.`,name:"system_prompt"},{anchor:"diffusers.LTX2ConditionPipeline.__call__.enable_prompt_enhancement",description:`<strong>enable_prompt_enhancement</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to run prompt enhancement. Opt-in, matching the Lightricks reference pipelines. When <code>True</code> and
<code>system_prompt</code> is omitted, LTX-2.5 picks <code>LTX2_5_I2V_DEFAULT_SYSTEM_PROMPT</code> /
<code>LTX2_5_T2V_DEFAULT_SYSTEM_PROMPT</code> based on whether a conditioning image is available.`,name:"enable_prompt_enhancement"},{anchor:"diffusers.LTX2ConditionPipeline.__call__.prompt_max_new_tokens",description:`<strong>prompt_max_new_tokens</strong> (<code>int</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
The maximum number of new tokens to generate when performing prompt enhancement. If not supplied, uses
600 for a dedicated Gemma 4 <code>prompt_enhancer</code> (LTX-2.5) or 512 for the Gemma 3 <code>text_encoder</code> fallback
(LTX-2.0/2.3).`,name:"prompt_max_new_tokens"},{anchor:"diffusers.LTX2ConditionPipeline.__call__.prompt_enhancement_kwargs",description:`<strong>prompt_enhancement_kwargs</strong> (<code>dict[str, Any]</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
Keyword arguments for the prompt enhancer&#x2019;s <code>.generate</code> call. If not supplied, always matches whichever
model is doing the enhancing: <code>do_sample=False, no_repeat_ngram_size=5</code> (greedy) when using a dedicated
<code>prompt_enhancer</code> (LTX-2.5), or <code>do_sample=True, temperature=0.7</code> for the <code>text_encoder</code> fallback
(LTX-2.0/2.3). See
<a href="https://huggingface.co/docs/transformers/main/en/main_classes/text_generation#transformers.GenerationMixin.generate" rel="nofollow">https://huggingface.co/docs/transformers/main/en/main_classes/text_generation#transformers.GenerationMixin.generate</a>
for more details.`,name:"prompt_enhancement_kwargs"},{anchor:"diffusers.LTX2ConditionPipeline.__call__.prompt_enhancement_seed",description:`<strong>prompt_enhancement_seed</strong> (<code>int</code>, <em>optional</em>, defaults to <code>10</code>) &#x2014;
Random seed for any random operations during prompt enhancement.`,name:"prompt_enhancement_seed"},{anchor:"diffusers.LTX2ConditionPipeline.__call__.output_type",description:`<strong>output_type</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;pil&quot;</code>) &#x2014;
The output format of the generate image. Choose between
<a href="https://pillow.readthedocs.io/en/stable/" rel="nofollow">PIL</a>: <code>PIL.Image.Image</code> or <code>np.array</code>.`,name:"output_type"},{anchor:"diffusers.LTX2ConditionPipeline.__call__.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to return a <code>~pipelines.ltx.LTX2PipelineOutput</code> instead of a plain tuple.`,name:"return_dict"},{anchor:"diffusers.LTX2ConditionPipeline.__call__.attention_kwargs",description:`<strong>attention_kwargs</strong> (<code>dict</code>, <em>optional</em>) &#x2014;
A kwargs dictionary that if specified is passed along to the <code>AttentionProcessor</code> as defined under
<code>self.processor</code> in
<a href="https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/attention_processor.py" rel="nofollow">diffusers.models.attention_processor</a>.`,name:"attention_kwargs"},{anchor:"diffusers.LTX2ConditionPipeline.__call__.callback_on_step_end",description:`<strong>callback_on_step_end</strong> (<code>Callable</code>, <em>optional</em>) &#x2014;
A function that calls at the end of each denoising steps during the inference. The function is called
with the following arguments: <code>callback_on_step_end(self: DiffusionPipeline, step: int, timestep: int, callback_kwargs: Dict)</code>. <code>callback_kwargs</code> will include a list of all tensors as specified by
<code>callback_on_step_end_tensor_inputs</code>.`,name:"callback_on_step_end"},{anchor:"diffusers.LTX2ConditionPipeline.__call__.callback_on_step_end_tensor_inputs",description:`<strong>callback_on_step_end_tensor_inputs</strong> (<code>List</code>, <em>optional</em>) &#x2014;
The list of tensor inputs for the <code>callback_on_step_end</code> function. The tensors specified in the list
will be passed as <code>callback_kwargs</code> argument. You will only be able to include variables listed in the
<code>._callback_tensor_inputs</code> attribute of your pipeline class.`,name:"callback_on_step_end_tensor_inputs"},{anchor:"diffusers.LTX2ConditionPipeline.__call__.max_sequence_length",description:`<strong>max_sequence_length</strong> (<code>int</code>, <em>optional</em>, defaults to <code>1024</code>) &#x2014;
Maximum sequence length to use with the <code>prompt</code>.`,name:"max_sequence_length"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>
<p>If <code>return_dict</code> is <code>True</code>, <code>~pipelines.ltx.LTX2PipelineOutput</code> is returned, otherwise a <code>tuple</code> is
returned where the first element is a list with the generated images.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>
<p><code>~pipelines.ltx.LTX2PipelineOutput</code> or <code>tuple</code></p>
`});var ao=e(Be,4);u(ao,{anchor:"diffusers.LTX2ConditionPipeline.__call__.example",children:(d,c)=>{var i=h(),r=e(m(i),2);s(r,{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwTFRYMkNvbmRpdGlvblBpcGVsaW5lJTBBZnJvbSUyMGRpZmZ1c2Vycy51dGlscyUyMGltcG9ydCUyMGVuY29kZV92aWRlbyUwQWZyb20lMjBkaWZmdXNlcnMucGlwZWxpbmVz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Iwb3V0cHV0X3R5cGUlM0QlMjJucCUyMiUyQyUwQSUyMCUyMCUyMCUyMHJldHVybl9kaWN0JTNERmFsc2UlMkMlMEEpJTBBdmlkZW8lMjAlM0QlMjAodmlkZW8lMjAqJTIwMjU1KS5yb3VuZCgpLmFzdHlwZSglMjJ1aW50OCUyMiklMEF2aWRlbyUyMCUzRCUyMHRvcmNoLmZyb21fbnVtcHkodmlkZW8pJTBBJTBBZW5jb2RlX3ZpZGVvKCUwQSUyMCUyMCUyMCUyMHZpZGVvJTVCMCU1RCUyQyUwQSUyMCUyMCUyMCUyMGZwcyUzRGZyYW1lX3JhdGUlMkMlMEElMjAlMjAlMjAlMjBhdWRpbyUzRGF1ZGlvJTVCMCU1RC5mbG9hdCgpLmNwdSgpJTJDJTBBJTIwJTIwJTIwJTIwYXVkaW9fc2FtcGxlX3JhdGUlM0RwaXBlLnZvY29kZXIuY29uZmlnLm91dHB1dF9zYW1wbGluZ19yYXRlJTJDJTIwJTIwJTIzJTIwc2hvdWxkJTIwYmUlMjAyNDAwMCUwQSUyMCUyMCUyMCUyMG91dHB1dF9wYXRoJTNEJTIydmlkZW8ubXA0JTIyJTJDJTBBKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> LTX2ConditionPipeline
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> encode_video
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers.pipelines.ltx2.pipeline_ltx2_condition <span class="hljs-keyword">import</span> LTX2VideoCondition
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image
<span class="hljs-meta">&gt;&gt;&gt; </span>pipe = LTX2ConditionPipeline.from_pretrained(<span class="hljs-string">&quot;Lightricks/LTX-2&quot;</span>, torch_dtype=torch.bfloat16)
<span class="hljs-meta">&gt;&gt;&gt; </span>pipe.enable_model_cpu_offload()
<span class="hljs-meta">&gt;&gt;&gt; </span>first_image = load_image(
<span class="hljs-meta">... </span> <span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/flf2v_input_first_frame.png&quot;</span>
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>last_image = load_image(
<span class="hljs-meta">... </span> <span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/flf2v_input_last_frame.png&quot;</span>
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>first_cond = LTX2VideoCondition(frames=first_image, index=<span class="hljs-number">0</span>, strength=<span class="hljs-number">1.0</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>last_cond = LTX2VideoCondition(frames=last_image, index=-<span class="hljs-number">1</span>, strength=<span class="hljs-number">1.0</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>conditions = [first_cond, last_cond]
<span class="hljs-meta">&gt;&gt;&gt; </span>prompt = <span class="hljs-string">&quot;CG animation style, a small blue bird takes off from the ground, flapping its wings.&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>negative_prompt = <span class="hljs-string">&quot;worst quality, inconsistent motion, blurry, jittery, distorted, static&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>frame_rate = <span class="hljs-number">24.0</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>video = pipe(
<span class="hljs-meta">... </span> conditions=conditions,
<span class="hljs-meta">... </span> prompt=prompt,
<span class="hljs-meta">... </span> negative_prompt=negative_prompt,
<span class="hljs-meta">... </span> width=<span class="hljs-number">768</span>,
<span class="hljs-meta">... </span> height=<span class="hljs-number">512</span>,
<span class="hljs-meta">... </span> num_frames=<span class="hljs-number">121</span>,
<span class="hljs-meta">... </span> frame_rate=frame_rate,
<span class="hljs-meta">... </span> num_inference_steps=<span class="hljs-number">30</span>,
<span class="hljs-meta">... </span> guidance_scale=<span class="hljs-number">3.0</span>,
<span class="hljs-meta">... </span> output_type=<span class="hljs-string">&quot;np&quot;</span>,
<span class="hljs-meta">... </span> return_dict=<span class="hljs-literal">False</span>,
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>video = (video * <span class="hljs-number">255</span>).<span class="hljs-built_in">round</span>().astype(<span class="hljs-string">&quot;uint8&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>video = torch.from_numpy(video)
<span class="hljs-meta">&gt;&gt;&gt; </span>encode_video(
<span class="hljs-meta">... </span> video[<span class="hljs-number">0</span>],
<span class="hljs-meta">... </span> fps=frame_rate,
<span class="hljs-meta">... </span> audio=audio[<span class="hljs-number">0</span>].<span class="hljs-built_in">float</span>().cpu(),
<span class="hljs-meta">... </span> audio_sample_rate=pipe.vocoder.config.output_sampling_rate, <span class="hljs-comment"># should be 24000</span>
<span class="hljs-meta">... </span> output_path=<span class="hljs-string">&quot;video.mp4&quot;</span>,
<span class="hljs-meta">... </span>)`,lang:"py",wrap:!1}),p(d,i)},$$slots:{default:!0}}),a(w);var b=e(w,2),to=n(b);o(to,{name:"apply_first_frame_conditioning",anchor:"diffusers.LTX2ConditionPipeline.apply_first_frame_conditioning",source:"https://github.com/huggingface/diffusers/blob/vr_14588/src/diffusers/pipelines/ltx2/pipeline_ltx2_condition.py#L961",parameters:[{name:"latents",val:": Tensor"},{name:"conditioning_mask",val:": Tensor"},{name:"condition_latents",val:": list"},{name:"condition_strengths",val:": list"},{name:"condition_indices",val:": list"},{name:"latent_height",val:": int"},{name:"latent_width",val:": int"}],parametersDescription:[{anchor:"diffusers.LTX2ConditionPipeline.apply_first_frame_conditioning.latents",description:`<strong>latents</strong> (<code>torch.Tensor</code>) &#x2014;
Initial packed (patchified) latents of shape [batch_size, patch_seq_len, hidden_dim].`,name:"latents"},{anchor:"diffusers.LTX2ConditionPipeline.apply_first_frame_conditioning.conditioning_mask",description:`<strong>conditioning_mask</strong> (<code>torch.Tensor</code>) &#x2014;
Initial packed (patchified) conditioning mask of shape [batch_size, patch_seq_len, 1] with values in
[0, 1] where 0 means the denoising model output will be fully used and 1 means the condition will be
fully used.`,name:"conditioning_mask"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>
<p>Returns a 3-tuple of tensors where:</p>
<ol>
<li>The packed video latents with first-frame conditions applied.</li>
<li>The packed conditioning mask with first-frame strengths applied.</li>
<li>The clean conditioning latents at first-frame positions (zeros elsewhere).</li>
</ol>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>
<p><code>Tuple[torch.Tensor, torch.Tensor, torch.Tensor]</code></p>
`}),l(4),a(b);var U=e(b,2),so=n(U);o(so,{name:"encode_prompt",anchor:"diffusers.LTX2ConditionPipeline.encode_prompt",source:"https://github.com/huggingface/diffusers/blob/vr_14588/src/diffusers/pipelines/ltx2/pipeline_ltx2_condition.py#L416",parameters:[{name:"prompt",val:": str | list[str]"},{name:"negative_prompt",val:": str | list[str] | None = None"},{name:"do_classifier_free_guidance",val:": bool = True"},{name:"num_videos_per_prompt",val:": int = 1"},{name:"prompt_embeds",val:": typing.Optional[torch.Tensor] = None"},{name:"negative_prompt_embeds",val:": typing.Optional[torch.Tensor] = None"},{name:"prompt_attention_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"negative_prompt_attention_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"max_sequence_length",val:": int = 1024"},{name:"scale_factor",val:": int = 8"},{name:"device",val:": typing.Optional[torch.device] = None"},{name:"dtype",val:": typing.Optional[torch.dtype] = None"}],parametersDescription:[{anchor:"diffusers.LTX2ConditionPipeline.encode_prompt.prompt",description:`<strong>prompt</strong> (<code>str</code> or <code>list[str]</code>, <em>optional</em>) &#x2014;
prompt to be encoded`,name:"prompt"},{anchor:"diffusers.LTX2ConditionPipeline.encode_prompt.negative_prompt",description:`<strong>negative_prompt</strong> (<code>str</code> or <code>list[str]</code>, <em>optional</em>) &#x2014;
The prompt or prompts not to guide the image generation. If not defined, one has to pass
<code>negative_prompt_embeds</code> instead. Ignored when not using guidance (i.e., ignored if <code>guidance_scale</code> is
less than <code>1</code>).`,name:"negative_prompt"},{anchor:"diffusers.LTX2ConditionPipeline.encode_prompt.do_classifier_free_guidance",description:`<strong>do_classifier_free_guidance</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to use classifier free guidance or not.`,name:"do_classifier_free_guidance"},{anchor:"diffusers.LTX2ConditionPipeline.encode_prompt.num_videos_per_prompt",description:`<strong>num_videos_per_prompt</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
Number of videos that should be generated per prompt. torch device to place the resulting embeddings on`,name:"num_videos_per_prompt"},{anchor:"diffusers.LTX2ConditionPipeline.encode_prompt.prompt_embeds",description:`<strong>prompt_embeds</strong> (<code>torch.Tensor</code>, <em>optional</em>) &#x2014;
Pre-generated text embeddings. Can be used to easily tweak text inputs, <em>e.g.</em> prompt weighting. If not
provided, text embeddings will be generated from <code>prompt</code> input argument.`,name:"prompt_embeds"},{anchor:"diffusers.LTX2ConditionPipeline.encode_prompt.negative_prompt_embeds",description:`<strong>negative_prompt_embeds</strong> (<code>torch.Tensor</code>, <em>optional</em>) &#x2014;
Pre-generated negative text embeddings. Can be used to easily tweak text inputs, <em>e.g.</em> prompt
weighting. If not provided, negative_prompt_embeds will be generated from <code>negative_prompt</code> input
argument.`,name:"negative_prompt_embeds"},{anchor:"diffusers.LTX2ConditionPipeline.encode_prompt.device",description:`<strong>device</strong> &#x2014; (<code>torch.device</code>, <em>optional</em>):
torch device`,name:"device"},{anchor:"diffusers.LTX2ConditionPipeline.encode_prompt.dtype",description:`<strong>dtype</strong> &#x2014; (<code>torch.dtype</code>, <em>optional</em>):
torch dtype`,name:"dtype"}]}),l(2),a(U);var j=e(U,2),lo=n(j);o(lo,{name:"enhance_prompt",anchor:"diffusers.LTX2ConditionPipeline.enhance_prompt",source:"https://github.com/huggingface/diffusers/blob/vr_14588/src/diffusers/pipelines/ltx2/pipeline_ltx2_condition.py#L624",parameters:[{name:"prompt",val:": str"},{name:"system_prompt",val:": str"},{name:"max_new_tokens",val:": int | None = None"},{name:"seed",val:": int = 10"},{name:"generator",val:": typing.Optional[torch.Generator] = None"},{name:"generation_kwargs",val:": dict[str, typing.Any] | None = None"},{name:"device",val:": typing.Union[torch.device, str, NoneType] = None"},{name:"image",val:": typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor], NoneType] = None"}]}),l(4),a(j);var Z=e(j,2),io=n(Z);o(io,{name:"prepare_latents",anchor:"diffusers.LTX2ConditionPipeline.prepare_latents",source:"https://github.com/huggingface/diffusers/blob/vr_14588/src/diffusers/pipelines/ltx2/pipeline_ltx2_condition.py#L1068",parameters:[{name:"conditions",val:": diffusers.pipelines.ltx2.pipeline_ltx2_condition.LTX2VideoCondition | list[diffusers.pipelines.ltx2.pipeline_ltx2_condition.LTX2VideoCondition] | None = None"},{name:"batch_size",val:": int = 1"},{name:"num_channels_latents",val:": int = 128"},{name:"height",val:": int = 512"},{name:"width",val:": int = 768"},{name:"num_frames",val:": int = 121"},{name:"frame_rate",val:": float = 24.0"},{name:"noise_scale",val:": float = 1.0"},{name:"dtype",val:": typing.Optional[torch.dtype] = None"},{name:"device",val:": typing.Optional[torch.device] = None"},{name:"generator",val:": typing.Optional[torch.Generator] = None"},{name:"latents",val:": typing.Optional[torch.Tensor] = None"}]}),l(8),a(Z);var v=e(Z,2),ro=n(v);o(ro,{name:"preprocess_conditions",anchor:"diffusers.LTX2ConditionPipeline.preprocess_conditions",source:"https://github.com/huggingface/diffusers/blob/vr_14588/src/diffusers/pipelines/ltx2/pipeline_ltx2_condition.py#L843",parameters:[{name:"conditions",val:": diffusers.pipelines.ltx2.pipeline_ltx2_condition.LTX2VideoCondition | list[diffusers.pipelines.ltx2.pipeline_ltx2_condition.LTX2VideoCondition] | None = None"},{name:"height",val:": int = 512"},{name:"width",val:": int = 768"},{name:"num_frames",val:": int = 121"},{name:"device",val:": typing.Optional[torch.device] = None"}],parametersDescription:[{anchor:"diffusers.LTX2ConditionPipeline.preprocess_conditions.conditions",description:`<strong>conditions</strong> (<code>LTX2VideoCondition</code> or <code>List[LTX2VideoCondition]</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
A list of image/video condition instances.`,name:"conditions"},{anchor:"diffusers.LTX2ConditionPipeline.preprocess_conditions.height",description:`<strong>height</strong> (<code>int</code>, <em>optional</em>, defaults to <code>512</code>) &#x2014;
The desired height in pixels.`,name:"height"},{anchor:"diffusers.LTX2ConditionPipeline.preprocess_conditions.width",description:`<strong>width</strong> (<code>int</code>, <em>optional</em>, defaults to <code>768</code>) &#x2014;
The desired width in pixels.`,name:"width"},{anchor:"diffusers.LTX2ConditionPipeline.preprocess_conditions.num_frames",description:`<strong>num_frames</strong> (<code>int</code>, <em>optional</em>, defaults to <code>121</code>) &#x2014;
The desired number of frames in the generated video.`,name:"num_frames"},{anchor:"diffusers.LTX2ConditionPipeline.preprocess_conditions.device",description:`<strong>device</strong> (<code>torch.device</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
The device on which to put the preprocessed image/video tensors.`,name:"device"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>
<p>Returns a 4-tuple of lists of length <code>len(conditions)</code> as follows:</p>
<ol>
<li>The first list is a list of preprocessed video tensors of shape [batch_size=1, num_channels,
num_frames, height, width].</li>
<li>The second list is a list of conditioning strengths.</li>
<li>The third list is a list of latent-space indices for each condition.</li>
<li>The fourth list is a list of (trimmed) pixel-space frame counts per condition. This is needed
for keyframe coord semantics (single-pixel-frame keyframes have a clamped temporal extent).</li>
</ol>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>
<p><code>Tuple[List[torch.Tensor], List[float], List[int], List[int]]</code></p>
`}),l(2),a(v);var Ve=e(v,2),co=n(Ve);o(co,{name:"trim_conditioning_sequence",anchor:"diffusers.LTX2ConditionPipeline.trim_conditioning_sequence",source:"https://github.com/huggingface/diffusers/blob/vr_14588/src/diffusers/pipelines/ltx2/pipeline_ltx2_condition.py#L826",parameters:[{name:"start_frame",val:": int"},{name:"sequence_num_frames",val:": int"},{name:"target_num_frames",val:": int"}],parametersDescription:[{anchor:"diffusers.LTX2ConditionPipeline.trim_conditioning_sequence.start_frame",description:"<strong>start_frame</strong> (int) &#x2014; The target frame number of the first frame in the sequence.",name:"start_frame"},{anchor:"diffusers.LTX2ConditionPipeline.trim_conditioning_sequence.sequence_num_frames",description:"<strong>sequence_num_frames</strong> (int) &#x2014; The number of frames in the sequence.",name:"sequence_num_frames"},{anchor:"diffusers.LTX2ConditionPipeline.trim_conditioning_sequence.target_num_frames",description:"<strong>target_num_frames</strong> (int) &#x2014; The target number of frames in the generated video.",name:"target_num_frames"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>
<p>updated sequence length</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>
<p>int</p>
`}),l(2),a(Ve),a(J);var We=e(J,2);t(We,{title:"LTX2LatentUpsamplePipeline",local:"diffusers.LTX2LatentUpsamplePipeline",headingTag:"h2"});var X=e(We,2),Re=n(X);o(Re,{name:"class diffusers.LTX2LatentUpsamplePipeline",anchor:"diffusers.LTX2LatentUpsamplePipeline",source:"https://github.com/huggingface/diffusers/blob/vr_14588/src/diffusers/pipelines/ltx2/pipeline_ltx2_latent_upsample.py#L104",parameters:[{name:"vae",val:": AutoencoderKLLTX2Video"},{name:"latent_upsampler",val:": LTX2LatentUpsamplerModel"}]});var G=e(Re,2),ke=n(G);o(ke,{name:"__call__",anchor:"diffusers.LTX2LatentUpsamplePipeline.__call__",source:"https://github.com/huggingface/diffusers/blob/vr_14588/src/diffusers/pipelines/ltx2/pipeline_ltx2_latent_upsample.py#L264",parameters:[{name:"video",val:": list[typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor]]] | None = None"},{name:"height",val:": int = 512"},{name:"width",val:": int = 768"},{name:"num_frames",val:": int = 121"},{name:"spatial_patch_size",val:": int = 1"},{name:"temporal_patch_size",val:": int = 1"},{name:"latents",val:": typing.Optional[torch.Tensor] = None"},{name:"latents_normalized",val:": bool = False"},{name:"decode_timestep",val:": float | list[float] = 0.0"},{name:"decode_noise_scale",val:": float | list[float] | None = None"},{name:"adain_factor",val:": float = 0.0"},{name:"tone_map_compression_ratio",val:": float = 0.0"},{name:"generator",val:": typing.Union[torch.Generator, list[torch.Generator], NoneType] = None"},{name:"output_type",val:": str | None = 'pil'"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.LTX2LatentUpsamplePipeline.__call__.video",description:`<strong>video</strong> (<code>list[PipelineImageInput]</code>, <em>optional</em>) &#x2014;
The video to be upsampled (such as a LTX 2.0 first stage output). If not supplied, <code>latents</code> should be
supplied.`,name:"video"},{anchor:"diffusers.LTX2LatentUpsamplePipeline.__call__.height",description:`<strong>height</strong> (<code>int</code>, <em>optional</em>, defaults to <code>512</code>) &#x2014;
The height in pixels of the input video (not the generated video, which will have a larger resolution).`,name:"height"},{anchor:"diffusers.LTX2LatentUpsamplePipeline.__call__.width",description:`<strong>width</strong> (<code>int</code>, <em>optional</em>, defaults to <code>768</code>) &#x2014;
The width in pixels of the input video (not the generated video, which will have a larger resolution).`,name:"width"},{anchor:"diffusers.LTX2LatentUpsamplePipeline.__call__.num_frames",description:`<strong>num_frames</strong> (<code>int</code>, <em>optional</em>, defaults to <code>121</code>) &#x2014;
The number of frames in the input video.`,name:"num_frames"},{anchor:"diffusers.LTX2LatentUpsamplePipeline.__call__.spatial_patch_size",description:`<strong>spatial_patch_size</strong> (<code>int</code>, <em>optional</em>, defaults to <code>1</code>) &#x2014;
The spatial patch size of the video latents. Used when <code>latents</code> is supplied if unpacking is necessary.`,name:"spatial_patch_size"},{anchor:"diffusers.LTX2LatentUpsamplePipeline.__call__.temporal_patch_size",description:`<strong>temporal_patch_size</strong> (<code>int</code>, <em>optional</em>, defaults to <code>1</code>) &#x2014;
The temporal patch size of the video latents. Used when <code>latents</code> is supplied if unpacking is
necessary.`,name:"temporal_patch_size"},{anchor:"diffusers.LTX2LatentUpsamplePipeline.__call__.latents",description:`<strong>latents</strong> (<code>torch.Tensor</code>, <em>optional</em>) &#x2014;
Pre-generated video latents. This can be supplied in place of the <code>video</code> argument. Can either be a
patch sequence of shape <code>(batch_size, seq_len, hidden_dim)</code> or a video latent of shape <code>(batch_size, latent_channels, latent_frames, latent_height, latent_width)</code>.`,name:"latents"},{anchor:"diffusers.LTX2LatentUpsamplePipeline.__call__.latents_normalized",description:`<strong>latents_normalized</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
If <code>latents</code> are supplied, whether the <code>latents</code> are normalized using the VAE latent mean and std. If
<code>True</code>, the <code>latents</code> will be denormalized before being supplied to the latent upsampler.`,name:"latents_normalized"},{anchor:"diffusers.LTX2LatentUpsamplePipeline.__call__.decode_timestep",description:`<strong>decode_timestep</strong> (<code>float</code>, defaults to <code>0.0</code>) &#x2014;
The timestep at which generated video is decoded.`,name:"decode_timestep"},{anchor:"diffusers.LTX2LatentUpsamplePipeline.__call__.decode_noise_scale",description:`<strong>decode_noise_scale</strong> (<code>float</code>, defaults to <code>None</code>) &#x2014;
The interpolation factor between random noise and denoised latents at the decode timestep.`,name:"decode_noise_scale"},{anchor:"diffusers.LTX2LatentUpsamplePipeline.__call__.adain_factor",description:`<strong>adain_factor</strong> (<code>float</code>, <em>optional</em>, defaults to <code>0.0</code>) &#x2014;
Adaptive Instance Normalization (AdaIN) blending factor between the upsampled and original latents.
Should be in [-10.0, 10.0]; supplying 0.0 (the default) means that AdaIN is not performed.`,name:"adain_factor"},{anchor:"diffusers.LTX2LatentUpsamplePipeline.__call__.tone_map_compression_ratio",description:`<strong>tone_map_compression_ratio</strong> (<code>float</code>, <em>optional</em>, defaults to <code>0.0</code>) &#x2014;
The compression strength for tone mapping, which will reduce the dynamic range of the latent values.
This is useful for regularizing high-variance latents or for conditioning outputs during generation.
Should be in [0, 1], where 0.0 (the default) means tone mapping is not applied and 1.0 corresponds to
the full compression effect.`,name:"tone_map_compression_ratio"},{anchor:"diffusers.LTX2LatentUpsamplePipeline.__call__.generator",description:`<strong>generator</strong> (<code>torch.Generator</code> or <code>list[torch.Generator]</code>, <em>optional</em>) &#x2014;
One or a list of <a href="https://pytorch.org/docs/stable/generated/torch.Generator.html" rel="nofollow">torch generator(s)</a>
to make generation deterministic.`,name:"generator"},{anchor:"diffusers.LTX2LatentUpsamplePipeline.__call__.output_type",description:`<strong>output_type</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;pil&quot;</code>) &#x2014;
The output format of the generate image. Choose between
<a href="https://pillow.readthedocs.io/en/stable/" rel="nofollow">PIL</a>: <code>PIL.Image.Image</code> or <code>np.array</code>.`,name:"output_type"},{anchor:"diffusers.LTX2LatentUpsamplePipeline.__call__.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to return a <code>~pipelines.ltx.LTXPipelineOutput</code> instead of a plain tuple.`,name:"return_dict"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>
<p>If <code>return_dict</code> is <code>True</code>, <code>~pipelines.ltx.LTXPipelineOutput</code> is returned, otherwise a <code>tuple</code> is
returned where the first element is the upsampled video.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>
<p><code>~pipelines.ltx.LTXPipelineOutput</code> or <code>tuple</code></p>
`});var po=e(ke,4);u(po,{anchor:"diffusers.LTX2LatentUpsamplePipeline.__call__.example",children:(d,c)=>{var i=h(),r=e(m(i),2);s(r,{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwTFRYMkltYWdlVG9WaWRlb1BpcGVsaW5lJTJDJTIwTFRYMkxhdGV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JTNEbGF0ZW50X3Vwc2FtcGxlciklMEF1cHNhbXBsZV9waXBlLnZhZS5lbmFibGVfdGlsaW5nKCklMEF1cHNhbXBsZV9waXBlLnRvKGRldmljZSUzRCUyMmN1ZGElMjIlMkMlMjBkdHlwZSUzRHRvcmNoLmJmbG9hdDE2KSUwQSUwQXZpZGVvJTIwJTNEJTIwdXBzYW1wbGVfcGlwZSglMEElMjAlMjAlMjAlMjB2aWRlbyUzRHZpZGVvJTJDJTBBJTIwJTIwJTIwJTIwd2lkdGglM0Q3NjglMkMlMEElMjAlMjAlMjAlMjBoZWlnaHQlM0Q1MTIlMkMlMEElMjAlMjAlMjAlMjBvdXRwdXRfdHlwZSUzRCUyMm5wJTIyJTJDJTBBJTIwJTIwJTIwJTIwcmV0dXJuX2RpY3QlM0RGYWxzZSUyQyUwQSklNUIwJTVEJTBBJTBBZW5jb2RlX3ZpZGVvKCUwQSUyMCUyMCUyMCUyMHZpZGVvJTVCMCU1RCUyQyUwQSUyMCUyMCUyMCUyMGZwcyUzRGZyYW1lX3JhdGUlMkMlMEElMjAlMjAlMjAlMjBhdWRpbyUzRGF1ZGlvJTVCMCU1RC5mbG9hdCgpLmNwdSgpJTJDJTBBJTIwJTIwJTIwJTIwYXVkaW9fc2FtcGxlX3JhdGUlM0RwaXBlLnZvY29kZXIuY29uZmlnLm91dHB1dF9zYW1wbGluZ19yYXRlJTJDJTIwJTIwJTIzJTIwc2hvdWxkJTIwYmUlMjAyNDAwMCUwQSUyMCUyMCUyMCUyMG91dHB1dF9wYXRoJTNEJTIydmlkZW8ubXA0JTIyJTJDJTBBKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> LTX2ImageToVideoPipeline, LTX2LatentUpsamplePipeline
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> encode_video
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers.pipelines.ltx2.latent_upsampler <span class="hljs-keyword">import</span> LTX2LatentUpsamplerModel
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image
<span class="hljs-meta">&gt;&gt;&gt; </span>pipe = LTX2ImageToVideoPipeline.from_pretrained(<span class="hljs-string">&quot;Lightricks/LTX-2&quot;</span>, torch_dtype=torch.bfloat16)
<span class="hljs-meta">&gt;&gt;&gt; </span>pipe.enable_model_cpu_offload()
<span class="hljs-meta">&gt;&gt;&gt; </span>image = load_image(
<span class="hljs-meta">... </span> <span class="hljs-string">&quot;https://huggingface.co/datasets/a-r-r-o-w/tiny-meme-dataset-captioned/resolve/main/images/8.png&quot;</span>
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>prompt = <span class="hljs-string">&quot;A young girl stands calmly in the foreground, looking directly at the camera, as a house fire rages in the background.&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>negative_prompt = <span class="hljs-string">&quot;worst quality, inconsistent motion, blurry, jittery, distorted&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>frame_rate = <span class="hljs-number">24.0</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>video, audio = pipe(
<span class="hljs-meta">... </span> image=image,
<span class="hljs-meta">... </span> prompt=prompt,
<span class="hljs-meta">... </span> negative_prompt=negative_prompt,
<span class="hljs-meta">... </span> width=<span class="hljs-number">768</span>,
<span class="hljs-meta">... </span> height=<span class="hljs-number">512</span>,
<span class="hljs-meta">... </span> num_frames=<span class="hljs-number">121</span>,
<span class="hljs-meta">... </span> frame_rate=frame_rate,
<span class="hljs-meta">... </span> num_inference_steps=<span class="hljs-number">40</span>,
<span class="hljs-meta">... </span> guidance_scale=<span class="hljs-number">4.0</span>,
<span class="hljs-meta">... </span> output_type=<span class="hljs-string">&quot;pil&quot;</span>,
<span class="hljs-meta">... </span> return_dict=<span class="hljs-literal">False</span>,
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>latent_upsampler = LTX2LatentUpsamplerModel.from_pretrained(
<span class="hljs-meta">... </span> <span class="hljs-string">&quot;Lightricks/LTX-2&quot;</span>, subfolder=<span class="hljs-string">&quot;latent_upsampler&quot;</span>, torch_dtype=torch.bfloat16
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>upsample_pipe = LTX2LatentUpsamplePipeline(vae=pipe.vae, latent_upsampler=latent_upsampler)
<span class="hljs-meta">&gt;&gt;&gt; </span>upsample_pipe.vae.enable_tiling()
<span class="hljs-meta">&gt;&gt;&gt; </span>upsample_pipe.to(device=<span class="hljs-string">&quot;cuda&quot;</span>, dtype=torch.bfloat16)
<span class="hljs-meta">&gt;&gt;&gt; </span>video = upsample_pipe(
<span class="hljs-meta">... </span> video=video,
<span class="hljs-meta">... </span> width=<span class="hljs-number">768</span>,
<span class="hljs-meta">... </span> height=<span class="hljs-number">512</span>,
<span class="hljs-meta">... </span> output_type=<span class="hljs-string">&quot;np&quot;</span>,
<span class="hljs-meta">... </span> return_dict=<span class="hljs-literal">False</span>,
<span class="hljs-meta">... </span>)[<span class="hljs-number">0</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>encode_video(
<span class="hljs-meta">... </span> video[<span class="hljs-number">0</span>],
<span class="hljs-meta">... </span> fps=frame_rate,
<span class="hljs-meta">... </span> audio=audio[<span class="hljs-number">0</span>].<span class="hljs-built_in">float</span>().cpu(),
<span class="hljs-meta">... </span> audio_sample_rate=pipe.vocoder.config.output_sampling_rate, <span class="hljs-comment"># should be 24000</span>
<span class="hljs-meta">... </span> output_path=<span class="hljs-string">&quot;video.mp4&quot;</span>,
<span class="hljs-meta">... </span>)`,lang:"py",wrap:!1}),p(d,i)},$$slots:{default:!0}}),a(G);var I=e(G,2),mo=n(I);o(mo,{name:"adain_filter_latent",anchor:"diffusers.LTX2LatentUpsamplePipeline.adain_filter_latent",source:"https://github.com/huggingface/diffusers/blob/vr_14588/src/diffusers/pipelines/ltx2/pipeline_ltx2_latent_upsample.py#L168",parameters:[{name:"latents",val:": Tensor"},{name:"reference_latents",val:": Tensor"},{name:"factor",val:": float = 1.0"}],parametersDescription:[{anchor:"diffusers.LTX2LatentUpsamplePipeline.adain_filter_latent.latent",description:`<strong>latent</strong> (<code>torch.Tensor</code>) &#x2014;
Input latents to normalize`,name:"latent"},{anchor:"diffusers.LTX2LatentUpsamplePipeline.adain_filter_latent.reference_latents",description:`<strong>reference_latents</strong> (<code>torch.Tensor</code>) &#x2014;
The reference latents providing style statistics.`,name:"reference_latents"},{anchor:"diffusers.LTX2LatentUpsamplePipeline.adain_filter_latent.factor",description:`<strong>factor</strong> (<code>float</code>) &#x2014;
Blending factor between original and transformed latent. Range: -10.0 to 10.0, Default: 1.0`,name:"factor"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>
<p>The transformed latent tensor</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>
<p>torch.Tensor</p>
`}),l(2),a(I);var Ce=e(I,2),uo=n(Ce);o(uo,{name:"tone_map_latents",anchor:"diffusers.LTX2LatentUpsamplePipeline.tone_map_latents",source:"https://github.com/huggingface/diffusers/blob/vr_14588/src/diffusers/pipelines/ltx2/pipeline_ltx2_latent_upsample.py#L196",parameters:[{name:"latents",val:": Tensor"},{name:"compression",val:": float"}],parametersDescription:[{anchor:"diffusers.LTX2LatentUpsamplePipeline.tone_map_latents.latents",description:`<strong>latents</strong> &#x2014; torch.Tensor
Input latent tensor with arbitrary shape. Expected to be roughly in [-1, 1] or [0, 1] range.`,name:"latents"},{anchor:"diffusers.LTX2LatentUpsamplePipeline.tone_map_latents.compression",description:`<strong>compression</strong> &#x2014; float
Compression strength in the range [0, 1].
<ul>
<li>0.0: No tone-mapping (identity transform)</li>
<li>1.0: Full compression effect</li>
</ul>`,name:"compression"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>
<p>torch.Tensor
The tone-mapped latent tensor of the same shape as input.</p>
`}),l(4),a(Ce),a(X);var xe=e(X,2);t(xe,{title:"LTX2VideoDiffusionDecodePipeline",local:"diffusers.LTX2VideoDiffusionDecodePipeline",headingTag:"h2"});var B=e(xe,2),Ne=n(B);o(Ne,{name:"class diffusers.LTX2VideoDiffusionDecodePipeline",anchor:"diffusers.LTX2VideoDiffusionDecodePipeline",source:"https://github.com/huggingface/diffusers/blob/vr_14588/src/diffusers/pipelines/ltx2/pipeline_ltx2_diffusion_decode.py#L27",parameters:[{name:"diffusion_decoder",val:": LTX2VideoDiffusionDecoderModel"},{name:"scheduler",val:""},{name:"vae",val:": AutoencoderKLLTX2Video = None"}],parametersDescription:[{anchor:"diffusers.LTX2VideoDiffusionDecodePipeline.diffusion_decoder",description:`<strong>diffusion_decoder</strong> (<a href="/docs/diffusers/pr_14588/en/api/models/ltx2_diffusion_decoder#diffusers.LTX2VideoDiffusionDecoderModel">LTX2VideoDiffusionDecoderModel</a>) &#x2014;
The diffusion video decoder.`,name:"diffusion_decoder"},{anchor:"diffusers.LTX2VideoDiffusionDecodePipeline.scheduler",description:`<strong>scheduler</strong> (<a href="/docs/diffusers/pr_14588/en/api/schedulers/flow_match_euler_discrete#diffusers.FlowMatchEulerDiscreteScheduler">FlowMatchEulerDiscreteScheduler</a>) &#x2014;
Scheduler driving the decoder&#x2019;s denoising steps.`,name:"scheduler"},{anchor:"diffusers.LTX2VideoDiffusionDecodePipeline.vae",description:`<strong>vae</strong> (<a href="/docs/diffusers/pr_14588/en/api/models/autoencoderkl_ltx_2#diffusers.AutoencoderKLLTX2Video">AutoencoderKLLTX2Video</a>, <em>optional</em>) &#x2014;
Only consulted for the latent statistics used to denormalize. When omitted the pipeline falls back to the
LTX-2 defaults, so a decode-only workflow does not have to load a second autoencoder.`,name:"vae"}]});var Le=e(Ne,6),ho=n(Le);o(ho,{name:"__call__",anchor:"diffusers.LTX2VideoDiffusionDecodePipeline.__call__",source:"https://github.com/huggingface/diffusers/blob/vr_14588/src/diffusers/pipelines/ltx2/pipeline_ltx2_diffusion_decode.py#L79",parameters:[{name:"latents",val:": Tensor"},{name:"generator",val:": typing.Union[torch.Generator, list[torch.Generator], NoneType] = None"},{name:"output_type",val:": str = 'pil'"},{name:"return_dict",val:": bool = True"},{name:"denormalize",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.LTX2VideoDiffusionDecodePipeline.__call__.latents",description:`<strong>latents</strong> (<code>torch.Tensor</code>) &#x2014;
Latents of shape <code>(B, C, F, H, W)</code>. Note that an LTX-2 pipeline run with <code>output_type=&quot;latent&quot;</code> returns
latents that are <em>already</em> denormalized, so pass <code>denormalize=False</code> for those.`,name:"latents"},{anchor:"diffusers.LTX2VideoDiffusionDecodePipeline.__call__.generator",description:`<strong>generator</strong> (<code>torch.Generator</code>, <em>optional</em>) &#x2014;
The decoder samples the noise it denoises, so pass a generator to make decoding reproducible.`,name:"generator"},{anchor:"diffusers.LTX2VideoDiffusionDecodePipeline.__call__.output_type",description:`<strong>output_type</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;pil&quot;</code>) &#x2014;
The output format of the decoded video. Choose between <code>&quot;pil&quot;</code>, <code>&quot;np&quot;</code>, <code>&quot;pt&quot;</code> and <code>&quot;latent&quot;</code>.`,name:"output_type"},{anchor:"diffusers.LTX2VideoDiffusionDecodePipeline.__call__.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to return a <code>LTX2VideoDecodeOutput</code> instead of a plain tuple.`,name:"return_dict"},{anchor:"diffusers.LTX2VideoDiffusionDecodePipeline.__call__.denormalize",description:`<strong>denormalize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to apply the latent statistics before decoding. Set to <code>False</code> if the latents are already
denormalized.`,name:"denormalize"}],returnType:`<script context="module">export const metadata = 'undefined';<\/script>
<p><code>LTX2VideoDecodeOutput</code> or <code>tuple</code></p>
`}),a(Le),a(B);var Ee=e(B,2);t(Ee,{title:"LTX2DurationHead",local:"diffusers.pipelines.ltx2.LTX2DurationHead",headingTag:"h2"});var V=e(Ee,2),Fe=n(V);o(Fe,{name:"class diffusers.pipelines.ltx2.LTX2DurationHead",anchor:"diffusers.pipelines.ltx2.LTX2DurationHead",source:"https://github.com/huggingface/diffusers/blob/vr_14588/src/diffusers/pipelines/ltx2/duration_head.py#L81",parameters:[{name:"video_cross_attention_dim",val:": int = 4096"},{name:"audio_cross_attention_dim",val:": int = 2048"},{name:"pooler_hidden_dim",val:": int = 256"},{name:"num_queries",val:": int = 1"},{name:"num_pooler_heads",val:": int = 4"},{name:"mlp_hidden_dim",val:": int = 256"}],parametersDescription:[{anchor:"diffusers.pipelines.ltx2.LTX2DurationHead.video_cross_attention_dim",description:`<strong>video_cross_attention_dim</strong> (<code>int</code>, defaults to <code>4096</code>) &#x2014;
Width of the video connector output.`,name:"video_cross_attention_dim"},{anchor:"diffusers.pipelines.ltx2.LTX2DurationHead.audio_cross_attention_dim",description:`<strong>audio_cross_attention_dim</strong> (<code>int</code>, defaults to <code>2048</code>) &#x2014;
Width of the audio connector output.`,name:"audio_cross_attention_dim"},{anchor:"diffusers.pipelines.ltx2.LTX2DurationHead.pooler_hidden_dim",description:`<strong>pooler_hidden_dim</strong> (<code>int</code>, defaults to <code>256</code>) &#x2014;
Shared hidden dimension both modalities are projected into.`,name:"pooler_hidden_dim"},{anchor:"diffusers.pipelines.ltx2.LTX2DurationHead.num_queries",description:`<strong>num_queries</strong> (<code>int</code>, defaults to <code>1</code>) &#x2014;
Number of learnable pooling queries.`,name:"num_queries"},{anchor:"diffusers.pipelines.ltx2.LTX2DurationHead.num_pooler_heads",description:`<strong>num_pooler_heads</strong> (<code>int</code>, defaults to <code>4</code>) &#x2014;
Attention heads used by the pooler.`,name:"num_pooler_heads"},{anchor:"diffusers.pipelines.ltx2.LTX2DurationHead.mlp_hidden_dim",description:`<strong>mlp_hidden_dim</strong> (<code>int</code>, defaults to <code>256</code>) &#x2014;
Hidden width of the output MLP. Named with a <code>_dim</code> suffix to avoid colliding with the <code>mlp_hidden</code>
submodule, which <code>ConfigMixin.__getattr__</code> would otherwise shadow with this config value.`,name:"mlp_hidden_dim"}]});var W=e(Fe,8),Mo=n(W);o(Mo,{name:"forward",anchor:"diffusers.pipelines.ltx2.LTX2DurationHead.forward",source:"https://github.com/huggingface/diffusers/blob/vr_14588/src/diffusers/pipelines/ltx2/duration_head.py#L134",parameters:[{name:"video_tokens",val:": typing.Optional[torch.Tensor] = None"},{name:"audio_tokens",val:": typing.Optional[torch.Tensor] = None"}],parametersDescription:[{anchor:"diffusers.pipelines.ltx2.LTX2DurationHead.forward.video_tokens",description:`<strong>video_tokens</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, seq_len, video_cross_attention_dim)</code>, <em>optional</em>) &#x2014;
Video connector output.`,name:"video_tokens"},{anchor:"diffusers.pipelines.ltx2.LTX2DurationHead.forward.audio_tokens",description:`<strong>audio_tokens</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, seq_len, audio_cross_attention_dim)</code>, <em>optional</em>) &#x2014;
Audio connector output.`,name:"audio_tokens"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>
<p>the predicted duration in seconds.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>
<p><code>torch.Tensor</code> of shape <code>(batch_size,)</code></p>
`}),a(W);var Qe=e(W,2),fo=n(Qe);o(fo,{name:"predict_num_frames",anchor:"diffusers.pipelines.ltx2.LTX2DurationHead.predict_num_frames",source:"https://github.com/huggingface/diffusers/blob/vr_14588/src/diffusers/pipelines/ltx2/duration_head.py#L172",parameters:[{name:"video_tokens",val:": typing.Optional[torch.Tensor] = None"},{name:"audio_tokens",val:": typing.Optional[torch.Tensor] = None"},{name:"frame_rate",val:": float"},{name:"temporal_compression_ratio",val:": int"},{name:"min_seconds",val:": float = 1.0"},{name:"max_seconds",val:": float = 20.0"}],parametersDescription:[{anchor:"diffusers.pipelines.ltx2.LTX2DurationHead.predict_num_frames.video_tokens",description:`<strong>video_tokens</strong> (<code>torch.Tensor</code>, <em>optional</em>) &#x2014;
Video connector output for a single prompt.`,name:"video_tokens"},{anchor:"diffusers.pipelines.ltx2.LTX2DurationHead.predict_num_frames.audio_tokens",description:`<strong>audio_tokens</strong> (<code>torch.Tensor</code>, <em>optional</em>) &#x2014;
Audio connector output for a single prompt.`,name:"audio_tokens"},{anchor:"diffusers.pipelines.ltx2.LTX2DurationHead.predict_num_frames.frame_rate",description:`<strong>frame_rate</strong> (<code>float</code>) &#x2014;
Frames per second used to convert the predicted duration into a frame count.`,name:"frame_rate"},{anchor:"diffusers.pipelines.ltx2.LTX2DurationHead.predict_num_frames.temporal_compression_ratio",description:`<strong>temporal_compression_ratio</strong> (<code>int</code>) &#x2014;
The VAE&#x2019;s temporal compression ratio, which defines the frame grid.`,name:"temporal_compression_ratio"},{anchor:"diffusers.pipelines.ltx2.LTX2DurationHead.predict_num_frames.min_seconds",description:`<strong>min_seconds</strong> (<code>float</code>, defaults to <code>1.0</code>) &#x2014;
Lower bound on the prediction.`,name:"min_seconds"},{anchor:"diffusers.pipelines.ltx2.LTX2DurationHead.predict_num_frames.max_seconds",description:`<strong>max_seconds</strong> (<code>float</code>, defaults to <code>20.0</code>) &#x2014;
Upper bound on the prediction.`,name:"max_seconds"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>
<p>a frame count lying on the VAE’s temporal grid.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>
<p><code>int</code></p>
`}),l(6),a(Qe),a(V);var Ye=e(V,2);t(Ye,{title:"LTX2PipelineOutput",local:"diffusers.pipelines.ltx2.pipeline_output.LTX2PipelineOutput",headingTag:"h2"});var R=e(Ye,2),go=n(R);o(go,{name:"class diffusers.pipelines.ltx2.pipeline_output.LTX2PipelineOutput",anchor:"diffusers.pipelines.ltx2.pipeline_output.LTX2PipelineOutput",source:"https://github.com/huggingface/diffusers/blob/vr_14588/src/diffusers/pipelines/ltx2/pipeline_output.py#L9",parameters:[{name:"frames",val:": Tensor"},{name:"audio",val:": Tensor"}],parametersDescription:[{anchor:"diffusers.pipelines.ltx2.pipeline_output.LTX2PipelineOutput.frames",description:`<strong>frames</strong> (<code>torch.Tensor</code>, <code>np.ndarray</code>, or list[list[PIL.Image.Image]]) &#x2014;
List of video outputs - It can be a nested list of length <code>batch_size,</code> with each sub-list containing
denoised PIL image sequences of length <code>num_frames.</code> It can also be a NumPy array or Torch tensor of shape
<code>(batch_size, num_frames, channels, height, width)</code>.`,name:"frames"},{anchor:"diffusers.pipelines.ltx2.pipeline_output.LTX2PipelineOutput.audio",description:`<strong>audio</strong> (<code>torch.Tensor</code>, <code>np.ndarray</code>) &#x2014;
TODO`,name:"audio"}]}),l(2),a(R);var Se=e(R,2);t(Se,{title:"LTX2ModularPipeline",local:"diffusers.LTX2ModularPipeline",headingTag:"h2"});var k=e(Se,2),To=n(k);o(To,{name:"class diffusers.LTX2ModularPipeline",anchor:"diffusers.LTX2ModularPipeline",source:"https://github.com/huggingface/diffusers/blob/vr_14588/src/diffusers/modular_pipelines/ltx2/modular_pipeline.py#L26",parameters:[{name:"blocks",val:": diffusers.modular_pipelines.modular_pipeline.ModularPipelineBlocks | None = None"},{name:"pretrained_model_name_or_path",val:": str | os.PathLike | None = None"},{name:"components_manager",val:": diffusers.modular_pipelines.components_manager.ComponentsManager | None = None"},{name:"collection",val:": str | None = None"},{name:"workflow",val:": str | None = None"},{name:"modular_config_dict",val:": dict[str, typing.Any] | None = None"},{name:"config_dict",val:": dict[str, typing.Any] | None = None"},{name:"**kwargs",val:""}]}),l(2),a(k);var Ae=e(k,2);t(Ae,{title:"LTX2AutoBlocks",local:"diffusers.LTX2AutoBlocks",headingTag:"h2"});var C=e(Ae,2),_o=n(C);o(_o,{name:"class diffusers.LTX2AutoBlocks",anchor:"diffusers.LTX2AutoBlocks",source:"https://github.com/huggingface/diffusers/blob/vr_14588/src/diffusers/modular_pipelines/ltx2/modular_blocks_ltx2.py#L1721",parameters:[]}),l(12),a(C);var ze=e(C,2);t(ze,{title:"LTX25ModularPipeline",local:"diffusers.LTX25ModularPipeline",headingTag:"h2"});var x=e(ze,2),yo=n(x);o(yo,{name:"class diffusers.LTX25ModularPipeline",anchor:"diffusers.LTX25ModularPipeline",source:"https://github.com/huggingface/diffusers/blob/vr_14588/src/diffusers/modular_pipelines/ltx2/modular_pipeline.py#L125",parameters:[{name:"blocks",val:": diffusers.modular_pipelines.modular_pipeline.ModularPipelineBlocks | None = None"},{name:"pretrained_model_name_or_path",val:": str | os.PathLike | None = None"},{name:"components_manager",val:": diffusers.modular_pipelines.components_manager.ComponentsManager | None = None"},{name:"collection",val:": str | None = None"},{name:"workflow",val:": str | None = None"},{name:"modular_config_dict",val:": dict[str, typing.Any] | None = None"},{name:"config_dict",val:": dict[str, typing.Any] | None = None"},{name:"**kwargs",val:""}]}),l(4),a(x);var He=e(x,2);t(He,{title:"LTX25AutoBlocks",local:"diffusers.LTX25AutoBlocks",headingTag:"h2"});var N=e(He,2),Jo=n(N);o(Jo,{name:"class diffusers.LTX25AutoBlocks",anchor:"diffusers.LTX25AutoBlocks",source:"https://github.com/huggingface/diffusers/blob/vr_14588/src/diffusers/modular_pipelines/ltx2/modular_blocks_ltx25.py#L215",parameters:[]}),l(12),a(N);var De=e(N,2);t(De,{title:"LTX2Guidance",local:"diffusers.modular_pipelines.ltx2.guider.LTX2Guidance",headingTag:"h2"});var L=e(De,2),wo=n(L);o(wo,{name:"class diffusers.modular_pipelines.ltx2.guider.LTX2Guidance",anchor:"diffusers.modular_pipelines.ltx2.guider.LTX2Guidance",source:"https://github.com/huggingface/diffusers/blob/vr_14588/src/diffusers/modular_pipelines/ltx2/guider.py#L44",parameters:[{name:"guidance_scale",val:": float = 1.0"},{name:"stg_scale",val:": float = 0.0"},{name:"modality_scale",val:": float = 1.0"},{name:"guidance_rescale",val:": float = 0.0"},{name:"spatio_temporal_guidance_blocks",val:": list[int] | None = None"},{name:"start",val:": float = 0.0"},{name:"stop",val:": float = 1.0"},{name:"enabled",val:": bool = True"}]}),l(6),a(L);var bo=e(L,2);Zo(bo,{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/pipelines/ltx2.md"}),l(2),p(Pe,F),Io()}export{No as component};

Xet Storage Details

Size:
302 kB
·
Xet hash:
46ef009f8381e799361137dbf3aa72c1023eab2ec671d3f595dc8aed62914e9b

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.