Diffusers documentation
LTX-Video
LTX-Video
LTX-Videoは、テキストや画像から高解像度動画を高速かつリアルタイムに生成するために設計された拡散トランスフォーマーです。LTX-Videoの主な特徴はVideo-VAEです。Video-VAEは、より高いピクセル対潜在変数の圧縮率(1:192)を備えており、これによりより効率的な動画データ処理とより高速な生成速度を実現します。生成過程で細部のディテールが失われるのをサポートし、防止するために、Video-VAEデコーダーは潜在変数からピクセルへの変換と最後のノイズ除去ステップを実行します。
すべてのオリジナルのLTX-Videoチェックポイントは、Lightricks組織の下で確認できます。
右側のサイドバーにあるLTX-Videoモデルをクリックすると、他の動画生成タスクの例をさらに確認できます。
以下の例では、メモリまたは推論速度に最適化されたビデオを生成する方法を示しています。
メモリ使用量の削減に関する詳細については、メモリ使用量の削減ガイドを参照してください。
以下のLTX-Videoモデルには、約10GBのVRAMが必要です。
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は初回に時間がかかりますが、以降のpipeline呼び出しは高速になります。Cachingにより、中間出力を保存して再利用することで、推論の高速化も期待できます。
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)注記
LTX-Videoリポジトリからの生成に関する推奨設定については、以下を参照してください。
- transformer、VAE、テキストエンコーダーの推奨される dtype は
torch.bfloat16です。VAE とテキストエンコーダーは、torch.float32またはtorch.float16でも使用できます。 - LTX-Videoのガイダンス蒸留版では、
guidance_scaleを1.0に設定してください。その他のモデルでは、guidance_scaleを5.0のように高い値に設定することで、良好な生成品質が得られます。 - タイムステップ対応のVAEバリアント(LTX-Video 0.9.1以降)では、
decode_timestepを0.05に、image_cond_noise_scaleを0.025に設定してください。 - 複数の条件付き画像や動画間の補間をサポートするバリアント(LTX-Video 0.9.5 以降)では、最適な結果を得るために、類似した画像や動画を使用してください。条件付き入力からの乖離は、生成された動画における急激な遷移を引き起こす可能性があります。
- transformer、VAE、テキストエンコーダーの推奨される dtype は
LTX-Video 0.9.7には、空間潜在アップスケーラーと13Bパラメータのtransformerが含まれています。推論時には、まず低解像度の動画を素早く生成し、その後、アップスケールして精錬します。
サンプルコードを表示
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)LTX-Video 0.9.7 の蒸留モデルは、生成速度を向上させるために、guidance と timestep が蒸留されています。良好な生成品質を得るには、
guidance_scaleを1.0に設定し、num_inference_stepsを4から10の範囲に設定する必要があります。また、最適な結果を得るには、以下のカスタム timesteps を使用してください。- アップスケーリングの準備としてベースモデルの推論を実行します:
[1000, 993, 987, 981, 975, 909, 725, 0.03]。 - アップスケーリング:
[1000, 909, 725, 421, 0]。
サンプルコードを表示
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)- アップスケーリングの準備としてベースモデルの推論を実行します:
LTX-Video 0.9.8 の蒸留モデルは、0.9.7 バリアントと類似しています。ガイダンスとタイムステップの蒸留が適用されており、上記と同様の推論コードを使用できます。このバージョンの改善点は、非常に長い動画の生成をサポートしていることです。また、
tone_map_compression_ratioパラメータを使用してトーンマッピングを適用し、生成された動画の品質を向上させることもサポートしています。0.6というデフォルト値の使用を推奨します。サンプルコードを表示
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は、load_lora_weights()によるLoRAをサポートしています。
サンプルコードを表示
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 supports loading from single files, such as GGUF checkpoints, with loaders.FromOriginalModelMixin.from_single_file() or loaders.FromSingleFileMixin.from_single_file().
サンプルコードを表示
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
class diffusers.LTXI2VLongMultiPromptPipeline
< source >( scheduler: FlowMatchEulerDiscreteSchedulervae: AutoencoderKLLTXVideotext_encoder: T5EncoderModeltokenizer: T5TokenizerFasttransformer: LTXVideoTransformer3DModel )
パラメータ
- transformer (LTXVideoTransformer3DModel) — エンコードされた動画の潜在変数(latents)をデノイズするための条件付き Transformer アーキテクチャ。
- scheduler(FlowMatchEulerDiscreteScheduler または
LTXEulerAncestralRFScheduler)—transformerと組み合わせて、エンコードされた画像の潜在変数(latents)のノイズ除去に使用するスケジューラです。 - vae (AutoencoderKLLTXVideo) — 画像を潜在表現にエンコードし、潜在表現からデコードするための変分オートエンコーダ (VAE) モデル。
- text_encoder (
T5EncoderModel) — 具体的には、T5 の google/t5-v1_1-xxl バリアントです。 - tokenizer (
T5TokenizerFast) — クラス T5TokenizerFast のトークナイザー。
ComfyUIと同等の機能を持つ、長時間のI2V(画像から動画)マルチプロンプトパイプライン。
主な機能:
- 時間方向のスライディングウィンドウサンプリングのみ(空間方向のH/Wシャーディングなし)、ウィンドウ間の自己回帰的フュージョン。
- ウィンドウごとのマルチプロンプトセグメンテーションと、ウィンドウの先頭でのスムーズな遷移。
- I2Vにおける、トークンごとのマスクによるファーストフレームのハード条件付け。
- 時間ウィンドウリングとVAEのタイルデコーディングによるVRAM制御。
参照: https://github.com/Lightricks/LTX-Video
__call__
< source >( prompt: str | list[str] = Nonenegative_prompt: str | list[str] | None = Noneprompt_segments: list[dict[str, Any]] | None = Noneheight: int = 512width: int = 704num_frames: int = 161frame_rate: float = 25guidance_scale: float = 1.0guidance_rescale: float = 0.0num_inference_steps: int | None = 8sigmas: list[float, torch.Tensor] | None = Nonegenerator: torch.Generator | list[torch.Generator] | None = Noneseed: int | None = 0cond_image: 'PIL.Image.Image' | torch.Tensor | None = Nonecond_strength: float = 0.5latents: torch.Tensor | None = Nonetemporal_tile_size: int = 80temporal_overlap: int = 24temporal_overlap_cond_strength: float = 0.5adain_factor: float = 0.25guidance_latents: torch.Tensor | None = Noneguiding_strength: float = 1.0negative_index_latents: torch.Tensor | None = Nonenegative_index_strength: float = 1.0skip_steps_sigma_threshold: float | None = 1decode_timestep: float | None = 0.05decode_noise_scale: float | None = 0.025decode_horizontal_tiles: int = 4decode_vertical_tiles: int = 4decode_overlap: int = 3output_type: str | None = 'latent'return_dict: bool = Trueattention_kwargs: dict[str, Any] | None = Nonecallback_on_step_end: Callable[[int, int], None] | None = Nonecallback_on_step_end_tensor_inputs: list[str] = ['latents']max_sequence_length: int = 128 ) → ~pipelines.ltx.LTXPipelineOutput or tuple
パラメータ
- prompt (
strまたはlist[str]、省略可能) — ウィンドウごとの正のテキストプロンプトです。単一の文字列に ’|’ が含まれている場合、バーで区切られた部分に分割されます。 - negative_prompt (
strまたはlist[str]、省略可) — 望ましくないコンテンツを抑制するためのネガティブプロンプトです。 - prompt_segments (
list[dict], 任意) — ウィンドウごとにプロンプトを上書きするための、{“start_window”, “end_window”, “text”} を持つセグメントのマッピング。 - height (
int、デフォルトは512) — 出力画像の高さ(ピクセル単位)です。32で割り切れる値である必要があります。 - width (
int、デフォルトは704) — 出力画像の幅(ピクセル単位)です。32で割り切れる値である必要があります。 - num_frames (
int、デフォルトは161) — 出力フレーム数(デコード後のピクセル空間での値)。 - frame_rate (
float、デフォルト値は25) — 秒あたりのフレーム数。video_coords内の時間座標を正規化するために使用されます。 - guidance_scale (
float、デフォルト値は1.0) — CFG スケール。1 より大きい値を設定すると、classifier-free guidance が有効になります。 - guidance_rescale (
float、デフォルト値は0.0) — CFG 下での露出過多を軽減するための任意のリスケール(rescale_noise_cfgを参照)。 - num_inference_steps (
int、任意、デフォルトは8) — ウィンドウごとのデノイジングステップ数。sigmasが指定されている場合は無視されます。 - sigmas (
list[float]またはtorch.Tensor、省略可) — ウィンドウごとの明示的なシグマスケジュールを設定します。設定されている場合、num_inference_stepsを上書きします。 - generator (
torch.Generatorまたはlist[torch.Generator]、任意) — 確率的性を制御します。リストは受け付けますが、最初の要素のみが使用されます(batch=1)。 - seed (
int、任意、デフォルトは0) — 指定された場合、グローバルな潜在変数用の共有ジェネレーターにシードを設定し、各時間ウィンドウに対してseed + w_startを用いたウィンドウローカルなジェネレーターを導出します。 - cond_image (
PIL.Image.Imageまたはtorch.Tensor、省略可) — 条件付け画像。cond_strength > 0の場合、トークンごとのマスクによってフレーム 0 を固定します。 - cond_strength (
float、デフォルトは0.5) — 最初のフレームのハード条件付けの強度です(cond_mask が小さいほど、保持が強くなります)。 - latents (
torch.Tensor, 任意) — 初期の潜在変数 [B, C_lat, F_lat, H_lat, W_lat]。None の場合、randn_tensorでサンプリングされます。 - temporal_tile_size (
int, デフォルトは80) — 時間方向のウィンドウサイズ(デコード済みフレーム数)。内部では VAE の時間方向圧縮率によってスケーリングされます。 - temporal_overlap (
int、デフォルトは24) — 連続するウィンドウ間の重複(デコード済みフレーム数)。内部では圧縮率によってスケーリングされます。 - temporal_overlap_cond_strength (
float、デフォルト値は0.5) — 新しいウィンドウの先頭に、直前のウィンドウの末尾の潜在変数を注入する際の強度。 - adain_factor (
float, デフォルトは0.25) — ウィンドウ間の整合性を保つための AdaIN 正規化の強さ(0 で無効化)。 - guidance_latents (
torch.Tensor, 省略可) — ウィンドウの先頭に注入される参照潜変数。以降のウィンドウでは、オーバーラップによって長さが調整されます。 - guiding_strength (
float、デフォルト値は1.0) —guidance_latentsへの注入強度。 - negative_index_latents (
torch.Tensor, 任意) — 「負のインデックス」のセマンティクスのために、ウィンドウの先頭に追加される単一フレームの潜在変数です。 - negative_index_strength (
float、デフォルト値は1.0) —negative_index_latentsへの注入強度です。 - skip_steps_sigma_threshold (
float、任意、デフォルトは1) — この閾値を超える sigma を持つステップをスキップします。 - decode_timestep (
float、任意、デフォルトは0.05) — デコード時のタイムステップ(VAE が timestep_conditioning をサポートする場合)。 - decode_noise_scale (
float、任意、デフォルトは0.025) — デコード時のノイズ混合スケール(VAE が timestep_conditioning をサポートする場合)。 - decode_horizontal_tiles (
int、デフォルトは4) — VAEデコード時の水平方向のタイル数です。 - decode_vertical_tiles (
int、デフォルトは4) — VAEデコード時の縦方向のタイル数です。 - decode_overlap (
int、デフォルトは3) — VAEデコード時に、タイル間のオーバーラップ量(潜在ピクセル単位)。 - output_type (
str, 任意、デフォルトは"latent") — 生成された動画の出力形式です。“latent”、“pt”、“np”、“pil” のいずれかを選択します。“latent” を指定した場合、デコードせずに潜在変数を返します。 - return_dict (
bool、任意、デフォルトはTrue) —~pipelines.ltx.LTXPipelineOutputを返すか、プレーンなタプルを返すかを指定します。 - attention_kwargs (
dict、省略可) — transformer に転送される追加の attention パラメータ。 - callback_on_step_end (
PipelineCallbackまたはMultiPipelineCallbacks、省略可) — ステップごとのコールバックフック。 - callback_on_step_end_tensor_inputs (
list[str]、デフォルトは["latents"]) — コールバックに渡す locals() のキー。 - max_sequence_length (
int、デフォルトは128) — プロンプトエンコード用のトークナイザーの最大長です。
戻り値
~pipelines.ltx.LTXPipelineOutput または tuple
return_dict が True の場合、~pipelines.ltx.LTXPipelineOutput が返され、それ以外の場合は tuple が返されます。このとき、最初の要素は生成されたフレームのリストです。出力形式は output_type に依存します。
- “latent”/“pt”:
torch.Tensor[B, C, F, H, W]。“latent”は正規化された潜在空間、“pt”はVAE出力空間です。 - “np”:
np.ndarray後処理済み。 - “pil”:
list[PIL.Image.Image]PIL画像のリスト。
時間方向のスライディングウィンドウとマルチプロンプトスケジューリングを用いて、画像から動画のシーケンスを生成します。
例:
>>> 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]形状: 潜在サイズ(自動生成の場合):
- F_lat = (num_frames - 1) // vae_temporal_compression_ratio + 1
- H_lat = height // vae_spatial_compression_ratio
- W_lat = width // vae_spatial_compression_ratio
注:
- シード設定:
seedが指定された場合、各時間ウィンドウはseed + w_startでシードされたローカルジェネレーターを使用します。一方、ジェネレーターが渡されていない場合、共有ジェネレーターはグローバル潜在変数のために一度だけシードされます。それ以外の場合は、渡されたジェネレーターが再利用されます。 - CFG: 任意の
guidance_rescaleを備えた、統一されたnoise_pred = uncond + w * (text - uncond)。 - メモリ: denoisingはフルフレームの予測を実行します(空間タイル分割なし)。デコードは、OOMを回避するためにタイル分割できます。
encode_prompt
< source >( prompt: str | list[str]negative_prompt: str | list[str] | None = Nonedo_classifier_free_guidance: bool = Truenum_videos_per_prompt: int = 1prompt_embeds: torch.Tensor | None = Nonenegative_prompt_embeds: torch.Tensor | None = Noneprompt_attention_mask: torch.Tensor | None = Nonenegative_prompt_attention_mask: torch.Tensor | None = Nonemax_sequence_length: int = 128device: torch.device | None = Nonedtype: torch.dtype | None = None )
パラメータ
- prompt (
strまたはlist[str]、省略可能) — エンコードするプロンプト - negative_prompt (
strまたはlist[str]、省略可) — 画像生成をガイドしないプロンプトです。未定義の場合、代わりにnegative_prompt_embedsを渡す必要があります。ガイダンスを使用していない場合は無視されます(guidance_scaleが1未満の場合は無視されます)。 - do_classifier_free_guidance (
bool、任意、デフォルトはTrue) — classifier free guidance を使用するかどうかを指定します。 - num_videos_per_prompt (
int、任意、デフォルトは 1) — プロンプトごとに生成する動画の数を指定します。結果の埋め込みを配置する torch デバイス - prompt_embeds (
torch.Tensor, 任意) — 事前に生成されたテキスト埋め込み。テキスト入力の調整、例えばプロンプトの重み付けなどを容易に行うために使用できます。指定されない場合、prompt入力引数からテキスト埋め込みが生成されます。 - negative_prompt_embeds (
torch.Tensor, 任意) — 事前に生成されたネガティブなテキスト埋め込みです。テキスト入力の調整、例えばプロンプトの重み付けなどを簡単に実行できます。指定されない場合、negative_prompt入力引数から negative_prompt_embeds が生成されます。 - device — (
torch.device、任意): torch デバイス - dtype — (
torch.dtype、省略可): torch の dtype
プロンプトをテキストエンコーダーの隠れ状態にエンコードします。
prepare_latents
< source >( batch_size: intnum_channels_latents: intheight: intwidth: intnum_frames: intdevice: torch.devicegenerator: torch.Generator | Nonedtype: torch.dtype = torch.float32latents: torch.Tensor | None = Nonecond_latents: torch.Tensor | None = Nonecond_strength: float = 0.0negative_index_latents: torch.Tensor | None = None )
ベースの潜在変数を準備し、必要に応じて最初のフレームの条件付け潜在変数を注入します。
vae_decode_tiled
< source >( latents: torch.Tensordecode_timestep: float | None = Nonedecode_noise_scale: float | None = Nonehorizontal_tiles: int = 4vertical_tiles: int = 4overlap: int = 3last_frame_fix: bool = Truegenerator: torch.Generator | None = Noneoutput_type: str = 'pt'auto_denormalize: bool = Truecompute_dtype: torch.dtype = torch.float32enable_vae_tiling: bool = False ) →
パラメータ
- latents — [B, C_latent, F_latent, H_latent, W_latent]
- decode_timestep — オプションのデコードタイムステップ(VAEがtimestep_conditioningをサポートしている場合のみ有効)
- decode_noise_scale — 任意のデコードノイズ補間(VAEがtimestep_conditioningをサポートしている場合のみ有効)
- horizontal_tiles, vertical_tiles — 横方向/縦方向のタイル数 (>= 1)
- overlap — 潜在空間でのオーバーラップ(潜在ピクセル単位、>= 0)
- last_frame_fix — 「最後のフレームを繰り返す」修正を有効にするかどうか
- generator — 乱数ジェネレーター(decode_noise_scale のノイズに使用)
- output_type — “latent” | “pt” | “np” | “pil”
- “latent”: 潜在変数をそのまま返します(下流処理に有用)
- “pt”: VAE出力空間のテンソルを返す
- “np”/“pil”: VideoProcessor.postprocess_video による後処理済み出力
- auto_denormalize — True の場合、
latentsに LTX のデノーマライズを内部で適用します(推奨) - compute_dtype — タイル融合時に使用される精度(デフォルトは float32。シームのぼやけを大幅に軽減します)
- enable_vae_tiling — True の場合、タイル分割を VAE の組み込み
tiled_decodeに委譲します(vae.use_tilingを設定します)。
戻り値
- output_type="latent" の場合
入力latentsをそのまま返します
- output_type="pt" の場合: [B, C, F, H, W] を返します(値はおおよそ [-1, 1] の範囲です)
- output_type=“np”/“pil”の場合: postprocess_videoを介して後処理された出力を返します
Diffusers スタイルで実装された、VAE ベースの空間タイルデコーディング(ComfyUI と同等)。
- 重なり合うタイルを線形フェザリングとブレンドにより処理し、継ぎ目を回避します。
- オプションの last_frame_fix: デコード前に最後の潜在フレームを複製し、末尾から time_scale_factor フレームを削除します。
- との注入をサポートします。
- デフォルトでは、「正規化された潜在変数」(ノイズ除去の出力)は内部でデノーマライズされます(auto_denormalize=True)。
- タイル融合は、ぼけや色ズレを軽減するために、compute_dtype(デフォルトは float32)で計算されます。
LTXPipeline
クラス diffusers.LTXPipeline
< source >( scheduler: FlowMatchEulerDiscreteSchedulervae: AutoencoderKLLTXVideotext_encoder: T5EncoderModeltokenizer: T5Tokenizertransformer: LTXVideoTransformer3DModel )
パラメータ
- transformer (LTXVideoTransformer3DModel) — エンコードされた動画の潜在変数(latents)をデノイズするための条件付き Transformer アーキテクチャ。
- scheduler (FlowMatchEulerDiscreteScheduler) —
transformerと組み合わせて、エンコードされた画像の潜在変数からノイズを除去するために使用するスケジューラ。 - vae (AutoencoderKLLTXVideo) — 画像を潜在表現にエンコードし、潜在表現からデコードするための変分オートエンコーダ (VAE) モデル。
- text_encoder (
T5EncoderModel) — 具体的には、T5 の google/t5-v1_1-xxl バリアントです。 - tokenizer (
CLIPTokenizer) — CLIPTokenizer クラスのトークナイザー。 - tokenizer (
T5TokenizerFast) — クラス T5TokenizerFast の 2 つ目の Tokenizer。
テキストから動画を生成するためのPipeline。
参照: https://github.com/Lightricks/LTX-Video
__call__
< source >( prompt: str | list[str] = Nonenegative_prompt: str | list[str] | None = Noneheight: int = 512width: int = 704num_frames: int = 161frame_rate: int = 25num_inference_steps: int = 50timesteps: list[int] = Noneguidance_scale: float = 3guidance_rescale: float = 0.0num_videos_per_prompt: int | None = 1generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = Nonelatents: typing.Optional[torch.Tensor] = Noneprompt_embeds: typing.Optional[torch.Tensor] = Noneprompt_attention_mask: typing.Optional[torch.Tensor] = Nonenegative_prompt_embeds: typing.Optional[torch.Tensor] = Nonenegative_prompt_attention_mask: typing.Optional[torch.Tensor] = Nonedecode_timestep: float | list[float] = 0.0decode_noise_scale: float | list[float] | None = Noneoutput_type: str | None = 'pil'return_dict: bool = Trueattention_kwargs: dict[str, typing.Any] | None = Nonecallback_on_step_end: typing.Optional[typing.Callable[[int, int], NoneType]] = Nonecallback_on_step_end_tensor_inputs: list[str] = ['latents']max_sequence_length: int = 128 ) → ~pipelines.ltx.LTXPipelineOutput or tuple
パラメータ
- prompt (
strまたはlist[str]、省略可) — 画像生成をガイドするためのプロンプトです。未定義の場合、代わりにprompt_embedsを渡す必要があります。 - negative_prompt (
strまたはlist[str]、省略可) — 画像生成をガイドしないプロンプトです。未定義の場合、代わりにnegative_prompt_embedsを渡す必要があります。guidance を使用していない場合(guidance_scale < 1)は無視されます。 - height (
int, デフォルトは512) — 生成される画像の高さ(ピクセル単位)です。最適な結果を得るため、デフォルトでは 480 に設定されています。 - width (
int, デフォルトは704) — 生成される画像の幅(ピクセル単位)です。最適な結果を得るため、デフォルトでは 848 に設定されています。 - num_frames (
int、デフォルトは161) — 生成する動画のフレーム数です。 - frame_rate (
int、デフォルトは25) — 生成される動画の目標フレームレートです。 - num_inference_steps (
int、任意、デフォルト値は 50)— デノイジングのステップ数です。デノイジングのステップ数を増やすと、推論速度が遅くなる代わりに、通常はより高品質な画像が得られます。 - timesteps (
list[int], 任意) —timesteps引数をサポートするスケジューラーのset_timestepsメソッドで、デノイジングプロセスに使用するカスタムタイムステップ。未定義の場合、num_inference_stepsが渡された際のデフォルトの動作が使用されます。降順で指定する必要があります。 - guidance_scale (
float、デフォルト値は3) — Classifier-Free Diffusion Guidance で定義されているガイダンススケールです。guidance_scaleは、Imagen Paper の数式 2 のwとして定義されています。guidance_scale > 1を設定することで、ガイダンススケールが有効になります。ガイダンススケールを高くすると、promptのテキストと密接に関連した画像の生成が促されますが、通常は画像の品質が低下する傾向があります。 - guidance_rescale (
float, optional, defaults to 0.0) — Guidance rescale factor proposed by Common Diffusion Noise Schedules and Sample Steps are Flawedguidance_scaleis defined asφin equation 16. of Common Diffusion Noise Schedules and Sample Steps are Flawed. Guidance rescale factor should fix overexposure when using zero terminal SNR. - num_videos_per_prompt (
int、任意、デフォルト値は 1) — 1 つのプロンプトごとに生成する動画の数です。 - generator (
torch.Generatorまたはlist[torch.Generator]、省略可) — 生成を決定論的にするためのtorch ジェネレーター1つまたはリスト。 - latents (
torch.Tensor, 任意) — 画像生成の入力として使用する、ガウス分布からサンプリングされた事前生成されたノイズ付き潜在変数。異なるプロンプトで同じ生成を調整するために使用できます。指定されない場合、指定されたランダムgeneratorを使用してサンプリングを行い、潜在変数テンソルが生成されます。 - prompt_embeds (
torch.Tensor, 任意) — 事前に生成されたテキスト埋め込み。テキスト入力の調整、例えばプロンプトの重み付けなどを容易に行うために使用できます。指定されない場合、prompt入力引数からテキスト埋め込みが生成されます。 - prompt_attention_mask (
torch.Tensor, 任意) — テキスト埋め込み用の事前生成されたアテンションマスク。 - negative_prompt_embeds (
torch.FloatTensor, 任意) — 事前に生成されたネガティブテキストの埋め込み。PixArt-Sigma の場合、このネガティブプロンプトは "" である必要があります。指定されない場合、negative_prompt入力引数から negative_prompt_embeds が生成されます。 - negative_prompt_attention_mask (
torch.FloatTensor, 任意) — ネガティブなテキスト埋め込み用の事前生成されたアテンションマスク。 - decode_timestep (
float、デフォルトは0.0) — 生成された動画がデコードされるタイムステップ。 - decode_noise_scale (
float、デフォルトはNone) — デコードタイムステップにおける、ランダムノイズとデノイズ済み潜在変数の間の補間係数です。 - output_type (
str、任意、デフォルトは"pil") — 画像生成の出力形式です。PIL:PIL.Image.Imageまたはnp.arrayから選択します。 - return_dict (
bool、任意、デフォルトはTrue) —~pipelines.ltx.LTXPipelineOutputを返すか、プレーンなタプルを返すかを指定します。 - attention_kwargs (
dict, 省略可) — 指定された場合、diffusers.models.attention_processor で定義されているself.processor内のAttentionProcessorに渡される kwargs 辞書です。 - callback_on_step_end (
Callable, 省略可) — 推論中の各デノイジングステップの終了時に呼び出される関数です。この関数は、以下の引数とともに呼び出されます:callback_on_step_end(self: DiffusionPipeline, step: int, timestep: int, callback_kwargs: Dict)。callback_kwargsには、callback_on_step_end_tensor_inputsで指定されたすべてのテンソルのリストが含まれます。 - callback_on_step_end_tensor_inputs (
list、任意) —callback_on_step_end関数へのテンソル入力の一覧です。このリストで指定されたテンソルは、callback_kwargs引数として渡されます。パイプラインクラスの._callback_tensor_inputs属性にリストされている変数のみを、このリストに含めることができます。 - max_sequence_length (
int、デフォルトは128) —promptに使用する最大シーケンス長。
戻り値
~pipelines.ltx.LTXPipelineOutput または tuple
return_dict が True の場合、~pipelines.ltx.LTXPipelineOutput が返され、それ以外の場合は tuple が返されます。このとき、最初の要素は生成された画像のリストです。
生成用のパイプラインを呼び出したときに実行される関数。
例:
>>> 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
< source >( prompt: str | list[str]negative_prompt: str | list[str] | None = Nonedo_classifier_free_guidance: bool = Truenum_videos_per_prompt: int = 1prompt_embeds: typing.Optional[torch.Tensor] = Nonenegative_prompt_embeds: typing.Optional[torch.Tensor] = Noneprompt_attention_mask: typing.Optional[torch.Tensor] = Nonenegative_prompt_attention_mask: typing.Optional[torch.Tensor] = Nonemax_sequence_length: int = 128device: typing.Optional[torch.device] = Nonedtype: typing.Optional[torch.dtype] = None )
パラメータ
- prompt (
strまたはlist[str]、省略可能) — エンコードするプロンプト - negative_prompt (
strまたはlist[str]、省略可) — 画像生成をガイドしないプロンプトです。未定義の場合、代わりにnegative_prompt_embedsを渡す必要があります。ガイダンスを使用していない場合は無視されます(guidance_scaleが1未満の場合は無視されます)。 - do_classifier_free_guidance (
bool、任意、デフォルトはTrue) — classifier free guidance を使用するかどうかを指定します。 - num_videos_per_prompt (
int、任意、デフォルトは 1) — プロンプトごとに生成する動画の数を指定します。結果の埋め込みを配置する torch デバイス - prompt_embeds (
torch.Tensor, 任意) — 事前に生成されたテキスト埋め込み。テキスト入力の調整、例えばプロンプトの重み付けなどを容易に行うために使用できます。指定されない場合、prompt入力引数からテキスト埋め込みが生成されます。 - negative_prompt_embeds (
torch.Tensor, 任意) — 事前に生成されたネガティブなテキスト埋め込みです。テキスト入力の調整、例えばプロンプトの重み付けなどを簡単に実行できます。指定されない場合、negative_prompt入力引数から negative_prompt_embeds が生成されます。 - device — (
torch.device、任意): torch デバイス - dtype — (
torch.dtype、省略可): torch の dtype
プロンプトをテキストエンコーダーの隠れ状態にエンコードします。
LTXImageToVideoPipeline
class diffusers.LTXImageToVideoPipeline
< source >( scheduler: FlowMatchEulerDiscreteSchedulervae: AutoencoderKLLTXVideotext_encoder: T5EncoderModeltokenizer: T5Tokenizertransformer: LTXVideoTransformer3DModel )
パラメータ
- transformer (LTXVideoTransformer3DModel) — エンコードされた動画の潜在変数(latents)をデノイズするための条件付き Transformer アーキテクチャ。
- scheduler (FlowMatchEulerDiscreteScheduler) —
transformerと組み合わせて、エンコードされた画像の潜在変数からノイズを除去するために使用するスケジューラ。 - vae (AutoencoderKLLTXVideo) — 画像を潜在表現にエンコードし、潜在表現からデコードするための変分オートエンコーダ (VAE) モデル。
- text_encoder (
T5EncoderModel) — 具体的には、T5 の google/t5-v1_1-xxl バリアントです。 - tokenizer (
CLIPTokenizer) — CLIPTokenizer クラスのトークナイザー。 - tokenizer (
T5TokenizerFast) — クラス T5TokenizerFast の 2 つ目の Tokenizer。
画像から動画への変換を行うPipeline。
参照: https://github.com/Lightricks/LTX-Video
__call__
< source >( image: typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor]] = Noneprompt: str | list[str] = Nonenegative_prompt: str | list[str] | None = Noneheight: int = 512width: int = 704num_frames: int = 161frame_rate: int = 25num_inference_steps: int = 50timesteps: list[int] = Noneguidance_scale: float = 3guidance_rescale: float = 0.0num_videos_per_prompt: int | None = 1generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = Nonelatents: typing.Optional[torch.Tensor] = Noneprompt_embeds: typing.Optional[torch.Tensor] = Noneprompt_attention_mask: typing.Optional[torch.Tensor] = Nonenegative_prompt_embeds: typing.Optional[torch.Tensor] = Nonenegative_prompt_attention_mask: typing.Optional[torch.Tensor] = Nonedecode_timestep: float | list[float] = 0.0decode_noise_scale: float | list[float] | None = Noneoutput_type: str | None = 'pil'return_dict: bool = Trueattention_kwargs: dict[str, typing.Any] | None = Nonecallback_on_step_end: typing.Optional[typing.Callable[[int, int], NoneType]] = Nonecallback_on_step_end_tensor_inputs: list[str] = ['latents']max_sequence_length: int = 128 ) → ~pipelines.ltx.LTXPipelineOutput or tuple
パラメータ
- image (
PipelineImageInput) — 生成を条件づけるための入力画像です。画像、画像のリスト、またはtorch.Tensorである必要があります。 - prompt (
strまたはlist[str]、省略可) — 画像生成をガイドするためのプロンプトです。未定義の場合、代わりにprompt_embedsを渡す必要があります。 - negative_prompt (
strまたはlist[str]、省略可) — 画像生成をガイドしないプロンプトです。未定義の場合、代わりにnegative_prompt_embedsを渡す必要があります。guidance を使用していない場合(guidance_scale < 1)は無視されます。 - height (
int, デフォルトは512) — 生成される画像の高さ(ピクセル単位)です。最適な結果を得るため、デフォルトでは 480 に設定されています。 - width (
int, デフォルトは704) — 生成される画像の幅(ピクセル単位)です。最適な結果を得るため、デフォルトでは 848 に設定されています。 - num_frames (
int、デフォルトは161) — 生成する動画のフレーム数です。 - frame_rate (
int、デフォルトは25) — 生成される動画の目標フレームレートです。 - num_inference_steps (
int、任意、デフォルト値は 50)— デノイジングのステップ数です。デノイジングのステップ数を増やすと、推論速度が遅くなる代わりに、通常はより高品質な画像が得られます。 - timesteps (
list[int], 任意) —timesteps引数をサポートするスケジューラーのset_timestepsメソッドで、デノイジングプロセスに使用するカスタムタイムステップ。未定義の場合、num_inference_stepsが渡された際のデフォルトの動作が使用されます。降順で指定する必要があります。 - guidance_scale (
float、デフォルト値は3) — Classifier-Free Diffusion Guidance で定義されているガイダンススケールです。guidance_scaleは、Imagen Paper の数式 2 のwとして定義されています。guidance_scale > 1を設定することで、ガイダンススケールが有効になります。ガイダンススケールを高くすると、promptのテキストと密接に関連した画像の生成が促されますが、通常は画像の品質が低下する傾向があります。 - guidance_rescale (
float, optional, defaults to 0.0) — Guidance rescale factor proposed by Common Diffusion Noise Schedules and Sample Steps are Flawedguidance_scaleis defined asφin equation 16. of Common Diffusion Noise Schedules and Sample Steps are Flawed. Guidance rescale factor should fix overexposure when using zero terminal SNR. - num_videos_per_prompt (
int、任意、デフォルト値は 1) — 1 つのプロンプトごとに生成する動画の数です。 - generator (
torch.Generatorまたはlist[torch.Generator]、省略可) — 生成を決定論的にするためのtorch ジェネレーター1つまたはリスト。 - latents (
torch.Tensor, 任意) — 画像生成の入力として使用する、ガウス分布からサンプリングされた事前生成されたノイズ付き潜在変数。異なるプロンプトで同じ生成を調整するために使用できます。指定されない場合、指定されたランダムgeneratorを使用してサンプリングを行い、潜在変数テンソルが生成されます。 - prompt_embeds (
torch.Tensor, 任意) — 事前に生成されたテキスト埋め込み。テキスト入力の調整、例えばプロンプトの重み付けなどを容易に行うために使用できます。指定されない場合、prompt入力引数からテキスト埋め込みが生成されます。 - prompt_attention_mask (
torch.Tensor, 任意) — テキスト埋め込み用の事前生成されたアテンションマスク。 - negative_prompt_embeds (
torch.FloatTensor, 任意) — 事前に生成されたネガティブテキストの埋め込み。PixArt-Sigma の場合、このネガティブプロンプトは "" である必要があります。指定されない場合、negative_prompt入力引数から negative_prompt_embeds が生成されます。 - negative_prompt_attention_mask (
torch.FloatTensor, 任意) — ネガティブなテキスト埋め込み用の事前生成されたアテンションマスク。 - decode_timestep (
float、デフォルトは0.0) — 生成された動画がデコードされるタイムステップ。 - decode_noise_scale (
float、デフォルトはNone) — デコードタイムステップにおける、ランダムノイズとデノイズ済み潜在変数の間の補間係数です。 - output_type (
str、任意、デフォルトは"pil") — 画像生成の出力形式です。PIL:PIL.Image.Imageまたはnp.arrayから選択します。 - return_dict (
bool、任意、デフォルトはTrue) —~pipelines.ltx.LTXPipelineOutputを返すか、プレーンなタプルを返すかを指定します。 - attention_kwargs (
dict, 省略可) — 指定された場合、diffusers.models.attention_processor で定義されているself.processor内のAttentionProcessorに渡される kwargs 辞書です。 - callback_on_step_end (
Callable, 省略可) — 推論中の各デノイジングステップの終了時に呼び出される関数です。この関数は、以下の引数とともに呼び出されます:callback_on_step_end(self: DiffusionPipeline, step: int, timestep: int, callback_kwargs: Dict)。callback_kwargsには、callback_on_step_end_tensor_inputsで指定されたすべてのテンソルのリストが含まれます。 - callback_on_step_end_tensor_inputs (
list、任意) —callback_on_step_end関数へのテンソル入力の一覧です。このリストで指定されたテンソルは、callback_kwargs引数として渡されます。パイプラインクラスの._callback_tensor_inputs属性にリストされている変数のみを、このリストに含めることができます。 - max_sequence_length (
int、デフォルトは128) —promptに使用する最大シーケンス長。
戻り値
~pipelines.ltx.LTXPipelineOutput または tuple
return_dict が True の場合、~pipelines.ltx.LTXPipelineOutput が返され、それ以外の場合は tuple が返されます。このとき、最初の要素は生成された画像のリストです。
生成用のパイプラインを呼び出したときに実行される関数。
例:
>>> 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
< source >( prompt: str | list[str]negative_prompt: str | list[str] | None = Nonedo_classifier_free_guidance: bool = Truenum_videos_per_prompt: int = 1prompt_embeds: typing.Optional[torch.Tensor] = Nonenegative_prompt_embeds: typing.Optional[torch.Tensor] = Noneprompt_attention_mask: typing.Optional[torch.Tensor] = Nonenegative_prompt_attention_mask: typing.Optional[torch.Tensor] = Nonemax_sequence_length: int = 128device: typing.Optional[torch.device] = Nonedtype: typing.Optional[torch.dtype] = None )
パラメータ
- prompt (
strまたはlist[str]、省略可能) — エンコードするプロンプト - negative_prompt (
strまたはlist[str]、省略可) — 画像生成をガイドしないプロンプトです。未定義の場合、代わりにnegative_prompt_embedsを渡す必要があります。ガイダンスを使用していない場合は無視されます(guidance_scaleが1未満の場合は無視されます)。 - do_classifier_free_guidance (
bool、任意、デフォルトはTrue) — classifier free guidance を使用するかどうかを指定します。 - num_videos_per_prompt (
int、任意、デフォルトは 1) — プロンプトごとに生成する動画の数を指定します。結果の埋め込みを配置する torch デバイス - prompt_embeds (
torch.Tensor, 任意) — 事前に生成されたテキスト埋め込み。テキスト入力の調整、例えばプロンプトの重み付けなどを容易に行うために使用できます。指定されない場合、prompt入力引数からテキスト埋め込みが生成されます。 - negative_prompt_embeds (
torch.Tensor, 任意) — 事前に生成されたネガティブなテキスト埋め込みです。テキスト入力の調整、例えばプロンプトの重み付けなどを簡単に実行できます。指定されない場合、negative_prompt入力引数から negative_prompt_embeds が生成されます。 - device — (
torch.device、任意): torch デバイス - dtype — (
torch.dtype、省略可): torch の dtype
プロンプトをテキストエンコーダーの隠れ状態にエンコードします。
LTXConditionPipeline
クラス diffusers.LTXConditionPipeline
< source >( scheduler: FlowMatchEulerDiscreteSchedulervae: AutoencoderKLLTXVideotext_encoder: T5EncoderModeltokenizer: T5Tokenizertransformer: LTXVideoTransformer3DModel )
パラメータ
- transformer (LTXVideoTransformer3DModel) — エンコードされた動画の潜在変数(latents)をデノイズするための条件付き Transformer アーキテクチャ。
- scheduler (FlowMatchEulerDiscreteScheduler) —
transformerと組み合わせて、エンコードされた画像の潜在変数からノイズを除去するために使用するスケジューラ。 - vae (AutoencoderKLLTXVideo) — 画像を潜在表現にエンコードし、潜在表現からデコードするための変分オートエンコーダ (VAE) モデル。
- text_encoder (
T5EncoderModel) — 具体的には、T5 の google/t5-v1_1-xxl バリアントです。 - tokenizer (
CLIPTokenizer) — CLIPTokenizer クラスのトークナイザー。 - tokenizer (
T5TokenizerFast) — クラス T5TokenizerFast の 2 つ目の Tokenizer。
テキスト/画像/動画から動画への変換を行うPipeline。
参照: https://github.com/Lightricks/LTX-Video
__call__
< source >( conditions: diffusers.pipelines.ltx.pipeline_ltx_condition.LTXVideoCondition | list[diffusers.pipelines.ltx.pipeline_ltx_condition.LTXVideoCondition] = Noneimage: 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]]]] = Nonevideo: list[typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor]]] = Noneframe_index: int | list[int] = 0strength: float | list[float] = 1.0denoise_strength: float = 1.0prompt: str | list[str] = Nonenegative_prompt: str | list[str] | None = Noneheight: int = 512width: int = 704num_frames: int = 161frame_rate: int = 25num_inference_steps: int = 50timesteps: list[int] = Noneguidance_scale: float = 3guidance_rescale: float = 0.0image_cond_noise_scale: float = 0.15num_videos_per_prompt: int | None = 1generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = Nonelatents: typing.Optional[torch.Tensor] = Noneprompt_embeds: typing.Optional[torch.Tensor] = Noneprompt_attention_mask: typing.Optional[torch.Tensor] = Nonenegative_prompt_embeds: typing.Optional[torch.Tensor] = Nonenegative_prompt_attention_mask: typing.Optional[torch.Tensor] = Nonedecode_timestep: float | list[float] = 0.0decode_noise_scale: float | list[float] | None = Noneoutput_type: str | None = 'pil'return_dict: bool = Trueattention_kwargs: dict[str, typing.Any] | None = Nonecallback_on_step_end: typing.Optional[typing.Callable[[int, int], NoneType]] = Nonecallback_on_step_end_tensor_inputs: list[str] = ['latents']max_sequence_length: int = 256 ) → ~pipelines.ltx.LTXPipelineOutput or tuple
パラメータ
- conditions (
list[LTXVideoCondition], *optional*) — 動画生成用のフレーム条件付けアイテムのリストです。指定しない場合、image、video、frame_index、strengthを使用して条件が作成されます。 - image (
PipelineImageInputまたはlist[PipelineImageInput]、省略可) — 動画生成の条件として使用する画像です。指定しない場合は、videoまたはconditionsを渡す必要があります。 - video (
list[PipelineImageInput]、省略可) — 動画生成の条件として使用する動画です。指定しない場合は、imageまたはconditionsを渡す必要があります。 - frame_index (
intまたはlist[int]、省略可) — 画像または動画が動画生成に条件として影響を与えるフレームのインデックス、またはインデックスのリストです。指定しない場合は、conditionsを渡す必要があります。 - strength (
floatまたはlist[float]、省略可) — 条件付け効果の強さです。指定しない場合、conditionsを渡す必要があります。 - denoise_strength (
float、デフォルト値は1.0) — 編集のために latents に加えるノイズの強度です。強度が高いほど latents に加えられるノイズが増え、元の動画と生成された動画の差が大きくなります。これは video-to-video 編集に有用です。 - prompt (
strまたはlist[str]、省略可) — 画像生成をガイドするためのプロンプトです。未定義の場合、代わりにprompt_embedsを渡す必要があります。 - negative_prompt (
strまたはlist[str]、省略可) — 画像生成をガイドしないプロンプトです。未定義の場合、代わりにnegative_prompt_embedsを渡す必要があります。guidance を使用していない場合(guidance_scale < 1)は無視されます。 - height (
int, デフォルトは512) — 生成される画像の高さ(ピクセル単位)です。最適な結果を得るため、デフォルトでは 480 に設定されています。 - width (
int, デフォルトは704) — 生成される画像の幅(ピクセル単位)です。最適な結果を得るため、デフォルトでは 848 に設定されています。 - num_frames (
int、デフォルトは161) — 生成する動画のフレーム数です。 - frame_rate (
int、デフォルトは25) — 生成される動画の目標フレームレートです。 - num_inference_steps (
int、任意、デフォルト値は 50)— デノイジングのステップ数です。デノイジングのステップ数を増やすと、推論速度が遅くなる代わりに、通常はより高品質な画像が得られます。 - timesteps (
list[int], 任意) —timesteps引数をサポートするスケジューラーのset_timestepsメソッドで、デノイジングプロセスに使用するカスタムタイムステップ。未定義の場合、num_inference_stepsが渡された際のデフォルトの動作が使用されます。降順で指定する必要があります。 - guidance_scale (
float、デフォルト値は3) — Classifier-Free Diffusion Guidance で定義されているガイダンススケールです。guidance_scaleは、Imagen Paper の数式 2 のwとして定義されています。guidance_scale > 1を設定することで、ガイダンススケールが有効になります。ガイダンススケールを高くすると、promptのテキストと密接に関連した画像の生成が促されますが、通常は画像の品質が低下する傾向があります。 - guidance_rescale (
float, optional, defaults to 0.0) — Guidance rescale factor proposed by Common Diffusion Noise Schedules and Sample Steps are Flawedguidance_scaleis defined asφin equation 16. of Common Diffusion Noise Schedules and Sample Steps are Flawed. Guidance rescale factor should fix overexposure when using zero terminal SNR. - image_cond_noise_scale (
float、デフォルト値は0.15) — 条件付き画像の潜在変数に追加されるノイズのスケール。 - num_videos_per_prompt (
int、任意、デフォルト値は 1) — 1 つのプロンプトごとに生成する動画の数です。 - generator (
torch.Generatorまたはlist[torch.Generator]、省略可) — 生成を決定論的にするためのtorch ジェネレーター1つまたはリスト。 - latents (
torch.Tensor, 任意) — 画像生成の入力として使用する、ガウス分布からサンプリングされた事前生成されたノイズ付き潜在変数。異なるプロンプトで同じ生成を調整するために使用できます。指定されない場合、指定されたランダムgeneratorを使用してサンプリングを行い、潜在変数テンソルが生成されます。 - prompt_embeds (
torch.Tensor, 任意) — 事前に生成されたテキスト埋め込み。テキスト入力の調整、例えばプロンプトの重み付けなどを容易に行うために使用できます。指定されない場合、prompt入力引数からテキスト埋め込みが生成されます。 - prompt_attention_mask (
torch.Tensor, 任意) — テキスト埋め込み用の事前生成されたアテンションマスク。 - negative_prompt_embeds (
torch.FloatTensor, 任意) — 事前に生成されたネガティブテキストの埋め込み。PixArt-Sigma の場合、このネガティブプロンプトは "" である必要があります。指定されない場合、negative_prompt入力引数から negative_prompt_embeds が生成されます。 - negative_prompt_attention_mask (
torch.FloatTensor, 任意) — ネガティブなテキスト埋め込み用の事前生成されたアテンションマスク。 - decode_timestep (
float、デフォルトは0.0) — 生成された動画がデコードされるタイムステップ。 - decode_noise_scale (
float、デフォルトはNone) — デコードタイムステップにおける、ランダムノイズとデノイズ済み潜在変数の間の補間係数です。 - output_type (
str、任意、デフォルトは"pil") — 画像生成の出力形式です。PIL:PIL.Image.Imageまたはnp.arrayから選択します。 - return_dict (
bool、任意、デフォルトはTrue) —~pipelines.ltx.LTXPipelineOutputを返すか、プレーンなタプルを返すかを指定します。 - attention_kwargs (
dict, 省略可) — 指定された場合、diffusers.models.attention_processor で定義されているself.processor内のAttentionProcessorに渡される kwargs 辞書です。 - callback_on_step_end (
Callable, 省略可) — 推論中の各デノイジングステップの終了時に呼び出される関数です。この関数は、以下の引数とともに呼び出されます:callback_on_step_end(self: DiffusionPipeline, step: int, timestep: int, callback_kwargs: Dict)。callback_kwargsには、callback_on_step_end_tensor_inputsで指定されたすべてのテンソルのリストが含まれます。 - callback_on_step_end_tensor_inputs (
list、任意) —callback_on_step_end関数へのテンソル入力の一覧です。このリストで指定されたテンソルは、callback_kwargs引数として渡されます。パイプラインクラスの._callback_tensor_inputs属性にリストされている変数のみを、このリストに含めることができます。 - max_sequence_length (
int、デフォルトは128) —promptに使用する最大シーケンス長。
戻り値
~pipelines.ltx.LTXPipelineOutput または tuple
return_dict が True の場合、~pipelines.ltx.LTXPipelineOutput が返され、それ以外の場合は tuple が返されます。このとき、最初の要素は生成された画像のリストです。
生成用のパイプラインを呼び出したときに実行される関数。
例:
>>> 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
< source >( t: floatinit_latents: Tensorlatents: Tensornoise_scale: floatconditioning_mask: Tensorgeneratoreps = 1e-06 )
ハード条件付けの潜在変数に、タイムステップに依存するノイズを追加します。これにより、特に単一のフレームで条件付けを行う場合のモーションの連続性が向上します。
encode_prompt
< source >( prompt: str | list[str]negative_prompt: str | list[str] | None = Nonedo_classifier_free_guidance: bool = Truenum_videos_per_prompt: int = 1prompt_embeds: typing.Optional[torch.Tensor] = Nonenegative_prompt_embeds: typing.Optional[torch.Tensor] = Noneprompt_attention_mask: typing.Optional[torch.Tensor] = Nonenegative_prompt_attention_mask: typing.Optional[torch.Tensor] = Nonemax_sequence_length: int = 256device: typing.Optional[torch.device] = Nonedtype: typing.Optional[torch.dtype] = None )
パラメータ
- prompt (
strまたはlist[str]、省略可能) — エンコードするプロンプト - negative_prompt (
strまたはlist[str]、省略可) — 画像生成をガイドしないプロンプトです。未定義の場合、代わりにnegative_prompt_embedsを渡す必要があります。ガイダンスを使用していない場合は無視されます(guidance_scaleが1未満の場合は無視されます)。 - do_classifier_free_guidance (
bool、任意、デフォルトはTrue) — classifier free guidance を使用するかどうかを指定します。 - num_videos_per_prompt (
int、任意、デフォルトは 1) — プロンプトごとに生成する動画の数を指定します。結果の埋め込みを配置する torch デバイス - prompt_embeds (
torch.Tensor, 任意) — 事前に生成されたテキスト埋め込み。テキスト入力の調整、例えばプロンプトの重み付けなどを容易に行うために使用できます。指定されない場合、prompt入力引数からテキスト埋め込みが生成されます。 - negative_prompt_embeds (
torch.Tensor, 任意) — 事前に生成されたネガティブなテキスト埋め込みです。テキスト入力の調整、例えばプロンプトの重み付けなどを簡単に実行できます。指定されない場合、negative_prompt入力引数から negative_prompt_embeds が生成されます。 - device — (
torch.device、任意): torch デバイス - dtype — (
torch.dtype、省略可): torch の dtype
プロンプトをテキストエンコーダーの隠れ状態にエンコードします。
trim_conditioning_sequence
< source >( start_frame: intsequence_num_frames: inttarget_num_frames: int ) → int
条件付けシーケンスを許可されたフレーム数にトリムします。
LTXLatentUpsamplePipeline
class diffusers.LTXLatentUpsamplePipeline
< source >( vae: AutoencoderKLLTXVideolatent_upsampler: LTXLatentUpsamplerModel )
__call__
< source >( video: list[typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor]]] | None = Noneheight: int = 512width: int = 704latents: typing.Optional[torch.Tensor] = Nonedecode_timestep: float | list[float] = 0.0decode_noise_scale: float | list[float] | None = Noneadain_factor: float = 0.0tone_map_compression_ratio: float = 0.0generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = Noneoutput_type: str | None = 'pil'return_dict: bool = True ) → ~pipelines.ltx.LTXPipelineOutput or tuple
パラメータ
- video (
list[PipelineImageInput]、任意) — アップサンプリングする入力動画フレーム。latentsとは排他的です。 - height (
int、デフォルトは512) — アップサンプルされた出力のピクセル単位の縦幅です。 - width (
int, デフォルトは704) — アップサンプルされた出力の幅(ピクセル単位)。 - latents (
torch.Tensor, 任意) — アップサンプリングする事前エンコード済み動画の潜在変数。videoとは排他です。 - decode_timestep (
floatまたはlist[float]、デフォルトは0.0) — アップサンプルされた潜在変数がデコードされるタイムステップです。 - decode_noise_scale (
floatまたはlist[float]、省略可) — デコードタイムステップにおける、ランダムノイズとデノイズ済み潜在変数の間の補間係数です。 - adain_factor (
float, デフォルトは0.0) — アップサンプリングされた潜在変数に適用される AdaIN 統計マッチングの強度。 - tone_map_compression_ratio (
float、デフォルト値は0.0) — アップサンプリングされた潜在変数に対するトーンマッピングに使用される圧縮比です。値は [0, 1] の範囲である必要があります。 - generator (
torch.Generatorまたはlist[torch.Generator]、省略可) — 生成を決定論的にするためのtorch.Generator。 - output_type (
str、任意、デフォルトは"pil") — 生成された動画の出力形式です。PIL.Image、np.array、またはlatentから選択してください。 - return_dict (
bool、任意、デフォルトはTrue) —~pipelines.ltx.LTXPipelineOutputを返すか、プレーンなタプルを返すかを指定します。
戻り値
~pipelines.ltx.LTXPipelineOutput または tuple
return_dict が True の場合は ~pipelines.ltx.LTXPipelineOutput、それ以外の場合は tuple を返します。タプルを返す場合、最初の要素はアップサンプリングされた動画(output_type="latent" の場合は潜在変数)です。
潜在アップサンプリングのためにパイプラインを呼び出した際に実行される関数。
adain_filter_latent
< source >( latents: Tensorreference_latents: Tensorfactor: float = 1.0 ) → torch.Tensor
参照潜在テンソルの統計量に基づいて、潜在テンソルに Adaptive Instance Normalization (AdaIN) を適用します。
tone_map_latents
< source >( latents: Tensorcompression: float )
シグモイドベースの圧縮を用いて、知覚的に滑らかな方法で潜在値のダイナミックレンジを低減するために、非線形トーンマッピング関数を潜在値に適用します。
これは、compression 係数を用いて動的な挙動を制御する場合、特に生成時の出力を条件付けたり、高分散の潜在変数を正則化したりする際に有用です。
LTXPipelineOutput
クラス diffusers.pipelines.ltx.pipeline_output.LTXPipelineOutput
< source >( frames: Tensor )
LTX パイプライン用の出力クラスです。