#
# Berlisensi di bawah Apache License, Versi 2.0 ("Lisensi");
# Anda mungkin tidak dapat menggunakan file ini kecuali sesuai dengan Lisensi.
# Anda dapat memperoleh salinan Lisensi di
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Kecuali diwajibkan oleh hukum yang berlaku atau disepakati secara tertulis, perangkat lunak
# distribusikan di bawah Lisensi berdasarkan basis "SEBAGAIMANA ADANYA",
# TANPA JAMINAN ATAU SYARAT DALAM BENTUK APAPUN, baik yang dinyatakan maupun yang tersirat.
# Lihat Lisensi untuk bahasa tertentu yang mengatur izin dan
# batasan di bawah Lisensi. -->

  
    
      
    
    
  

# LTX-Video

[LTX-Video](https://huggingface.co/Lightricks/LTX-Video) adalah diffusion transformer yang dirancang untuk menghasilkan video resolusi tinggi secara cepat dan real-time dari teks dan gambar. Fitur utama LTX-Video adalah Video-VAE. Video-VAE memiliki rasio kompresi pixel ke latent yang lebih tinggi (1:192) yang memungkinkan pemrosesan data video yang lebih efisien dan kecepatan generasi yang lebih cepat. Untuk mendukung dan mencegah hilangnya detail yang lebih halus selama generasi, decoder Video-VAE melakukan konversi latent ke pixel *dan* langkah denoising terakhir.

Anda dapat menemukan semua checkpoint asli LTX-Video di bawah organisasi [Lightricks](https://huggingface.co/Lightricks).

> [!TIP]
> Klik pada model LTX-Video di bilah sisi kanan untuk melihat lebih banyak contoh tugas generasi video lainnya.

Contoh di bawah ini menunjukkan cara menghasilkan video yang dioptimalkan untuk memori atau kecepatan inferensi.

Lihat panduan [Reduce memory usage](../../optimization/memory) untuk detail lebih lanjut tentang berbagai teknik penghematan memori.

Model LTX-Video di bawah ini membutuhkan sekitar 10GB VRAM.

```py
import torch
from diffusers import LTXPipeline, AutoModel
from diffusers.hooks import apply_group_offloading
from diffusers.utils import export_to_video

# fp8 layerwise weight-casting
transformer = AutoModel.from_pretrained(
    "Lightricks/LTX-Video",
    subfolder="transformer",
    dtype=torch.bfloat16
)
transformer.enable_layerwise_casting(
    storage_dtype=torch.float8_e4m3fn, compute_dtype=torch.bfloat16
)

pipeline = LTXPipeline.from_pretrained("Lightricks/LTX-Video", transformer=transformer, dtype=torch.bfloat16)

# group-offloading
onload_device = torch.device("cuda")
offload_device = torch.device("cpu")
pipeline.transformer.enable_group_offload(onload_device=onload_device, offload_device=offload_device, offload_type="leaf_level", use_stream=True)
apply_group_offloading(pipeline.text_encoder, onload_device=onload_device, offload_type="block_level", num_blocks_per_group=2)
apply_group_offloading(pipeline.vae, onload_device=onload_device, offload_type="leaf_level")

prompt = """
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'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
"""
negative_prompt = "worst quality, inconsistent motion, blurry, jittery, distorted"

video = pipeline(
    prompt=prompt,
    negative_prompt=negative_prompt,
    width=768,
    height=512,
    num_frames=161,
    decode_timestep=0.03,
    decode_noise_scale=0.025,
    num_inference_steps=50,
).frames[0]
export_to_video(video, "output.mp4", fps=24)
```

[Compilation](../../optimization/fp16#torchcompile) lambat pada pemanggilan pertama, tetapi pemanggilan ke pipeline berikutnya lebih cepat. [Caching](../../optimization/cache) juga dapat mempercepat inferensi dengan menyimpan dan menggunakan kembali output antara.

```py
import torch
from diffusers import LTXPipeline
from diffusers.utils import export_to_video

pipeline = LTXPipeline.from_pretrained(
    "Lightricks/LTX-Video", dtype=torch.bfloat16
)

# torch.compile
pipeline.transformer.to(memory_format=torch.channels_last)
pipeline.transformer = torch.compile(
    pipeline.transformer, mode="max-autotune", fullgraph=True
)

prompt = """
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'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
"""
negative_prompt = "worst quality, inconsistent motion, blurry, jittery, distorted"

video = pipeline(
    prompt=prompt,
    negative_prompt=negative_prompt,
    width=768,
    height=512,
    num_frames=161,
    decode_timestep=0.03,
    decode_noise_scale=0.025,
    num_inference_steps=50,
).frames[0]
export_to_video(video, "output.mp4", fps=24)
```

## Catatan

- Lihat pengaturan yang direkomendasikan berikut untuk generasi dari repositori [LTX-Video](https://github.com/Lightricks/LTX-Video).

  - dtype yang direkomendasikan untuk transformer, VAE, dan text encoder adalah `torch.bfloat16`. VAE dan text encoder juga dapat menggunakan `torch.float32` atau `torch.float16`.
  - Untuk varian LTX-Video yang menggunakan guidance-distilled, atur `guidance_scale` ke `1.0`. Nilai `guidance_scale` untuk model lain sebaiknya diatur lebih tinggi, seperti `5.0`, untuk kualitas generasi yang baik.
  - Untuk varian VAE yang sadar timestep (LTX-Video 0.9.1 dan di atasnya), atur `decode_timestep` ke `0.05` dan `image_cond_noise_scale` ke `0.025`.
  - Untuk varian yang mendukung interpolasi antara beberapa gambar dan video kondisional (LTX-Video 0.9.5 ke atas), gunakan gambar dan video yang serupa untuk hasil terbaik. Penyimpangan dari input kondisional dapat menyebabkan transisi mendadak dalam video yang dihasilkan.

- LTX-Video 0.9.7 mencakup spatial latent upscaler dan transformer dengan 13B parameter. Selama inferensi, video beresolusi rendah pertama kali dihasilkan dengan cepat, kemudian di-upscale dan disempurnakan.

  
  Tampilkan kode contoh

  ```py
  import torch
  from diffusers import LTXConditionPipeline, LTXLatentUpsamplePipeline
  from diffusers.pipelines.ltx.pipeline_ltx_condition import LTXVideoCondition
  from diffusers.utils import export_to_video, load_video

  pipeline = LTXConditionPipeline.from_pretrained("Lightricks/LTX-Video-0.9.7-dev", dtype=torch.bfloat16)
  pipeline_upsample = LTXLatentUpsamplePipeline.from_pretrained("Lightricks/ltxv-spatial-upscaler-0.9.7", vae=pipeline.vae, dtype=torch.bfloat16)
  pipeline.to("cuda")  # or "mps", "xpu", "cpu"
  pipe_upsample.to("cuda")
  pipeline.vae.enable_tiling()

  def round_to_nearest_resolution_acceptable_by_vae(height, width):
      height = height - (height % pipeline.vae_temporal_compression_ratio)
      width = width - (width % pipeline.vae_temporal_compression_ratio)
      return height, width

  video = load_video(
      "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cosmos/cosmos-video2world-input-vid.mp4"
  )[:21]  # only use the first 21 frames as conditioning
  condition1 = LTXVideoCondition(video=video, frame_index=0)

  prompt = """
  The video depicts a winding mountain road covered in snow, with a single vehicle 
  traveling along it. The road is flanked by steep, rocky cliffs and sparse vegetation. 
  The landscape is characterized by rugged terrain and a river visible in the distance. 
  The scene captures the solitude and beauty of a winter drive through a mountainous region.
  """
  negative_prompt = "worst quality, inconsistent motion, blurry, jittery, distorted"
  expected_height, expected_width = 768, 1152
  downscale_factor = 2 / 3
  num_frames = 161

  # 1. Generate video at smaller resolution
  # Text-only conditioning is also supported without the need to pass `conditions`
  downscaled_height, downscaled_width = int(expected_height * downscale_factor), int(expected_width * downscale_factor)
  downscaled_height, downscaled_width = round_to_nearest_resolution_acceptable_by_vae(downscaled_height, downscaled_width)
  latents = pipeline(
      conditions=[condition1],
      prompt=prompt,
      negative_prompt=negative_prompt,
      width=downscaled_width,
      height=downscaled_height,
      num_frames=num_frames,
      num_inference_steps=30,
      decode_timestep=0.05,
      decode_noise_scale=0.025,
      image_cond_noise_scale=0.0,
      guidance_scale=5.0,
      guidance_rescale=0.7,
      generator=torch.Generator().manual_seed(0),
      output_type="latent",
  ).frames

  # 2. Upscale generated video using latent upsampler with fewer inference steps
  # The available latent upsampler upscales the height/width by 2x
  upscaled_height, upscaled_width = downscaled_height * 2, downscaled_width * 2
  upscaled_latents = pipe_upsample(
      latents=latents,
      output_type="latent"
  ).frames

  # 3. Denoise the upscaled video with few steps to improve texture (optional, but recommended)
  video = pipeline(
      conditions=[condition1],
      prompt=prompt,
      negative_prompt=negative_prompt,
      width=upscaled_width,
      height=upscaled_height,
      num_frames=num_frames,
      denoise_strength=0.4,  # Effectively, 4 inference steps out of 10
      num_inference_steps=10,
      latents=upscaled_latents,
      decode_timestep=0.05,
      decode_noise_scale=0.025,
      image_cond_noise_scale=0.0,
      guidance_scale=5.0,
      guidance_rescale=0.7,
      generator=torch.Generator().manual_seed(0),
      output_type="pil",
  ).frames[0]

  # 4. Downscale the video to the expected resolution
  video = [frame.resize((expected_width, expected_height)) for frame in video]

  export_to_video(video, "output.mp4", fps=24)
  ```

  

- Model LTX-Video 0.9.7 distilled telah di-distill untuk guidance dan timestep guna mempercepat proses generasi. Model ini memerlukan `guidance_scale` yang diatur ke `1.0` dan `num_inference_steps` sebaiknya diatur antara `4` dan `10` untuk kualitas generasi yang baik. Anda juga sebaiknya menggunakan timestep kustom berikut untuk hasil terbaik.

  - Inferensi model dasar untuk persiapan upscaling: `[1000, 993, 987, 981, 975, 909, 725, 0.03]`.
  - Upscaling: `[1000, 909, 725, 421, 0]`.

  
  Tampilkan kode contoh

  ```py
  import torch
  from diffusers import LTXConditionPipeline, LTXLatentUpsamplePipeline
  from diffusers.pipelines.ltx.pipeline_ltx_condition import LTXVideoCondition
  from diffusers.utils import export_to_video, load_video

  pipeline = LTXConditionPipeline.from_pretrained("Lightricks/LTX-Video-0.9.7-distilled", dtype=torch.bfloat16)
  pipe_upsample = LTXLatentUpsamplePipeline.from_pretrained("Lightricks/ltxv-spatial-upscaler-0.9.7", vae=pipeline.vae, dtype=torch.bfloat16)
  pipeline.to("cuda")  # or "mps", "xpu", "cpu"
  pipe_upsample.to("cuda")
  pipeline.vae.enable_tiling()

  def round_to_nearest_resolution_acceptable_by_vae(height, width):
      height = height - (height % pipeline.vae_spatial_compression_ratio)
      width = width - (width % pipeline.vae_spatial_compression_ratio)
      return height, width

  prompt = """
  artistic anatomical 3d render, utlra quality, human half full male body with transparent 
  skin revealing structure instead of organs, muscular, intricate creative patterns, 
  monochromatic with backlighting, lightning mesh, scientific concept art, blending biology 
  with botany, surreal and ethereal quality, unreal engine 5, ray tracing, ultra realistic, 
  16K UHD, rich details. camera zooms out in a rotating fashion
  """
  negative_prompt = "worst quality, inconsistent motion, blurry, jittery, distorted"
  expected_height, expected_width = 768, 1152
  downscale_factor = 2 / 3
  num_frames = 161

  # 1. Generate video at smaller resolution
  downscaled_height, downscaled_width = int(expected_height * downscale_factor), int(expected_width * downscale_factor)
  downscaled_height, downscaled_width = round_to_nearest_resolution_acceptable_by_vae(downscaled_height, downscaled_width)
  latents = pipeline(
      prompt=prompt,
      negative_prompt=negative_prompt,
      width=downscaled_width,
      height=downscaled_height,
      num_frames=num_frames,
      timesteps=[1000, 993, 987, 981, 975, 909, 725, 0.03],
      decode_timestep=0.05,
      decode_noise_scale=0.025,
      image_cond_noise_scale=0.0,
      guidance_scale=1.0,
      guidance_rescale=0.7,
      generator=torch.Generator().manual_seed(0),
      output_type="latent",
  ).frames

  # 2. Upscale generated video using latent upsampler with fewer inference steps
  # The available latent upsampler upscales the height/width by 2x
  upscaled_height, upscaled_width = downscaled_height * 2, downscaled_width * 2
  upscaled_latents = pipe_upsample(
      latents=latents,
      adain_factor=1.0,
      output_type="latent"
  ).frames

  # 3. Denoise the upscaled video with few steps to improve texture (optional, but recommended)
  video = pipeline(
      prompt=prompt,
      negative_prompt=negative_prompt,
      width=upscaled_width,
      height=upscaled_height,
      num_frames=num_frames,
      denoise_strength=0.999,  # Effectively, 4 inference steps out of 5
      timesteps=[1000, 909, 725, 421, 0],
      latents=upscaled_latents,
      decode_timestep=0.05,
      decode_noise_scale=0.025,
      image_cond_noise_scale=0.0,
      guidance_scale=1.0,
      guidance_rescale=0.7,
      generator=torch.Generator().manual_seed(0),
      output_type="pil",
  ).frames[0]

  # 4. Downscale the video to the expected resolution
  video = [frame.resize((expected_width, expected_height)) for frame in video]

  export_to_video(video, "output.mp4", fps=24)
  ```

  

- Model LTX-Video 0.9.8 distilled mirip dengan varian 0.9.7. Model ini telah melalui proses distilasi guidance dan timestep, sehingga kode inferensi yang serupa dapat digunakan seperti di atas. Peningkatan pada versi ini adalah dukungan untuk menghasilkan video yang sangat panjang. Selain itu, model ini juga mendukung penggunaan tone mapping untuk meningkatkan kualitas video yang dihasilkan melalui parameter `tone_map_compression_ratio`. Nilai default `0.6` direkomendasikan.

  
  Tampilkan kode contoh

  ```python
  import torch
  from diffusers import LTXConditionPipeline, LTXLatentUpsamplePipeline
  from diffusers.pipelines.ltx.pipeline_ltx_condition import LTXVideoCondition
  from diffusers.models.latent_upscaler import LTXLatentUpsamplerModel
  from diffusers.utils import export_to_video, load_video

  pipeline = LTXConditionPipeline.from_pretrained("Lightricks/LTX-Video-0.9.8-13B-distilled", dtype=torch.bfloat16)
  # TODO: Update the checkpoint here once updated in LTX org
  upsampler = LTXLatentUpsamplerModel.from_pretrained("a-r-r-o-w/LTX-0.9.8-Latent-Upsampler", dtype=torch.bfloat16)
  pipe_upsample = LTXLatentUpsamplePipeline(vae=pipeline.vae, latent_upsampler=upsampler).to(torch.bfloat16)
  pipeline.to("cuda")  # or "mps", "xpu", "cpu"
  pipe_upsample.to("cuda")
  pipeline.vae.enable_tiling()

  def round_to_nearest_resolution_acceptable_by_vae(height, width):
      height = height - (height % pipeline.vae_spatial_compression_ratio)
      width = width - (width % pipeline.vae_spatial_compression_ratio)
      return height, width

  prompt = """The camera pans over a snow-covered mountain range, revealing a vast expanse of snow-capped peaks and valleys.The mountains are covered in a thick layer of snow, with some areas appearing almost white while others have a slightly darker, almost grayish hue. The peaks are jagged and irregular, with some rising sharply into the sky while others are more rounded. The valleys are deep and narrow, with steep slopes that are also covered in snow. The trees in the foreground are mostly bare, with only a few leaves remaining on their branches. The sky is overcast, with thick clouds obscuring the sun. The overall impression is one of peace and tranquility, with the snow-covered mountains standing as a testament to the power and beauty of nature."""
  # prompt = """A woman walks away from a white Jeep parked on a city street at night, then ascends a staircase and knocks on a door. The woman, wearing a dark jacket and jeans, walks away from the Jeep parked on the left side of the street, her back to the camera; she walks at a steady pace, her arms swinging slightly by her sides; the street is dimly lit, with streetlights casting pools of light on the wet pavement; a man in a dark jacket and jeans walks past the Jeep in the opposite direction; the camera follows the woman from behind as she walks up a set of stairs towards a building with a green door; she reaches the top of the stairs and turns left, continuing to walk towards the building; she reaches the door and knocks on it with her right hand; the camera remains stationary, focused on the doorway; the scene is captured in real-life footage."""
  negative_prompt = "bright colors, symbols, graffiti, watermarks, worst quality, inconsistent motion, blurry, jittery, distorted"
  expected_height, expected_width = 480, 832
  downscale_factor = 2 / 3
  # num_frames = 161
  num_frames = 361

  # 1. Generate video at smaller resolution
  downscaled_height, downscaled_width = int(expected_height * downscale_factor), int(expected_width * downscale_factor)
  downscaled_height, downscaled_width = round_to_nearest_resolution_acceptable_by_vae(downscaled_height, downscaled_width)
  latents = pipeline(
      prompt=prompt,
      negative_prompt=negative_prompt,
      width=downscaled_width,
      height=downscaled_height,
      num_frames=num_frames,
      timesteps=[1000, 993, 987, 981, 975, 909, 725, 0.03],
      decode_timestep=0.05,
      decode_noise_scale=0.025,
      image_cond_noise_scale=0.0,
      guidance_scale=1.0,
      guidance_rescale=0.7,
      generator=torch.Generator().manual_seed(0),
      output_type="latent",
  ).frames

  # 2. Upscale generated video using latent upsampler with fewer inference steps
  # The available latent upsampler upscales the height/width by 2x
  upscaled_height, upscaled_width = downscaled_height * 2, downscaled_width * 2
  upscaled_latents = pipe_upsample(
      latents=latents,
      adain_factor=1.0,
      tone_map_compression_ratio=0.6,
      output_type="latent"
  ).frames

  # 3. Denoise the upscaled video with few steps to improve texture (optional, but recommended)
  video = pipeline(
      prompt=prompt,
      negative_prompt=negative_prompt,
      width=upscaled_width,
      height=upscaled_height,
      num_frames=num_frames,
      denoise_strength=0.999,  # Effectively, 4 inference steps out of 5
      timesteps=[1000, 909, 725, 421, 0],
      latents=upscaled_latents,
      decode_timestep=0.05,
      decode_noise_scale=0.025,
      image_cond_noise_scale=0.0,
      guidance_scale=1.0,
      guidance_rescale=0.7,
      generator=torch.Generator().manual_seed(0),
      output_type="pil",
  ).frames[0]

  # 4. Downscale the video to the expected resolution
  video = [frame.resize((expected_width, expected_height)) for frame in video]

  export_to_video(video, "output.mp4", fps=24)
  ```

  

- LTX-Video mendukung LoRA dengan [load_lora_weights()](/docs/diffusers/v0.43.0/id/api/loaders/lora#diffusers.loaders.LTXVideoLoraLoaderMixin.load_lora_weights).

  
  Tampilkan kode contoh

  ```py
  import torch
  from diffusers import LTXConditionPipeline
  from diffusers.utils import export_to_video, load_image

  pipeline = LTXConditionPipeline.from_pretrained(
      "Lightricks/LTX-Video-0.9.5", dtype=torch.bfloat16
  )

  pipeline.load_lora_weights("Lightricks/LTX-Video-Cakeify-LoRA", adapter_name="cakeify")
  pipeline.set_adapters("cakeify")

  # use "CAKEIFY" to trigger the LoRA
  prompt = "CAKEIFY a person using a knife to cut a cake shaped like a Pikachu plushie"
  image = load_image("https://huggingface.co/Lightricks/LTX-Video-Cakeify-LoRA/resolve/main/assets/images/pikachu.png")

  video = pipeline(
      prompt=prompt,
      image=image,
      width=576,
      height=576,
      num_frames=161,
      decode_timestep=0.03,
      decode_noise_scale=0.025,
      num_inference_steps=50,
  ).frames[0]
  export_to_video(video, "output.mp4", fps=26)
  ```

  

- LTX-Video mendukung pemuatan dari file tunggal, seperti [checkpoint GGUF](../../quantization/gguf), dengan [loaders.FromOriginalModelMixin.from_single_file()](/docs/diffusers/v0.43.0/id/api/loaders/single_file#diffusers.loaders.FromOriginalModelMixin.from_single_file) atau [loaders.FromSingleFileMixin.from_single_file()](/docs/diffusers/v0.43.0/id/api/loaders/single_file#diffusers.loaders.FromSingleFileMixin.from_single_file).

  
  Tampilkan kode contoh

  ```py
  import torch
  from diffusers.utils import export_to_video
  from diffusers import LTXPipeline, AutoModel, GGUFQuantizationConfig

  transformer = AutoModel.from_single_file(
      "https://huggingface.co/city96/LTX-Video-gguf/blob/main/ltx-video-2b-v0.9-Q3_K_S.gguf"
      quantization_config=GGUFQuantizationConfig(compute_dtype=torch.bfloat16),
      dtype=torch.bfloat16
  )
  pipeline = LTXPipeline.from_pretrained(
      "Lightricks/LTX-Video",
      transformer=transformer,
      dtype=torch.bfloat16
  )
  ```

  

## LTXI2VLongMultiPromptPipeline[[diffusers.LTXI2VLongMultiPromptPipeline]]

#### diffusers.LTXI2VLongMultiPromptPipeline[[diffusers.LTXI2VLongMultiPromptPipeline]]

```python
diffusers.LTXI2VLongMultiPromptPipeline(scheduler: FlowMatchEulerDiscreteScheduler, vae: AutoencoderKLLTXVideo, text_encoder: T5EncoderModel, tokenizer: T5TokenizerFast, transformer: LTXVideoTransformer3DModel)
```

[Sumber](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/pipelines/ltx/pipeline_ltx_i2v_long_multi_prompt.py#L389)

**Parameter:**

transformer ([LTXVideoTransformer3DModel](/docs/diffusers/v0.43.0/id/api/models/ltx_video_transformer3d#diffusers.LTXVideoTransformer3DModel)) : Arsitektur Transformer bersyarat untuk mendenoise latens video yang telah dikodekan.

scheduler ([FlowMatchEulerDiscreteScheduler](/docs/diffusers/v0.43.0/id/api/schedulers/flow_match_euler_discrete#diffusers.FlowMatchEulerDiscreteScheduler) atau `LTXEulerAncestralRFScheduler`) : Scheduler yang digunakan bersama `transformer` untuk menghilangkan noise pada latens gambar yang telah dikodekan.

vae ([AutoencoderKLLTXVideo](/docs/diffusers/v0.43.0/id/api/models/autoencoderkl_ltx_video#diffusers.AutoencoderKLLTXVideo)) : Model Variational Auto-Encoder (VAE) untuk mengodekan dan mendekodekan gambar ke dan dari representasi laten.

text_encoder (`T5EncoderModel`) : [T5](https://huggingface.co/docs/transformers/en/model_doc/t5#transformers.T5EncoderModel), khususnya varian [google/t5-v1_1-xxl](https://huggingface.co/google/t5-v1_1-xxl).

tokenizer (`T5TokenizerFast`) : Tokenizer dari kelas [T5TokenizerFast](https://huggingface.co/docs/transformers/en/model_doc/t5#transformers.T5TokenizerFast).

Pipeline multi-prompt I2V (image-to-video) berdurasi panjang dengan paritas ComfyUI.

Fitur utama:
- Pengambilan sampel jendela geser temporal saja (tanpa pembagian spasial H/W); fusi autoregresif di antara jendela.
- Segmentasi multi-prompt per jendela dengan transisi halus di kepala jendela.
- Kondisi keras bingkai pertama melalui masker per-token untuk I2V.
- Kontrol VRAM melalui temporal windowing dan VAE tiled decoding.

Referensi: https://github.com/Lightricks/LTX-Video

#### __call__[[diffusers.LTXI2VLongMultiPromptPipeline.__call__]]

```python
__call__(prompt: str | list[str] = None, negative_prompt: str | list[str] | None = None, prompt_segments: list[dict[str, Any]] | None = None, height: int = 512, width: int = 704, num_frames: int = 161, frame_rate: float = 25, guidance_scale: float = 1.0, guidance_rescale: float = 0.0, num_inference_steps: int | None = 8, sigmas: list[float, torch.Tensor] | None = None, generator: torch.Generator | list[torch.Generator] | None = None, seed: int | None = 0, cond_image: 'PIL.Image.Image' | torch.Tensor | None = None, cond_strength: float = 0.5, latents: torch.Tensor | None = None, temporal_tile_size: int = 80, temporal_overlap: int = 24, temporal_overlap_cond_strength: float = 0.5, adain_factor: float = 0.25, guidance_latents: torch.Tensor | None = None, guiding_strength: float = 1.0, negative_index_latents: torch.Tensor | None = None, negative_index_strength: float = 1.0, skip_steps_sigma_threshold: float | None = 1, decode_timestep: float | None = 0.05, decode_noise_scale: float | None = 0.025, decode_horizontal_tiles: int = 4, decode_vertical_tiles: int = 4, decode_overlap: int = 3, output_type: str | None = 'latent', return_dict: bool = True, attention_kwargs: dict[str, Any] | None = None, callback_on_step_end: Callable[[int, int], None] | None = None, callback_on_step_end_tensor_inputs: list[str] = ['latents'], max_sequence_length: int = 128)
```

[Sumber](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/pipelines/ltx/pipeline_ltx_i2v_long_multi_prompt.py#L935)

**Parameter:**

prompt (`str` atau `list[str]`, *opsional*) : Prompt teks positif per jendela. Jika satu string berisi '|', bagian-bagiannya dipisahkan oleh bar.

negative_prompt (`str` atau `list[str]`, *opsional*) : Prompt negatif untuk menekan konten yang tidak diinginkan.

prompt_segments (`list[dict]`, *opsional*) : Pemetaan segmen dengan {"start_window", "end_window", "text"} untuk menimpa prompt per jendela.

height (`int`, defaultnya `512`) : Tinggi gambar output dalam piksel; harus habis dibagi 32.

width (`int`, defaultnya `704`) : Lebar gambar keluaran dalam piksel; harus habis dibagi 32.

num_frames (`int`, defaultnya `161`) : Jumlah frame output (dalam ruang piksel terdekode).

frame_rate (`float`, defaultnya `25`) : Frame per detik; digunakan untuk menormalisasi koordinat temporal di `video_coords`.

guidance_scale (`float`, defaultnya `1.0`) : skala CFG; nilai > 1 mengaktifkan classifier-free guidance.

guidance_rescale (`float`, defaultnya `0.0`) : Rescale opsional untuk memitigasi overexposure di bawah CFG (lihat `rescale_noise_cfg`).

num_inference_steps (`int`, *opsional*, default `8`) : Langkah denoising per jendela. Diabaikan jika `sigmas` disediakan.

sigmas (`list[float]` atau `torch.Tensor`, *opsional*) : Jadwal sigma eksplisit per jendela; jika diatur, menimpa `num_inference_steps`.

generator (`torch.Generator` atau `list[torch.Generator]`, *opsional*) : Mengontrol sifat stokastik; daftar diterima tetapi hanya elemen pertama yang digunakan (batch=1).

seed (`int`, *opsional*, defaultnya `0`) : Jika diberikan, menabur benih (seed) generator bersama untuk latens global dan menurunkan generator lokal jendela dengan `seed + w_start` per jendela temporal.

cond_image (`PIL.Image.Image` atau `torch.Tensor`, *opsional*) : Gambar kondisioning; memperbaiki frame 0 melalui mask per-token ketika `cond_strength > 0`.

cond_strength (`float`, defaultnya `0.5`) : Kekuatan kondisi keras bingkai pertama (cond_mask yang lebih kecil ⇒ pelestarian yang lebih kuat).

latents (`torch.Tensor`, *opsional*) : Laten awal [B, C_lat, F_lat, H_lat, W_lat]; jika None, diambil dengan `randn_tensor`.

temporal_tile_size (`int`, defaultnya `80`) : Ukuran jendela temporal (dalam frame yang didekode); secara internal diskalakan oleh kompresi temporal VAE.

temporal_overlap (`int`, defaultnya `24`) : Tumpang tindih antara jendela berurutan (dalam frame yang didekode); secara internal diskalakan oleh kompresi.

temporal_overlap_cond_strength (`float`, defaultnya `0.5`) : Kekuatan untuk menyuntikkan latens ekor jendela sebelumnya ke kepala jendela baru.

adain_factor (`float`, defaultnya `0.25`) : Kekuatan normalisasi AdaIN untuk konsistensi antar-jendela (0 untuk menonaktifkan).

guidance_latents (`torch.Tensor`, *opsional*) : Laten referensi yang disuntikkan di kepala jendela; panjangnya dipangkas oleh tumpang tindih untuk jendela berikutnya.

guiding_strength (`float`, defaultnya `1.0`) : Kekuatan injeksi untuk `guidance_latents`.

negative_index_latents (`torch.Tensor`, *opsional*) : Laten satu bingkai yang ditambahkan di kepala jendela untuk semantik "indeks negatif".

negative_index_strength (`float`, defaultnya `1.0`) : Kekuatan injeksi untuk `negative_index_latents`.

skip_steps_sigma_threshold (`float`, *opsional*, defaultnya `1`) : Lewati langkah-langkah yang sigmanya melebihi ambang batas ini.

decode_timestep (`float`, *opsional*, default `0.05`) : Timestep saat decode (jika VAE mendukung timestep_conditioning).

decode_noise_scale (`float`, *opsional*, default `0.025`) : Skala campuran noise saat decode (jika VAE mendukung timestep_conditioning).

decode_horizontal_tiles (`int`, defaultnya `4`) : Jumlah ubin horizontal selama decoding VAE.

decode_vertical_tiles (`int`, defaultnya `4`) : Jumlah ubin vertikal selama decoding VAE.

decode_overlap (`int`, defaultnya `3`) : Overlap (dalam piksel laten) antara tile selama decoding VAE.

output_type (`str`, *opsional*, defaultnya `"latent"`) : Format output dari video yang dihasilkan. Pilih antara "latent", "pt", "np", atau "pil". Jika "latent", mengembalikan latents tanpa decoding.

return_dict (`bool`, *opsional*, defaultnya `True`) : Apakah akan mengembalikan `~pipelines.ltx.LTXPipelineOutput` alih-alih tuple biasa.

attention_kwargs (`dict`, *opsional*) : Parameter perhatian tambahan yang diteruskan ke transformer.

callback_on_step_end (`PipelineCallback` atau `MultiPipelineCallbacks`, *opsional*) : Hook callback per langkah.

callback_on_step_end_tensor_inputs (`list[str]`, defaultnya `["latents"]`) : Kunci dari locals() untuk diteruskan ke callback.

max_sequence_length (`int`, defaultnya `128`) : Panjang maksimum tokenizer untuk pengkodean prompt.

**Mengembalikan:** `~pipelines.ltx.LTXPipelineOutput` atau `tuple`

Jika `return_dict` adalah `True`, maka `~pipelines.ltx.LTXPipelineOutput` yang dikembalikan, selain itu sebuah `tuple` yang dikembalikan di mana elemen pertama adalah daftar dengan frame yang dihasilkan. Format output bergantung pada `output_type`:
- "latent"/"pt": `torch.Tensor` [B, C, F, H, W]; "latent" berada di ruang laten ternormalisasi, "pt" berada di ruang output VAE.
- "np": `np.ndarray` yang telah diproses pascaproses.
- "pil": `list[PIL.Image.Image]` daftar gambar PIL.

Buat urutan gambar-ke-video melalui jendela geser temporal dan penjadwalan multi-prompt.

Contoh:
```py
>>> import torch
>>> from diffusers import LTXEulerAncestralRFScheduler, LTXI2VLongMultiPromptPipeline

>>> pipe = LTXI2VLongMultiPromptPipeline.from_pretrained("LTX-Video-0.9.8-13B-distilled")
>>> # For ComfyUI parity, swap in the RF scheduler (keeps the original config).
>>> pipe.scheduler = LTXEulerAncestralRFScheduler.from_config(pipe.scheduler.config)
>>> pipe = pipe.to("cuda").to(dtype=torch.bfloat16)
>>> # Example A: get decoded frames (PIL)
>>> out = pipe(
...     prompt="a chimpanzee walks | a chimpanzee eats",
...     num_frames=161,
...     height=512,
...     width=704,
...     temporal_tile_size=80,
...     temporal_overlap=24,
...     output_type="pil",
...     return_dict=True,
... )
>>> frames = out.frames[0]  # list of PIL.Image.Image
>>> # Example B: get latent video and decode later (saves VRAM during sampling)
>>> out_latent = pipe(prompt="a chimpanzee walking", output_type="latent", return_dict=True).frames
>>> frames = pipe.vae_decode_tiled(out_latent, output_type="pil")[0]
```

Bentuk: Ukuran laten (ketika dibuat secara otomatis):
- F_lat = (num_frames - 1) // vae_temporal_compression_ratio + 1
- H_lat = height // vae_spatial_compression_ratio
- W_lat = width // vae_spatial_compression_ratio

Catatan:
- Seeding: ketika `seed` diberikan, setiap jendela temporal menggunakan generator lokal yang di-seed dengan `seed + w_start`, sedangkan generator bersama di-seed sekali untuk latens global jika tidak ada generator yang diteruskan; jika tidak, generator yang diteruskan akan digunakan kembali.
- CFG: `noise_pred = uncond + w * (text - uncond)` yang disatukan dengan `guidance_rescale` opsional.
- Memory: denoising melakukan prediksi full-frame (tanpa spatial tiling); decoding dapat di-tile untuk menghindari OOM.

#### encode_prompt[[diffusers.LTXI2VLongMultiPromptPipeline.encode_prompt]]

```python
encode_prompt(prompt: str | list[str], negative_prompt: str | list[str] | None = None, do_classifier_free_guidance: bool = True, num_videos_per_prompt: int = 1, prompt_embeds: torch.Tensor | None = None, negative_prompt_embeds: torch.Tensor | None = None, prompt_attention_mask: torch.Tensor | None = None, negative_prompt_attention_mask: torch.Tensor | None = None, max_sequence_length: int = 128, device: torch.device | None = None, dtype: torch.dtype | None = None)
```

[Sumber](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/pipelines/ltx/pipeline_ltx_i2v_long_multi_prompt.py#L552)

**Parameter:**

prompt (`str` atau `list[str]`, *opsional*) : prompt yang akan dienkod

negative_prompt (`str` atau `list[str]`, *opsional*) : Prompt atau prompt-prompt yang tidak akan memandu generasi gambar. Jika tidak didefinisikan, Anda harus meneruskan `negative_prompt_embeds` sebagai gantinya. Diabaikan saat tidak menggunakan guidance (yaitu, diabaikan jika `guidance_scale` kurang dari `1`).

do_classifier_free_guidance (`bool`, *opsional*, defaultnya `True`) : Apakah akan menggunakan classifier free guidance atau tidak.

num_videos_per_prompt (`int`, *opsional*, default 1) : Jumlah video yang harus dihasilkan per prompt. perangkat torch untuk menempatkan embedding yang dihasilkan

prompt_embeds (`torch.Tensor`, *opsional*) : Embedding teks yang sudah dibuat sebelumnya. Dapat digunakan untuk dengan mudah menyesuaikan input teks, *misalnya* penimbangan prompt. Jika tidak disediakan, embedding teks akan dihasilkan dari argumen input `prompt`.

negative_prompt_embeds (`torch.Tensor`, *opsional*) : Embedding teks negatif yang telah dibuat sebelumnya. Dapat digunakan untuk dengan mudah menyesuaikan input teks, *misalnya* penimbangan prompt. Jika tidak disediakan, negative_prompt_embeds akan dibuat dari argumen input `negative_prompt`.

device : (`torch.device`, *opsional*): perangkat torch

dtype : (`torch.dtype`, *opsional*): torch dtype

Mengkodekan prompt menjadi hidden states dari text encoder.

#### prepare_latents[[diffusers.LTXI2VLongMultiPromptPipeline.prepare_latents]]

```python
prepare_latents(batch_size: int, num_channels_latents: int, height: int, width: int, num_frames: int, device: torch.device, generator: torch.Generator | None, dtype: torch.dtype = torch.float32, latents: torch.Tensor | None = None, cond_latents: torch.Tensor | None = None, cond_strength: float = 0.0, negative_index_latents: torch.Tensor | None = None)
```

[Sumber](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/pipelines/ltx/pipeline_ltx_i2v_long_multi_prompt.py#L694)

**Mengembalikan:**

latents, negative_index_latents, latent_num_frames, latent_height, latent_width

Siapkan latens dasar dan secara opsional suntikkan latens kondisioning bingkai pertama.

#### vae_decode_tiled[[diffusers.LTXI2VLongMultiPromptPipeline.vae_decode_tiled]]

```python
vae_decode_tiled(latents: torch.Tensor, decode_timestep: float | None = None, decode_noise_scale: float | None = None, horizontal_tiles: int = 4, vertical_tiles: int = 4, overlap: int = 3, last_frame_fix: bool = True, generator: torch.Generator | None = None, output_type: str = 'pt', auto_denormalize: bool = True, compute_dtype: torch.dtype = torch.float32, enable_vae_tiling: bool = False)
```

[Sumber](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/pipelines/ltx/pipeline_ltx_i2v_long_multi_prompt.py#L738)

**Parameter:**

latents : [B, C_latent, F_latent, H_latent, W_latent]

decode_timestep : Langkah waktu decode opsional (hanya berlaku jika VAE mendukung timestep_conditioning)

decode_noise_scale : Interpolasi noise decode opsional (hanya berlaku jika VAE mendukung timestep_conditioning)

horizontal_tiles, vertical_tiles : Jumlah tile secara horizontal/vertikal (>= 1)

overlap : Tumpang tindih di ruang laten (dalam piksel laten, >= 0)

last_frame_fix : Apakah akan mengaktifkan perbaikan "ulangi bingkai terakhir"

generator : Generator acak (digunakan untuk decode_noise_scale noise)

output_type : "latent" | "pt" | "np" | "pil" - "latent": kembalikan latents tanpa perubahan (berguna untuk pemrosesan lanjutan) - "pt": kembalikan tensor dalam ruang output VAE - "np"/"pil": output yang diproses pascaproses melalui VideoProcessor.postprocess_video

auto_denormalize : Jika True, terapkan de-normalisasi LTX pada `latents` secara internal (disarankan)

compute_dtype : Presisi yang digunakan selama penggabungan tile (default float32; secara signifikan mengurangi blur pada sambungan)

enable_vae_tiling : Jika True, delegasikan tiling ke `tiled_decode` bawaan VAE (mengatur `vae.use_tiling`).

**Returns:** `- If output_type="latent"`

mengembalikan `latents` input tanpa perubahan
- Jika output_type="pt": mengembalikan [B, C, F, H, W] (nilai kira-kira dalam [-1, 1])
- Jika output_type="np"/"pil": mengembalikan output yang telah diproses ulang melalui postprocess_video

Dekoding spasial berbasis VAE dengan tiling (setara ComfyUI) yang diimplementasikan dalam gaya Diffusers.
- Lakukan feathering dan blending secara linear pada tile yang tumpang tindih untuk menghindari sambungan.
- last_frame_fix opsional: duplikasi frame laten terakhir sebelum decoding, lalu buang time_scale_factor frame di akhir.
- Mendukung injeksi timestep_conditioning dan decode_noise_scale.
- Secara default, "normalized latents" (output denoising) akan di-de-normalisasi secara internal (auto_denormalize=True).
- Tile fusion dihitung dalam compute_dtype (float32 secara default) untuk mengurangi blur dan pergeseran warna.

## LTXPipeline[[diffusers.LTXPipeline]]

#### diffusers.LTXPipeline[[diffusers.LTXPipeline]]

```python
diffusers.LTXPipeline(scheduler: FlowMatchEulerDiscreteScheduler, vae: AutoencoderKLLTXVideo, text_encoder: T5EncoderModel, tokenizer: T5Tokenizer, transformer: LTXVideoTransformer3DModel)
```

[Sumber](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/pipelines/ltx/pipeline_ltx.py#L170)

**Parameter:**

transformer ([LTXVideoTransformer3DModel](/docs/diffusers/v0.43.0/id/api/models/ltx_video_transformer3d#diffusers.LTXVideoTransformer3DModel)) : Arsitektur Transformer bersyarat untuk mendenoise latens video yang telah dikodekan.

scheduler ([FlowMatchEulerDiscreteScheduler](/docs/diffusers/v0.43.0/id/api/schedulers/flow_match_euler_discrete#diffusers.FlowMatchEulerDiscreteScheduler)) : Penjadwal yang digunakan bersama `transformer` untuk menghilangkan noise pada latens gambar yang telah dikodekan.

vae ([AutoencoderKLLTXVideo](/docs/diffusers/v0.43.0/id/api/models/autoencoderkl_ltx_video#diffusers.AutoencoderKLLTXVideo)) : Model Variational Auto-Encoder (VAE) untuk mengodekan dan mendekodekan gambar ke dan dari representasi laten.

text_encoder (`T5EncoderModel`) : [T5](https://huggingface.co/docs/transformers/en/model_doc/t5#transformers.T5EncoderModel), khususnya varian [google/t5-v1_1-xxl](https://huggingface.co/google/t5-v1_1-xxl).

tokenizer (`CLIPTokenizer`) : Tokenizer dari kelas [CLIPTokenizer](https://huggingface.co/docs/transformers/en/model_doc/clip#transformers.CLIPTokenizer).

tokenizer (`T5TokenizerFast`) : Tokenizer kedua dari kelas [T5TokenizerFast](https://huggingface.co/docs/transformers/en/model_doc/t5#transformers.T5TokenizerFast).

Pipeline untuk generasi teks-ke-video.

Referensi: https://github.com/Lightricks/LTX-Video

#### __call__[[diffusers.LTXPipeline.__call__]]

```python
__call__(prompt: str | list[str] = None, negative_prompt: str | list[str] | None = None, height: int = 512, width: int = 704, num_frames: int = 161, frame_rate: int = 25, num_inference_steps: int = 50, timesteps: list[int] = None, guidance_scale: float = 3, guidance_rescale: float = 0.0, num_videos_per_prompt: int | None = 1, generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = None, latents: typing.Optional[torch.Tensor] = None, prompt_embeds: typing.Optional[torch.Tensor] = None, prompt_attention_mask: typing.Optional[torch.Tensor] = None, negative_prompt_embeds: typing.Optional[torch.Tensor] = None, negative_prompt_attention_mask: typing.Optional[torch.Tensor] = None, decode_timestep: float | list[float] = 0.0, decode_noise_scale: float | list[float] | None = None, output_type: str | None = 'pil', return_dict: bool = True, attention_kwargs: dict[str, typing.Any] | None = None, callback_on_step_end: typing.Optional[typing.Callable[[int, int], NoneType]] = None, callback_on_step_end_tensor_inputs: list[str] = ['latents'], max_sequence_length: int = 128)
```

[Sumber](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/pipelines/ltx/pipeline_ltx.py#L535)

**Parameter:**

prompt (`str` atau `list[str]`, *opsional*) : Prompt atau prompt-prompt untuk mengarahkan generasi gambar. Jika tidak didefinisikan, Anda harus melewatkan `prompt_embeds` sebagai gantinya.

negative_prompt (`str` atau `list[str]`, *opsional*) : Prompt atau prompt-prompt yang tidak akan memandu generasi gambar. Jika tidak didefinisikan, Anda harus meneruskan `negative_prompt_embeds` sebagai gantinya. Diabaikan saat tidak menggunakan panduan (`guidance_scale < 1`).

height (`int`, defaultnya `512`) : Tinggi gambar yang dihasilkan dalam piksel. Ini diatur ke 480 secara default untuk hasil terbaik.

width (`int`, defaultnya `704`) : Lebar gambar yang dihasilkan dalam piksel. Ini diatur ke 848 secara default untuk hasil terbaik.

num_frames (`int`, defaultnya `161`) : Jumlah bingkai video yang akan dihasilkan

frame_rate (`int`, defaultnya `25`) : Laju bingkai target dari video yang dihasilkan.

num_inference_steps (`int`, *opsional*, defaultnya 50) : Jumlah langkah denoising. Semakin banyak langkah denoising, biasanya menghasilkan gambar dengan kualitas lebih tinggi, namun dengan biaya inferensi yang lebih lambat.

timesteps (`list[int]`, *opsional*) : Timesteps kustom untuk digunakan dalam proses denoising dengan scheduler yang mendukung argumen `timesteps` di metode `set_timesteps` mereka. Jika tidak didefinisikan, perilaku default saat `num_inference_steps` diteruskan akan digunakan. Harus dalam urutan menurun.

guidance_scale (`float`, defaultnya `3 `) : Skala panduan seperti yang didefinisikan dalam [Classifier-Free Diffusion Guidance](https://huggingface.co/papers/2207.12598). `guidance_scale` didefinisikan sebagai `w` dari persamaan 2. pada [Imagen Paper](https://huggingface.co/papers/2205.11487). Skala panduan diaktifkan dengan mengatur `guidance_scale > 1`. Skala panduan yang lebih tinggi mendorong generasi gambar yang sangat terkait dengan `prompt` teks, biasanya dengan mengorbankan kualitas gambar yang lebih rendah.

guidance_rescale (`float`, *opsional*, default 0.0) : Faktor rescale guidance yang diusulkan oleh [Common Diffusion Noise Schedules and Sample Steps are Flawed](https://huggingface.co/papers/2305.08891) `guidance_scale` didefinisikan sebagai `φ` dalam persamaan 16. dari [Common Diffusion Noise Schedules and Sample Steps are Flawed](https://huggingface.co/papers/2305.08891). Faktor rescale guidance harus memperbaiki overexposure saat menggunakan zero terminal SNR.

num_videos_per_prompt (`int`, *opsional*, default 1) : Jumlah video yang akan dihasilkan per prompt.

generator (`torch.Generator` atau `list[torch.Generator]`, *opsional*) : Satu atau daftar [generator torch](https://pytorch.org/docs/stable/generated/torch.Generator.html) untuk membuat proses generasi menjadi deterministik.

latents (`torch.Tensor`, *opsional*) : Laten berisik yang telah dibuat sebelumnya, diambil dari distribusi Gaussian, untuk digunakan sebagai input untuk generasi gambar. Dapat digunakan untuk menyesuaikan generasi yang sama dengan prompt yang berbeda. Jika tidak disediakan, tensor laten akan dibuat dengan pengambilan sampel menggunakan `generator` acak yang diberikan.

prompt_embeds (`torch.Tensor`, *opsional*) : Embedding teks yang sudah dibuat sebelumnya. Dapat digunakan untuk dengan mudah menyesuaikan input teks, *misalnya* penimbangan prompt. Jika tidak disediakan, embedding teks akan dihasilkan dari argumen input `prompt`.

prompt_attention_mask (`torch.Tensor`, *opsional*) : Mask perhatian yang telah dibuat sebelumnya untuk embedding teks.

negative_prompt_embeds (`torch.FloatTensor`, *opsional*) : Embedding teks negatif yang telah dibuat sebelumnya. Untuk PixArt-Sigma, prompt negatif ini harus "". Jika tidak disediakan, negative_prompt_embeds akan dibuat dari argumen input `negative_prompt`.

negative_prompt_attention_mask (`torch.FloatTensor`, *opsional*) : Mask perhatian yang telah dibuat sebelumnya untuk embedding teks negatif.

decode_timestep (`float`, defaultnya `0.0`) : Timestep di mana video yang dihasilkan didekode.

decode_noise_scale (`float`, defaultnya `None`) : Faktor interpolasi antara noise acak dan latents yang telah dinoise pada timestep decode.

output_type (`str`, *opsional*, defaultnya `"pil"`) : Format output dari gambar yang dihasilkan. Pilih antara [PIL](https://pillow.readthedocs.io/en/stable/): `PIL.Image.Image` atau `np.array`.

return_dict (`bool`, *opsional*, defaultnya `True`) : Apakah akan mengembalikan `~pipelines.ltx.LTXPipelineOutput` alih-alih tuple biasa.

attention_kwargs (`dict`, *opsional*) : Kamus kwargs yang jika ditentukan akan diteruskan ke `AttentionProcessor` seperti yang didefinisikan di bawah `self.processor` dalam [diffusers.models.attention_processor](https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/attention_processor.py).

callback_on_step_end (`Callable`, *opsional*) : Fungsi yang dipanggil di akhir setiap langkah denoising selama inferensi. Fungsi ini dipanggil dengan argumen berikut: `callback_on_step_end(self: DiffusionPipeline, step: int, timestep: int, callback_kwargs: Dict)`. `callback_kwargs` akan berisi daftar semua tensor sesuai yang ditentukan oleh `callback_on_step_end_tensor_inputs`.

callback_on_step_end_tensor_inputs (`list`, *opsional*) : Daftar input tensor untuk fungsi `callback_on_step_end`. Tensor yang ditentukan dalam daftar akan diteruskan sebagai argumen `callback_kwargs`. Anda hanya dapat menyertakan variabel yang tercantum dalam atribut `._callback_tensor_inputs` dari kelas pipeline Anda.

max_sequence_length (`int` defaultnya `128 `) : Panjang maksimum urutan yang digunakan dengan `prompt`.

**Mengembalikan:** `~pipelines.ltx.LTXPipelineOutput` atau `tuple`

Jika `return_dict` adalah `True`, `~pipelines.ltx.LTXPipelineOutput` dikembalikan, selain itu sebuah `tuple` dikembalikan di mana elemen pertama adalah daftar dengan gambar yang dihasilkan.

Fungsi yang dipanggil saat memanggil pipeline untuk generasi.

Contoh:
```py
>>> import torch
>>> from diffusers import LTXPipeline
>>> from diffusers.utils import export_to_video

>>> pipe = LTXPipeline.from_pretrained("Lightricks/LTX-Video", torch_dtype=torch.bfloat16)
>>> pipe.to("cuda")

>>> prompt = "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'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"
>>> negative_prompt = "worst quality, inconsistent motion, blurry, jittery, distorted"

>>> video = pipe(
...     prompt=prompt,
...     negative_prompt=negative_prompt,
...     width=704,
...     height=480,
...     num_frames=161,
...     num_inference_steps=50,
... ).frames[0]
>>> export_to_video(video, "output.mp4", fps=24)
```

#### encode_prompt[[diffusers.LTXPipeline.encode_prompt]]

```python
encode_prompt(prompt: str | list[str], negative_prompt: str | list[str] | None = None, do_classifier_free_guidance: bool = True, num_videos_per_prompt: int = 1, prompt_embeds: typing.Optional[torch.Tensor] = None, negative_prompt_embeds: typing.Optional[torch.Tensor] = None, prompt_attention_mask: typing.Optional[torch.Tensor] = None, negative_prompt_attention_mask: typing.Optional[torch.Tensor] = None, max_sequence_length: int = 128, device: typing.Optional[torch.device] = None, dtype: typing.Optional[torch.dtype] = None)
```

[Sumber](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/pipelines/ltx/pipeline_ltx.py#L283)

**Parameter:**

prompt (`str` atau `list[str]`, *opsional*) : prompt yang akan dienkod

negative_prompt (`str` atau `list[str]`, *opsional*) : Prompt atau prompt-prompt yang tidak akan memandu generasi gambar. Jika tidak didefinisikan, Anda harus meneruskan `negative_prompt_embeds` sebagai gantinya. Diabaikan saat tidak menggunakan guidance (yaitu, diabaikan jika `guidance_scale` kurang dari `1`).

do_classifier_free_guidance (`bool`, *opsional*, defaultnya `True`) : Apakah akan menggunakan classifier free guidance atau tidak.

num_videos_per_prompt (`int`, *opsional*, default 1) : Jumlah video yang harus dihasilkan per prompt. perangkat torch untuk menempatkan embedding yang dihasilkan

prompt_embeds (`torch.Tensor`, *opsional*) : Embedding teks yang sudah dibuat sebelumnya. Dapat digunakan untuk dengan mudah menyesuaikan input teks, *misalnya* penimbangan prompt. Jika tidak disediakan, embedding teks akan dihasilkan dari argumen input `prompt`.

negative_prompt_embeds (`torch.Tensor`, *opsional*) : Embedding teks negatif yang telah dibuat sebelumnya. Dapat digunakan untuk dengan mudah menyesuaikan input teks, *misalnya* penimbangan prompt. Jika tidak disediakan, negative_prompt_embeds akan dibuat dari argumen input `negative_prompt`.

device : (`torch.device`, *opsional*): perangkat torch

dtype : (`torch.dtype`, *opsional*): torch dtype

Mengkodekan prompt menjadi hidden states dari text encoder.

## LTXImageToVideoPipeline[[diffusers.LTXImageToVideoPipeline]]

#### diffusers.LTXImageToVideoPipeline[[diffusers.LTXImageToVideoPipeline]]

```python
diffusers.LTXImageToVideoPipeline(scheduler: FlowMatchEulerDiscreteScheduler, vae: AutoencoderKLLTXVideo, text_encoder: T5EncoderModel, tokenizer: T5Tokenizer, transformer: LTXVideoTransformer3DModel)
```

[Sumber](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/pipelines/ltx/pipeline_ltx_image2video.py#L189)

**Parameter:**

transformer ([LTXVideoTransformer3DModel](/docs/diffusers/v0.43.0/id/api/models/ltx_video_transformer3d#diffusers.LTXVideoTransformer3DModel)) : Arsitektur Transformer bersyarat untuk mendenoise latens video yang telah dikodekan.

scheduler ([FlowMatchEulerDiscreteScheduler](/docs/diffusers/v0.43.0/id/api/schedulers/flow_match_euler_discrete#diffusers.FlowMatchEulerDiscreteScheduler)) : Penjadwal yang digunakan bersama `transformer` untuk menghilangkan noise pada latens gambar yang telah dikodekan.

vae ([AutoencoderKLLTXVideo](/docs/diffusers/v0.43.0/id/api/models/autoencoderkl_ltx_video#diffusers.AutoencoderKLLTXVideo)) : Model Variational Auto-Encoder (VAE) untuk mengodekan dan mendekodekan gambar ke dan dari representasi laten.

text_encoder (`T5EncoderModel`) : [T5](https://huggingface.co/docs/transformers/en/model_doc/t5#transformers.T5EncoderModel), khususnya varian [google/t5-v1_1-xxl](https://huggingface.co/google/t5-v1_1-xxl).

tokenizer (`CLIPTokenizer`) : Tokenizer dari kelas [CLIPTokenizer](https://huggingface.co/docs/transformers/en/model_doc/clip#transformers.CLIPTokenizer).

tokenizer (`T5TokenizerFast`) : Tokenizer kedua dari kelas [T5TokenizerFast](https://huggingface.co/docs/transformers/en/model_doc/t5#transformers.T5TokenizerFast).

Pipeline untuk generasi gambar-ke-video.

Referensi: https://github.com/Lightricks/LTX-Video

#### __call__[[diffusers.LTXImageToVideoPipeline.__call__]]

```python
__call__(image: typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor]] = None, prompt: str | list[str] = None, negative_prompt: str | list[str] | None = None, height: int = 512, width: int = 704, num_frames: int = 161, frame_rate: int = 25, num_inference_steps: int = 50, timesteps: list[int] = None, guidance_scale: float = 3, guidance_rescale: float = 0.0, num_videos_per_prompt: int | None = 1, generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = None, latents: typing.Optional[torch.Tensor] = None, prompt_embeds: typing.Optional[torch.Tensor] = None, prompt_attention_mask: typing.Optional[torch.Tensor] = None, negative_prompt_embeds: typing.Optional[torch.Tensor] = None, negative_prompt_attention_mask: typing.Optional[torch.Tensor] = None, decode_timestep: float | list[float] = 0.0, decode_noise_scale: float | list[float] | None = None, output_type: str | None = 'pil', return_dict: bool = True, attention_kwargs: dict[str, typing.Any] | None = None, callback_on_step_end: typing.Optional[typing.Callable[[int, int], NoneType]] = None, callback_on_step_end_tensor_inputs: list[str] = ['latents'], max_sequence_length: int = 128)
```

[Sumber](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/pipelines/ltx/pipeline_ltx_image2video.py#L596)

**Parameter:**

image (`PipelineImageInput`) : Gambar input untuk mengondisikan generasi. Harus berupa gambar, daftar gambar, atau `torch.Tensor`.

prompt (`str` atau `list[str]`, *opsional*) : Prompt atau prompt-prompt untuk mengarahkan generasi gambar. Jika tidak didefinisikan, Anda harus melewatkan `prompt_embeds` sebagai gantinya.

negative_prompt (`str` atau `list[str]`, *opsional*) : Prompt atau prompt-prompt yang tidak akan memandu generasi gambar. Jika tidak didefinisikan, Anda harus meneruskan `negative_prompt_embeds` sebagai gantinya. Diabaikan saat tidak menggunakan panduan (`guidance_scale < 1`).

height (`int`, defaultnya `512`) : Tinggi gambar yang dihasilkan dalam piksel. Ini diatur ke 480 secara default untuk hasil terbaik.

width (`int`, defaultnya `704`) : Lebar gambar yang dihasilkan dalam piksel. Ini diatur ke 848 secara default untuk hasil terbaik.

num_frames (`int`, defaultnya `161`) : Jumlah bingkai video yang akan dihasilkan

frame_rate (`int`, defaultnya `25`) : Laju bingkai target dari video yang dihasilkan.

num_inference_steps (`int`, *opsional*, defaultnya 50) : Jumlah langkah denoising. Semakin banyak langkah denoising, biasanya menghasilkan gambar dengan kualitas lebih tinggi, namun dengan biaya inferensi yang lebih lambat.

timesteps (`list[int]`, *opsional*) : Timesteps kustom untuk digunakan dalam proses denoising dengan scheduler yang mendukung argumen `timesteps` di metode `set_timesteps` mereka. Jika tidak didefinisikan, perilaku default saat `num_inference_steps` diteruskan akan digunakan. Harus dalam urutan menurun.

guidance_scale (`float`, defaultnya `3 `) : Skala panduan seperti yang didefinisikan dalam [Classifier-Free Diffusion Guidance](https://huggingface.co/papers/2207.12598). `guidance_scale` didefinisikan sebagai `w` dari persamaan 2. pada [Imagen Paper](https://huggingface.co/papers/2205.11487). Skala panduan diaktifkan dengan mengatur `guidance_scale > 1`. Skala panduan yang lebih tinggi mendorong generasi gambar yang sangat terkait dengan `prompt` teks, biasanya dengan mengorbankan kualitas gambar yang lebih rendah.

guidance_rescale (`float`, *opsional*, default 0.0) : Faktor rescale guidance yang diusulkan oleh [Common Diffusion Noise Schedules and Sample Steps are Flawed](https://huggingface.co/papers/2305.08891) `guidance_scale` didefinisikan sebagai `φ` dalam persamaan 16. dari [Common Diffusion Noise Schedules and Sample Steps are Flawed](https://huggingface.co/papers/2305.08891). Faktor rescale guidance harus memperbaiki overexposure saat menggunakan zero terminal SNR.

num_videos_per_prompt (`int`, *opsional*, default 1) : Jumlah video yang akan dihasilkan per prompt.

generator (`torch.Generator` atau `list[torch.Generator]`, *opsional*) : Satu atau daftar [generator torch](https://pytorch.org/docs/stable/generated/torch.Generator.html) untuk membuat proses generasi menjadi deterministik.

latents (`torch.Tensor`, *opsional*) : Laten berisik yang telah dibuat sebelumnya, diambil dari distribusi Gaussian, untuk digunakan sebagai input untuk generasi gambar. Dapat digunakan untuk menyesuaikan generasi yang sama dengan prompt yang berbeda. Jika tidak disediakan, tensor laten akan dibuat dengan pengambilan sampel menggunakan `generator` acak yang diberikan.

prompt_embeds (`torch.Tensor`, *opsional*) : Embedding teks yang sudah dibuat sebelumnya. Dapat digunakan untuk dengan mudah menyesuaikan input teks, *misalnya* penimbangan prompt. Jika tidak disediakan, embedding teks akan dihasilkan dari argumen input `prompt`.

prompt_attention_mask (`torch.Tensor`, *opsional*) : Mask perhatian yang telah dibuat sebelumnya untuk embedding teks.

negative_prompt_embeds (`torch.FloatTensor`, *opsional*) : Embedding teks negatif yang telah dibuat sebelumnya. Untuk PixArt-Sigma, prompt negatif ini harus "". Jika tidak disediakan, negative_prompt_embeds akan dibuat dari argumen input `negative_prompt`.

negative_prompt_attention_mask (`torch.FloatTensor`, *opsional*) : Mask perhatian yang telah dibuat sebelumnya untuk embedding teks negatif.

decode_timestep (`float`, defaultnya `0.0`) : Timestep di mana video yang dihasilkan didekode.

decode_noise_scale (`float`, defaultnya `None`) : Faktor interpolasi antara noise acak dan latents yang telah dinoise pada timestep decode.

output_type (`str`, *opsional*, defaultnya `"pil"`) : Format output dari gambar yang dihasilkan. Pilih antara [PIL](https://pillow.readthedocs.io/en/stable/): `PIL.Image.Image` atau `np.array`.

return_dict (`bool`, *opsional*, defaultnya `True`) : Apakah akan mengembalikan `~pipelines.ltx.LTXPipelineOutput` alih-alih tuple biasa.

attention_kwargs (`dict`, *opsional*) : Kamus kwargs yang jika ditentukan akan diteruskan ke `AttentionProcessor` seperti yang didefinisikan di bawah `self.processor` dalam [diffusers.models.attention_processor](https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/attention_processor.py).

callback_on_step_end (`Callable`, *opsional*) : Fungsi yang dipanggil di akhir setiap langkah denoising selama inferensi. Fungsi ini dipanggil dengan argumen berikut: `callback_on_step_end(self: DiffusionPipeline, step: int, timestep: int, callback_kwargs: Dict)`. `callback_kwargs` akan berisi daftar semua tensor sesuai yang ditentukan oleh `callback_on_step_end_tensor_inputs`.

callback_on_step_end_tensor_inputs (`list`, *opsional*) : Daftar input tensor untuk fungsi `callback_on_step_end`. Tensor yang ditentukan dalam daftar akan diteruskan sebagai argumen `callback_kwargs`. Anda hanya dapat menyertakan variabel yang tercantum dalam atribut `._callback_tensor_inputs` dari kelas pipeline Anda.

max_sequence_length (`int` defaultnya `128 `) : Panjang maksimum urutan yang digunakan dengan `prompt`.

**Mengembalikan:** `~pipelines.ltx.LTXPipelineOutput` atau `tuple`

Jika `return_dict` adalah `True`, `~pipelines.ltx.LTXPipelineOutput` dikembalikan, selain itu sebuah `tuple` dikembalikan di mana elemen pertama adalah daftar dengan gambar yang dihasilkan.

Fungsi yang dipanggil saat memanggil pipeline untuk generasi.

Contoh:
```py
>>> import torch
>>> from diffusers import LTXImageToVideoPipeline
>>> from diffusers.utils import export_to_video, load_image

>>> pipe = LTXImageToVideoPipeline.from_pretrained("Lightricks/LTX-Video", torch_dtype=torch.bfloat16)
>>> pipe.to("cuda")

>>> image = load_image(
...     "https://huggingface.co/datasets/a-r-r-o-w/tiny-meme-dataset-captioned/resolve/main/images/8.png"
... )
>>> prompt = "A young girl stands calmly in the foreground, looking directly at the camera, as a house fire rages in the background. Flames engulf the structure, with smoke billowing into the air. Firefighters in protective gear rush to the scene, a fire truck labeled '38' visible behind them. The girl's neutral expression contrasts sharply with the chaos of the fire, creating a poignant and emotionally charged scene."
>>> negative_prompt = "worst quality, inconsistent motion, blurry, jittery, distorted"

>>> video = pipe(
...     image=image,
...     prompt=prompt,
...     negative_prompt=negative_prompt,
...     width=704,
...     height=480,
...     num_frames=161,
...     num_inference_steps=50,
... ).frames[0]
>>> export_to_video(video, "output.mp4", fps=24)
```

#### encode_prompt[[diffusers.LTXImageToVideoPipeline.encode_prompt]]

```python
encode_prompt(prompt: str | list[str], negative_prompt: str | list[str] | None = None, do_classifier_free_guidance: bool = True, num_videos_per_prompt: int = 1, prompt_embeds: typing.Optional[torch.Tensor] = None, negative_prompt_embeds: typing.Optional[torch.Tensor] = None, prompt_attention_mask: typing.Optional[torch.Tensor] = None, negative_prompt_attention_mask: typing.Optional[torch.Tensor] = None, max_sequence_length: int = 128, device: typing.Optional[torch.device] = None, dtype: typing.Optional[torch.dtype] = None)
```

[Sumber](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/pipelines/ltx/pipeline_ltx_image2video.py#L306)

**Parameter:**

prompt (`str` atau `list[str]`, *opsional*) : prompt yang akan dienkod

negative_prompt (`str` atau `list[str]`, *opsional*) : Prompt atau prompt-prompt yang tidak akan memandu generasi gambar. Jika tidak didefinisikan, Anda harus meneruskan `negative_prompt_embeds` sebagai gantinya. Diabaikan saat tidak menggunakan guidance (yaitu, diabaikan jika `guidance_scale` kurang dari `1`).

do_classifier_free_guidance (`bool`, *opsional*, defaultnya `True`) : Apakah akan menggunakan classifier free guidance atau tidak.

num_videos_per_prompt (`int`, *opsional*, default 1) : Jumlah video yang harus dihasilkan per prompt. perangkat torch untuk menempatkan embedding yang dihasilkan

prompt_embeds (`torch.Tensor`, *opsional*) : Embedding teks yang sudah dibuat sebelumnya. Dapat digunakan untuk dengan mudah menyesuaikan input teks, *misalnya* penimbangan prompt. Jika tidak disediakan, embedding teks akan dihasilkan dari argumen input `prompt`.

negative_prompt_embeds (`torch.Tensor`, *opsional*) : Embedding teks negatif yang telah dibuat sebelumnya. Dapat digunakan untuk dengan mudah menyesuaikan input teks, *misalnya* penimbangan prompt. Jika tidak disediakan, negative_prompt_embeds akan dibuat dari argumen input `negative_prompt`.

device : (`torch.device`, *opsional*): perangkat torch

dtype : (`torch.dtype`, *opsional*): torch dtype

Mengkodekan prompt menjadi hidden states dari text encoder.

## LTXConditionPipeline[[diffusers.LTXConditionPipeline]]

#### diffusers.LTXConditionPipeline[[diffusers.LTXConditionPipeline]]

```python
diffusers.LTXConditionPipeline(scheduler: FlowMatchEulerDiscreteScheduler, vae: AutoencoderKLLTXVideo, text_encoder: T5EncoderModel, tokenizer: T5Tokenizer, transformer: LTXVideoTransformer3DModel)
```

[Sumber](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/pipelines/ltx/pipeline_ltx_condition.py#L252)

**Parameter:**

transformer ([LTXVideoTransformer3DModel](/docs/diffusers/v0.43.0/id/api/models/ltx_video_transformer3d#diffusers.LTXVideoTransformer3DModel)) : Arsitektur Transformer bersyarat untuk mendenoise latens video yang telah dikodekan.

scheduler ([FlowMatchEulerDiscreteScheduler](/docs/diffusers/v0.43.0/id/api/schedulers/flow_match_euler_discrete#diffusers.FlowMatchEulerDiscreteScheduler)) : Penjadwal yang digunakan bersama `transformer` untuk menghilangkan noise pada latens gambar yang telah dikodekan.

vae ([AutoencoderKLLTXVideo](/docs/diffusers/v0.43.0/id/api/models/autoencoderkl_ltx_video#diffusers.AutoencoderKLLTXVideo)) : Model Variational Auto-Encoder (VAE) untuk mengodekan dan mendekodekan gambar ke dan dari representasi laten.

text_encoder (`T5EncoderModel`) : [T5](https://huggingface.co/docs/transformers/en/model_doc/t5#transformers.T5EncoderModel), khususnya varian [google/t5-v1_1-xxl](https://huggingface.co/google/t5-v1_1-xxl).

tokenizer (`CLIPTokenizer`) : Tokenizer dari kelas [CLIPTokenizer](https://huggingface.co/docs/transformers/en/model_doc/clip#transformers.CLIPTokenizer).

tokenizer (`T5TokenizerFast`) : Tokenizer kedua dari kelas [T5TokenizerFast](https://huggingface.co/docs/transformers/en/model_doc/t5#transformers.T5TokenizerFast).

Pipeline untuk generasi teks/gambar/video-ke-video.

Referensi: https://github.com/Lightricks/LTX-Video

#### __call__[[diffusers.LTXConditionPipeline.__call__]]

```python
__call__(conditions: diffusers.pipelines.ltx.pipeline_ltx_condition.LTXVideoCondition | list[diffusers.pipelines.ltx.pipeline_ltx_condition.LTXVideoCondition] = None, image: typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor], list[typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor]]]] = None, video: list[typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor]]] = None, frame_index: int | list[int] = 0, strength: float | list[float] = 1.0, denoise_strength: float = 1.0, prompt: str | list[str] = None, negative_prompt: str | list[str] | None = None, height: int = 512, width: int = 704, num_frames: int = 161, frame_rate: int = 25, num_inference_steps: int = 50, timesteps: list[int] = None, guidance_scale: float = 3, guidance_rescale: float = 0.0, image_cond_noise_scale: float = 0.15, num_videos_per_prompt: int | None = 1, generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = None, latents: typing.Optional[torch.Tensor] = None, prompt_embeds: typing.Optional[torch.Tensor] = None, prompt_attention_mask: typing.Optional[torch.Tensor] = None, negative_prompt_embeds: typing.Optional[torch.Tensor] = None, negative_prompt_attention_mask: typing.Optional[torch.Tensor] = None, decode_timestep: float | list[float] = 0.0, decode_noise_scale: float | list[float] | None = None, output_type: str | None = 'pil', return_dict: bool = True, attention_kwargs: dict[str, typing.Any] | None = None, callback_on_step_end: typing.Optional[typing.Callable[[int, int], NoneType]] = None, callback_on_step_end_tensor_inputs: list[str] = ['latents'], max_sequence_length: int = 256)
```

[Sumber](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/pipelines/ltx/pipeline_ltx_condition.py#L848)

**Parameter:**

conditions (`list[LTXVideoCondition], *optional*`) : Daftar item kondisioning frame untuk generasi video. Jika tidak disediakan, kondisi akan dibuat menggunakan `image`, `video`, `frame_index`, dan `strength`.

image (`PipelineImageInput` atau `list[PipelineImageInput]`, *opsional*) : Gambar atau beberapa gambar untuk mengondisikan generasi video. Jika tidak diberikan, Anda harus meneruskan `video` atau `conditions`.

video (`list[PipelineImageInput]`, *opsional*) : Video untuk mengondisikan generasi video. Jika tidak disediakan, Anda harus meneruskan `image` atau `conditions`.

frame_index (`int` atau `list[int]`, *opsional*) : Indeks frame atau indeks-indeks frame di mana gambar atau video akan secara kondisional memengaruhi generasi video. Jika tidak diberikan, Anda harus meneruskan `conditions`.

strength (`float` atau `list[float]`, *opsional*) : Kekuatan atau kekuatan-kekuatan efek kondisioning. Jika tidak diberikan, Anda harus meneruskan `conditions`.

denoise_strength (`float`, defaultnya `1.0`) : Kekuatan noise yang ditambahkan ke latents untuk editing. Kekuatan yang lebih tinggi menyebabkan lebih banyak noise ditambahkan ke latents, sehingga menghasilkan lebih banyak perbedaan antara video asli dan video yang dihasilkan. Ini berguna untuk editing video-ke-video.

prompt (`str` atau `list[str]`, *opsional*) : Prompt atau prompt-prompt untuk mengarahkan generasi gambar. Jika tidak didefinisikan, Anda harus melewatkan `prompt_embeds` sebagai gantinya.

negative_prompt (`str` atau `list[str]`, *opsional*) : Prompt atau prompt-prompt yang tidak akan memandu generasi gambar. Jika tidak didefinisikan, Anda harus meneruskan `negative_prompt_embeds` sebagai gantinya. Diabaikan saat tidak menggunakan panduan (`guidance_scale < 1`).

height (`int`, defaultnya `512`) : Tinggi gambar yang dihasilkan dalam piksel. Ini diatur ke 480 secara default untuk hasil terbaik.

width (`int`, defaultnya `704`) : Lebar gambar yang dihasilkan dalam piksel. Ini diatur ke 848 secara default untuk hasil terbaik.

num_frames (`int`, defaultnya `161`) : Jumlah bingkai video yang akan dihasilkan

frame_rate (`int`, defaultnya `25`) : Laju bingkai target dari video yang dihasilkan.

num_inference_steps (`int`, *opsional*, defaultnya 50) : Jumlah langkah denoising. Semakin banyak langkah denoising, biasanya menghasilkan gambar dengan kualitas lebih tinggi, namun dengan biaya inferensi yang lebih lambat.

timesteps (`list[int]`, *opsional*) : Timesteps kustom untuk digunakan dalam proses denoising dengan scheduler yang mendukung argumen `timesteps` di metode `set_timesteps` mereka. Jika tidak didefinisikan, perilaku default saat `num_inference_steps` diteruskan akan digunakan. Harus dalam urutan menurun.

guidance_scale (`float`, defaultnya `3 `) : Skala panduan seperti yang didefinisikan dalam [Classifier-Free Diffusion Guidance](https://huggingface.co/papers/2207.12598). `guidance_scale` didefinisikan sebagai `w` dari persamaan 2. pada [Imagen Paper](https://huggingface.co/papers/2205.11487). Skala panduan diaktifkan dengan mengatur `guidance_scale > 1`. Skala panduan yang lebih tinggi mendorong generasi gambar yang sangat terkait dengan `prompt` teks, biasanya dengan mengorbankan kualitas gambar yang lebih rendah.

guidance_rescale (`float`, *opsional*, default 0.0) : Faktor rescale guidance yang diusulkan oleh [Common Diffusion Noise Schedules and Sample Steps are Flawed](https://huggingface.co/papers/2305.08891) `guidance_scale` didefinisikan sebagai `φ` dalam persamaan 16. dari [Common Diffusion Noise Schedules and Sample Steps are Flawed](https://huggingface.co/papers/2305.08891). Faktor rescale guidance harus memperbaiki overexposure saat menggunakan zero terminal SNR.

image_cond_noise_scale (`float`, defaultnya `0.15`) : Skala noise yang ditambahkan ke latens gambar kondisional.

num_videos_per_prompt (`int`, *opsional*, default 1) : Jumlah video yang akan dihasilkan per prompt.

generator (`torch.Generator` atau `list[torch.Generator]`, *opsional*) : Satu atau daftar [generator torch](https://pytorch.org/docs/stable/generated/torch.Generator.html) untuk membuat proses generasi menjadi deterministik.

latents (`torch.Tensor`, *opsional*) : Laten berisik yang telah dibuat sebelumnya, diambil dari distribusi Gaussian, untuk digunakan sebagai input untuk generasi gambar. Dapat digunakan untuk menyesuaikan generasi yang sama dengan prompt yang berbeda. Jika tidak disediakan, tensor laten akan dibuat dengan pengambilan sampel menggunakan `generator` acak yang diberikan.

prompt_embeds (`torch.Tensor`, *opsional*) : Embedding teks yang sudah dibuat sebelumnya. Dapat digunakan untuk dengan mudah menyesuaikan input teks, *misalnya* penimbangan prompt. Jika tidak disediakan, embedding teks akan dihasilkan dari argumen input `prompt`.

prompt_attention_mask (`torch.Tensor`, *opsional*) : Mask perhatian yang telah dibuat sebelumnya untuk embedding teks.

negative_prompt_embeds (`torch.FloatTensor`, *opsional*) : Embedding teks negatif yang telah dibuat sebelumnya. Untuk PixArt-Sigma, prompt negatif ini harus "". Jika tidak disediakan, negative_prompt_embeds akan dibuat dari argumen input `negative_prompt`.

negative_prompt_attention_mask (`torch.FloatTensor`, *opsional*) : Mask perhatian yang telah dibuat sebelumnya untuk embedding teks negatif.

decode_timestep (`float`, defaultnya `0.0`) : Timestep di mana video yang dihasilkan didekode.

decode_noise_scale (`float`, defaultnya `None`) : Faktor interpolasi antara noise acak dan latents yang telah dinoise pada timestep decode.

output_type (`str`, *opsional*, defaultnya `"pil"`) : Format output dari gambar yang dihasilkan. Pilih antara [PIL](https://pillow.readthedocs.io/en/stable/): `PIL.Image.Image` atau `np.array`.

return_dict (`bool`, *opsional*, defaultnya `True`) : Apakah akan mengembalikan `~pipelines.ltx.LTXPipelineOutput` alih-alih tuple biasa.

attention_kwargs (`dict`, *opsional*) : Kamus kwargs yang jika ditentukan akan diteruskan ke `AttentionProcessor` seperti yang didefinisikan di bawah `self.processor` dalam [diffusers.models.attention_processor](https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/attention_processor.py).

callback_on_step_end (`Callable`, *opsional*) : Fungsi yang dipanggil di akhir setiap langkah denoising selama inferensi. Fungsi ini dipanggil dengan argumen berikut: `callback_on_step_end(self: DiffusionPipeline, step: int, timestep: int, callback_kwargs: Dict)`. `callback_kwargs` akan berisi daftar semua tensor sesuai yang ditentukan oleh `callback_on_step_end_tensor_inputs`.

callback_on_step_end_tensor_inputs (`list`, *opsional*) : Daftar input tensor untuk fungsi `callback_on_step_end`. Tensor yang ditentukan dalam daftar akan diteruskan sebagai argumen `callback_kwargs`. Anda hanya dapat menyertakan variabel yang tercantum dalam atribut `._callback_tensor_inputs` dari kelas pipeline Anda.

max_sequence_length (`int` defaultnya `128 `) : Panjang maksimum urutan yang digunakan dengan `prompt`.

**Mengembalikan:** `~pipelines.ltx.LTXPipelineOutput` atau `tuple`

Jika `return_dict` adalah `True`, `~pipelines.ltx.LTXPipelineOutput` dikembalikan, selain itu sebuah `tuple` dikembalikan di mana elemen pertama adalah daftar dengan gambar yang dihasilkan.

Fungsi yang dipanggil saat memanggil pipeline untuk generasi.

Contoh:
```py
>>> import torch
>>> from diffusers.pipelines.ltx.pipeline_ltx_condition import LTXConditionPipeline, LTXVideoCondition
>>> from diffusers.utils import export_to_video, load_video, load_image

>>> pipe = LTXConditionPipeline.from_pretrained("Lightricks/LTX-Video-0.9.5", torch_dtype=torch.bfloat16)
>>> pipe.to("cuda")

>>> # Load input image and video
>>> video = load_video(
...     "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cosmos/cosmos-video2world-input-vid.mp4"
... )
>>> image = load_image(
...     "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cosmos/cosmos-video2world-input.jpg"
... )

>>> # Create conditioning objects
>>> condition1 = LTXVideoCondition(
...     image=image,
...     frame_index=0,
... )
>>> condition2 = LTXVideoCondition(
...     video=video,
...     frame_index=80,
... )

>>> prompt = "The video depicts a long, straight highway stretching into the distance, flanked by metal guardrails. The road is divided into multiple lanes, with a few vehicles visible in the far distance. The surrounding landscape features dry, grassy fields on one side and rolling hills on the other. The sky is mostly clear with a few scattered clouds, suggesting a bright, sunny day. And then the camera switch to a winding mountain road covered in snow, with a single vehicle traveling along it. The road is flanked by steep, rocky cliffs and sparse vegetation. The landscape is characterized by rugged terrain and a river visible in the distance. The scene captures the solitude and beauty of a winter drive through a mountainous region."
>>> negative_prompt = "worst quality, inconsistent motion, blurry, jittery, distorted"

>>> # Generate video
>>> generator = torch.Generator("cuda").manual_seed(0)
>>> # Text-only conditioning is also supported without the need to pass `conditions`
>>> video = pipe(
...     conditions=[condition1, condition2],
...     prompt=prompt,
...     negative_prompt=negative_prompt,
...     width=768,
...     height=512,
...     num_frames=161,
...     num_inference_steps=40,
...     generator=generator,
... ).frames[0]

>>> export_to_video(video, "output.mp4", fps=24)
```

#### add_noise_to_image_conditioning_latents[[diffusers.LTXConditionPipeline.add_noise_to_image_conditioning_latents]]

```python
add_noise_to_image_conditioning_latents(t: float, init_latents: Tensor, latents: Tensor, noise_scale: float, conditioning_mask: Tensor, generator, eps = 1e-06)
```

[Sumber](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/pipelines/ltx/pipeline_ltx_condition.py#L646)

Tambahkan noise yang bergantung pada timestep ke latents hard-conditioning. Hal ini membantu menjaga kontinuitas gerakan, terutama ketika dikondisikan pada satu frame.

#### encode_prompt[[diffusers.LTXConditionPipeline.encode_prompt]]

```python
encode_prompt(prompt: str | list[str], negative_prompt: str | list[str] | None = None, do_classifier_free_guidance: bool = True, num_videos_per_prompt: int = 1, prompt_embeds: typing.Optional[torch.Tensor] = None, negative_prompt_embeds: typing.Optional[torch.Tensor] = None, prompt_attention_mask: typing.Optional[torch.Tensor] = None, negative_prompt_attention_mask: typing.Optional[torch.Tensor] = None, max_sequence_length: int = 256, device: typing.Optional[torch.device] = None, dtype: typing.Optional[torch.dtype] = None)
```

[Sumber](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/pipelines/ltx/pipeline_ltx_condition.py#L369)

**Parameter:**

prompt (`str` atau `list[str]`, *opsional*) : prompt yang akan dienkod

negative_prompt (`str` atau `list[str]`, *opsional*) : Prompt atau prompt-prompt yang tidak akan memandu generasi gambar. Jika tidak didefinisikan, Anda harus meneruskan `negative_prompt_embeds` sebagai gantinya. Diabaikan saat tidak menggunakan guidance (yaitu, diabaikan jika `guidance_scale` kurang dari `1`).

do_classifier_free_guidance (`bool`, *opsional*, defaultnya `True`) : Apakah akan menggunakan classifier free guidance atau tidak.

num_videos_per_prompt (`int`, *opsional*, default 1) : Jumlah video yang harus dihasilkan per prompt. perangkat torch untuk menempatkan embedding yang dihasilkan

prompt_embeds (`torch.Tensor`, *opsional*) : Embedding teks yang sudah dibuat sebelumnya. Dapat digunakan untuk dengan mudah menyesuaikan input teks, *misalnya* penimbangan prompt. Jika tidak disediakan, embedding teks akan dihasilkan dari argumen input `prompt`.

negative_prompt_embeds (`torch.Tensor`, *opsional*) : Embedding teks negatif yang telah dibuat sebelumnya. Dapat digunakan untuk dengan mudah menyesuaikan input teks, *misalnya* penimbangan prompt. Jika tidak disediakan, negative_prompt_embeds akan dibuat dari argumen input `negative_prompt`.

device : (`torch.device`, *opsional*): perangkat torch

dtype : (`torch.dtype`, *opsional*): torch dtype

Mengkodekan prompt menjadi hidden states dari text encoder.

#### trim_conditioning_sequence[[diffusers.LTXConditionPipeline.trim_conditioning_sequence]]

```python
trim_conditioning_sequence(start_frame: int, sequence_num_frames: int, target_num_frames: int)
```

[Sumber](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/pipelines/ltx/pipeline_ltx_condition.py#L629)

**Parameter:**

start_frame (int) : Nomor frame target dari frame pertama dalam urutan.

sequence_num_frames (int) : Jumlah frame dalam urutan.

target_num_frames (int) : Jumlah bingkai target dalam video yang dihasilkan.

**Mengembalikan:** `int`

panjang sekuens yang diperbarui

Potong urutan kondisioning menjadi jumlah frame yang diizinkan.

## LTXLatentUpsamplePipeline[[diffusers.LTXLatentUpsamplePipeline]]

#### diffusers.LTXLatentUpsamplePipeline[[diffusers.LTXLatentUpsamplePipeline]]

```python
diffusers.LTXLatentUpsamplePipeline(vae: AutoencoderKLLTXVideo, latent_upsampler: LTXLatentUpsamplerModel)
```

[Sumber](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/pipelines/ltx/pipeline_ltx_latent_upsample.py#L44)

#### __call__[[diffusers.LTXLatentUpsamplePipeline.__call__]]

```python
__call__(video: list[typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor]]] | None = None, height: int = 512, width: int = 704, latents: typing.Optional[torch.Tensor] = None, decode_timestep: float | list[float] = 0.0, decode_noise_scale: float | list[float] | None = None, adain_factor: float = 0.0, tone_map_compression_ratio: float = 0.0, generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = None, output_type: str | None = 'pil', return_dict: bool = True)
```

[Sumber](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/pipelines/ltx/pipeline_ltx_latent_upsample.py#L188)

**Parameter:**

video (`list[PipelineImageInput]`, *opsional*) : Bingkai video input untuk di-upsample. Saling eksklusif dengan `latents`.

height (`int`, defaultnya `512`) : Tinggi output yang di-upsample dalam piksel.

width (`int`, defaultnya `704`) : Lebar output yang di-upsample dalam piksel.

latents (`torch.Tensor`, *opsional*) : Laten video yang sudah di-encode sebelumnya untuk di-upsample. Saling eksklusif dengan `video`.

decode_timestep (`float` atau `list[float]`, defaultnya `0.0`) : Timestep di mana latents yang di-upsample di-decode.

decode_noise_scale (`float` atau `list[float]`, *opsional*) : Faktor interpolasi antara noise acak dan latents yang telah dinoise pada timestep decode.

adain_factor (`float`, defaultnya `0.0`) : Kekuatan pencocokan statistik AdaIN yang diterapkan pada latents yang di-upsample.

tone_map_compression_ratio (`float`, defaultnya `0.0`) : Rasio kompresi yang digunakan untuk tone mapping latens yang di-upsample. Harus berada dalam rentang [0, 1].

generator (`torch.Generator` atau `list[torch.Generator]`, *opsional*) : Sebuah [`torch.Generator`](https://pytorch.org/docs/stable/generated/torch.Generator.html) untuk membuat proses generasi menjadi deterministik.

output_type (`str`, *opsional*, defaultnya `"pil"`) : Format output dari video yang dihasilkan. Pilih antara `PIL.Image`, `np.array`, atau `latent`.

return_dict (`bool`, *opsional*, defaultnya `True`) : Apakah akan mengembalikan `~pipelines.ltx.LTXPipelineOutput` alih-alih tuple biasa.

**Mengembalikan:** `~pipelines.ltx.LTXPipelineOutput` atau `tuple`

`~pipelines.ltx.LTXPipelineOutput` jika `return_dict` bernilai True, selain itu berupa `tuple`. Saat mengembalikan tuple, elemen pertama adalah video yang di-upsample (atau latents jika `output_type="latent"`).

Fungsi yang dipanggil saat memanggil pipeline untuk upsampling laten.

#### adain_filter_latent[[diffusers.LTXLatentUpsamplePipeline.adain_filter_latent]]

```python
adain_filter_latent(latents: Tensor, reference_latents: Tensor, factor: float = 1.0)
```

[Sumber](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/pipelines/ltx/pipeline_ltx_latent_upsample.py#L94)

**Parameter:**

latents (`torch.Tensor`) : Laten input untuk dinormalisasi

reference_latents (`torch.Tensor`) : Latens referensi yang menyediakan statistik gaya.

factor (`float`) : Faktor pencampuran antara laten asli dan laten yang ditransformasi. Rentang: -10.0 hingga 10.0, Default: 1.0

**Mengembalikan:** `torch.Tensor`

Tensor laten yang ditransformasi

Menerapkan Adaptive Instance Normalization (AdaIN) ke tensor laten berdasarkan statistik dari tensor laten referensi.

#### tone_map_latents[[diffusers.LTXLatentUpsamplePipeline.tone_map_latents]]

```python
tone_map_latents(latents: Tensor, compression: float)
```

[Sumber](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/pipelines/ltx/pipeline_ltx_latent_upsample.py#L122)

**Parameter:**

latents : torch.Tensor Tensor laten input dengan bentuk arbitrer. Diperkirakan berada dalam kisaran [-1, 1] atau [0, 1].

compression : float Kekuatan kompresi dalam rentang [0, 1]. - 0.0: Tanpa tone-mapping (transformasi identitas) - 1.0: Efek kompresi penuh

**Mengembalikan:**

torch.Tensor Tensor laten yang telah di-tone-map dengan bentuk yang sama dengan input.

Menerapkan fungsi tone-mapping non-linear ke nilai laten untuk mengurangi rentang dinamisnya dengan cara yang halus secara perseptual menggunakan kompresi berbasis sigmoid.

Hal ini berguna untuk meregularisasi latens dengan varians tinggi atau untuk mengondisikan output selama generasi, terutama saat mengendalikan perilaku dinamis dengan faktor `compression`.

## LTXPipelineOutput[[diffusers.pipelines.ltx.pipeline_output.LTXPipelineOutput]]

#### diffusers.pipelines.ltx.pipeline_output.LTXPipelineOutput[[diffusers.pipelines.ltx.pipeline_output.LTXPipelineOutput]]

```python
diffusers.pipelines.ltx.pipeline_output.LTXPipelineOutput(frames: Tensor)
```

[Sumber](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/pipelines/ltx/pipeline_output.py#L9)

**Parameter:**

frames (`torch.Tensor`, `np.ndarray`, atau list[list[PIL.Image.Image]]) : daftar output video - Dapat berupa daftar bersarang dengan panjang `batch_size,` di mana setiap sub-daftar berisi urutan gambar PIL yang telah didenoise dengan panjang `num_frames.` Dapat juga berupa array NumPy atau tensor Torch dengan bentuk `(batch_size, num_frames, channels, height, width)`.

Kelas output untuk pipeline LTX.

