Buckets:
Apache License, Version 2.0(「ライセンス」)の下でライセンスされています。
このファイルは、ライセンスに準拠した場合にのみ使用できます。
ライセンスのコピーは以下から入手できます
http://www.apache.org/licenses/LICENSE-2.0
適用される法律で要求される場合、または書面による合意がある場合を除き、ソフトウェア
ライセンスに基づき配布される本ソフトウェアは、「現状のまま」
明示的または黙示的を問わず、いかなる種類の保証や条件も付随しません。
権限を管理する特定の言語については、ライセンスを参照してください。
ライセンスの下での制限。-->
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[[diffusers.LTXI2VLongMultiPromptPipeline]]
diffusers.LTXI2VLongMultiPromptPipeline[[diffusers.LTXI2VLongMultiPromptPipeline]]
diffusers.LTXI2VLongMultiPromptPipeline(scheduler: FlowMatchEulerDiscreteScheduler, vae: AutoencoderKLLTXVideo, text_encoder: T5EncoderModel, tokenizer: T5TokenizerFast, transformer: LTXVideoTransformer3DModel)
パラメータ:
transformer (LTXVideoTransformer3DModel) : エンコードされた動画の潜在変数をノイズ除去するための条件付き Transformer アーキテクチャ。
scheduler (FlowMatchEulerDiscreteScheduler または LTXEulerAncestralRFScheduler) : transformer と組み合わせて、エンコードされた画像の潜在変数からノイズを除去するために使用するスケジューラ。
vae (AutoencoderKLLTXVideo) : 画像を潜在表現にエンコードし、潜在表現からデコードするための Variational Auto-Encoder (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[[diffusers.LTXI2VLongMultiPromptPipeline.call]]
__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)
パラメータ:
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、任意) : ウィンドウごとの明示的な sigma スケジュール。設定されている場合、num_inference_steps を上書きします。
generator (torch.Generator または list[torch.Generator]、任意) : 確率的性を制御します。リストは受け入れられますが、バッチサイズが 1 のため最初の要素のみが使用されます。
seed (int、optional、デフォルトは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) : プロンプトエンコード用のTokenizerの最大長。
戻り値: ~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[[diffusers.LTXI2VLongMultiPromptPipeline.encode_prompt]]
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)
パラメータ:
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、optional、デフォルトは 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[[diffusers.LTXI2VLongMultiPromptPipeline.prepare_latents]]
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)
戻り値:
latents, negative_index_latents, latent_num_frames, latent_height, latent_width
ベースの潜在変数を準備し、必要に応じて最初のフレームの条件付け潜在変数を注入します。
vae_decode_tiled[[diffusers.LTXI2VLongMultiPromptPipeline.vae_decode_tiled]]
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)
パラメータ:
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 を設定します)。
戻り値: - If 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]]
diffusers.LTXPipeline[[diffusers.LTXPipeline]]
diffusers.LTXPipeline(scheduler: FlowMatchEulerDiscreteScheduler, vae: AutoencoderKLLTXVideo, text_encoder: T5EncoderModel, tokenizer: T5Tokenizer, transformer: LTXVideoTransformer3DModel)
パラメータ:
transformer (LTXVideoTransformer3DModel) : エンコードされた動画の潜在変数をノイズ除去するための条件付き Transformer アーキテクチャ。
scheduler (FlowMatchEulerDiscreteScheduler) : transformer と組み合わせて、エンコードされた画像の潜在変数をデノイズするために使用するスケジューラー。
vae (AutoencoderKLLTXVideo) : 画像を潜在表現にエンコードし、潜在表現からデコードするための Variational Auto-Encoder (VAE) モデル。
text_encoder (T5EncoderModel) : T5、具体的には google/t5-v1_1-xxl バリアントです。
tokenizer (CLIPTokenizer) : クラス CLIPTokenizer の Tokenizer。
tokenizer (T5TokenizerFast) : クラス T5TokenizerFast の2番目の Tokenizer。
テキストから動画を生成するためのPipeline。
参考: https://github.com/Lightricks/LTX-Video
call[[diffusers.LTXPipeline.call]]
__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)
パラメータ:
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]、任意) : set_timesteps メソッドで 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 Flawed guidance_scale is 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、optional、デフォルトは 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[[diffusers.LTXPipeline.encode_prompt]]
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)
パラメータ:
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、optional、デフォルトは 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[[diffusers.LTXImageToVideoPipeline]]
diffusers.LTXImageToVideoPipeline[[diffusers.LTXImageToVideoPipeline]]
diffusers.LTXImageToVideoPipeline(scheduler: FlowMatchEulerDiscreteScheduler, vae: AutoencoderKLLTXVideo, text_encoder: T5EncoderModel, tokenizer: T5Tokenizer, transformer: LTXVideoTransformer3DModel)
パラメータ:
transformer (LTXVideoTransformer3DModel) : エンコードされた動画の潜在変数をノイズ除去するための条件付き Transformer アーキテクチャ。
scheduler (FlowMatchEulerDiscreteScheduler) : transformer と組み合わせて、エンコードされた画像の潜在変数をデノイズするために使用するスケジューラー。
vae (AutoencoderKLLTXVideo) : 画像を潜在表現にエンコードし、潜在表現からデコードするための Variational Auto-Encoder (VAE) モデル。
text_encoder (T5EncoderModel) : T5、具体的には google/t5-v1_1-xxl バリアントです。
tokenizer (CLIPTokenizer) : クラス CLIPTokenizer の Tokenizer。
tokenizer (T5TokenizerFast) : クラス T5TokenizerFast の2番目の Tokenizer。
画像から動画への変換を行うPipeline。
参考: https://github.com/Lightricks/LTX-Video
call[[diffusers.LTXImageToVideoPipeline.call]]
__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)
パラメータ:
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]、任意) : set_timesteps メソッドで 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 Flawed guidance_scale is 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、optional、デフォルトは 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[[diffusers.LTXImageToVideoPipeline.encode_prompt]]
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)
パラメータ:
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、optional、デフォルトは 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]]
diffusers.LTXConditionPipeline[[diffusers.LTXConditionPipeline]]
diffusers.LTXConditionPipeline(scheduler: FlowMatchEulerDiscreteScheduler, vae: AutoencoderKLLTXVideo, text_encoder: T5EncoderModel, tokenizer: T5Tokenizer, transformer: LTXVideoTransformer3DModel)
パラメータ:
transformer (LTXVideoTransformer3DModel) : エンコードされた動画の潜在変数をノイズ除去するための条件付き Transformer アーキテクチャ。
scheduler (FlowMatchEulerDiscreteScheduler) : transformer と組み合わせて、エンコードされた画像の潜在変数をデノイズするために使用するスケジューラー。
vae (AutoencoderKLLTXVideo) : 画像を潜在表現にエンコードし、潜在表現からデコードするための Variational Auto-Encoder (VAE) モデル。
text_encoder (T5EncoderModel) : T5、具体的には google/t5-v1_1-xxl バリアントです。
tokenizer (CLIPTokenizer) : クラス CLIPTokenizer の Tokenizer。
tokenizer (T5TokenizerFast) : クラス T5TokenizerFast の2番目の Tokenizer。
テキスト/画像/動画から動画への変換を行うPipeline。
参考: https://github.com/Lightricks/LTX-Video
call[[diffusers.LTXConditionPipeline.call]]
__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)
パラメータ:
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]、任意) : set_timesteps メソッドで 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 Flawed guidance_scale is 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、optional、デフォルトは 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[[diffusers.LTXConditionPipeline.add_noise_to_image_conditioning_latents]]
add_noise_to_image_conditioning_latents(t: float, init_latents: Tensor, latents: Tensor, noise_scale: float, conditioning_mask: Tensor, generator, eps = 1e-06)
ハード条件付けの潜在変数に、タイムステップに依存するノイズを追加します。これにより、特に単一のフレームを条件として与える場合のモーションの連続性が向上します。
encode_prompt[[diffusers.LTXConditionPipeline.encode_prompt]]
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)
パラメータ:
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、optional、デフォルトは 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[[diffusers.LTXConditionPipeline.trim_conditioning_sequence]]
trim_conditioning_sequence(start_frame: int, sequence_num_frames: int, target_num_frames: int)
パラメータ:
start_frame (int) : シーケンス内の最初のフレームのターゲットフレーム番号。
sequence_num_frames (int) : シーケンス内のフレーム数。
target_num_frames (int) : 生成される動画のフレーム数。
戻り値: int
更新されたシーケンス長
条件付けシーケンスを許可されたフレーム数にトリムします。
LTXLatentUpsamplePipeline[[diffusers.LTXLatentUpsamplePipeline]]
diffusers.LTXLatentUpsamplePipeline[[diffusers.LTXLatentUpsamplePipeline]]
diffusers.LTXLatentUpsamplePipeline(vae: AutoencoderKLLTXVideo, latent_upsampler: LTXLatentUpsamplerModel)
call[[diffusers.LTXLatentUpsamplePipeline.call]]
__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)
パラメータ:
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 を返します。tuple を返す場合、最初の要素はアップサンプリングされた動画(output_type="latent" の場合は潜在変数)です。
潜在アップサンプリングのためにパイプラインを呼び出した際に実行される関数。
adain_filter_latent[[diffusers.LTXLatentUpsamplePipeline.adain_filter_latent]]
adain_filter_latent(latents: Tensor, reference_latents: Tensor, factor: float = 1.0)
パラメータ:
latents (torch.Tensor) : 正規化対象の入力潜在変数
reference_latents (torch.Tensor) : スタイル統計を提供する参照潜在変数。
factor (float) : 元の潜在変数と変換後の潜在変数の間のブレンド係数。範囲: -10.0 から 10.0、デフォルト: 1.0
戻り値: torch.Tensor
変換された潜在テンソル
参照潜在テンソルの統計量に基づいて、潜在テンソルに Adaptive Instance Normalization (AdaIN) を適用します。
tone_map_latents[[diffusers.LTXLatentUpsamplePipeline.tone_map_latents]]
tone_map_latents(latents: Tensor, compression: float)
パラメータ:
latents : torch.Tensor 任意の形状を持つ入力潜在テンソル。おおよそ [-1, 1] または [0, 1] の範囲にあることが期待されます。
compression : float 圧縮の強さ。範囲は [0, 1] です。 - 0.0: トーンマッピングなし(恒等変換) - 1.0: 完全な圧縮効果
戻り値:
torch.Tensor 入力と同じ形状の、トーンマッピングされた潜在テンソル。
シグモイドベースの圧縮を用いて、潜在値のダイナミックレンジを知覚的に滑らかに低減するために、非線形トーンマッピング関数を潜在値に適用します。
compression 係数を用いて動的な挙動を制御する場合など、生成時の出力を条件付けたり、高分散な潜在変数を正則化したりする際に有用です。
LTXPipelineOutput[[diffusers.pipelines.ltx.pipeline_output.LTXPipelineOutput]]
diffusers.pipelines.ltx.pipeline_output.LTXPipelineOutput[[diffusers.pipelines.ltx.pipeline_output.LTXPipelineOutput]]
diffusers.pipelines.ltx.pipeline_output.LTXPipelineOutput(frames: Tensor)
パラメータ:
frames (torch.Tensor、np.ndarray、または list[list[PIL.Image.Image]]) : 動画出力のリスト - batch_size, 長のネストされたリストであり、各サブリストには num_frames. 長のデノイズ済み PIL 画像シーケンスが含まれる場合があります。また、(batch_size, num_frames, channels, height, width) の形状を持つ NumPy 配列や Torch テンソルである場合もあります。
LTX パイプライン用の出力クラスです。
Xet Storage Details
- Size:
- 93.9 kB
- Xet hash:
- d5e2d6993322e9a992e695fb0e20d4aa4d09f6e16076891eebc69ff7eecc61ed
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.