Buckets:
Apache License, Version 2.0("라이선스")에 따라 라이선스가 부여됩니다.
이 파일은 라이선스에 따라만 사용할 수 있습니다.
라이선스 사본은 다음에서 가져올 수 있습니다
http://www.apache.org/licenses/LICENSE-2.0
적용 가능한 법률에 의해 요구되거나 서면으로 합의되지 않는 한, 소프트웨어
라이선스에 따라 배포되는 본 소프트웨어는 "있는 그대로"
명시적이든 묵시적이든 어떠한 종류의 보증이나 조건도 없이 제공됩니다.
권한을 관리하는 특정 언어에 대한 라이선스를 참조하세요
라이선스 하의 제한 사항. -->
LTX-Video
LTX-Video는 텍스트와 이미지에서 고해상도 영상을 빠르고 실시간으로 생성하도록 설계된 diffusion transformer입니다. LTX-Video의 주요 특징은 Video-VAE입니다. Video-VAE는 더 높은 픽셀 대 latent 압축 비율(1:192)을 갖추고 있어 더 효율적인 영상 데이터 처리와 더 빠른 생성 속도를 가능하게 합니다. 생성 과정에서 더 세밀한 디테일이 손실되지 않도록 지원하고 방지하기 위해, Video-VAE 디코더는 latent에서 픽셀로의 변환 과 마지막 denoising 단계를 수행합니다.
모든 원본 LTX-Video 체크포인트는 Lightricks 조직에서 찾을 수 있습니다.
LTX-Video 모델에 대한 다른 비디오 생성 작업의 예시를 보려면 오른쪽 사이드바의 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은 첫 번째 호출 시 느리지만, 이후 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)
The input is a single word "Notes".
참고
LTX-Video 저장소에서 생성을 위한 권장 설정은 다음과 같습니다.
- transformer, VAE, text encoder에 권장되는 dtype는
torch.bfloat16입니다. VAE와 text encoder는torch.float32또는torch.float16도 사용할 수 있습니다. - LTX-Video의 guidance-distilled 변형의 경우
guidance_scale을1.0으로 설정하세요. 다른 모든 모델의guidance_scale은 좋은 생성 품질을 위해5.0과 같이 더 높은 값으로 설정해야 합니다. - timestep 인식 VAE 변형(LTX-Video 0.9.1 이상)의 경우
decode_timestep을0.05로,image_cond_noise_scale을0.025로 설정합니다. - 여러 conditioning 이미지와 비디오 간의 보간을 지원하는 변형(LTX-Video 0.9.5 이상)의 경우, 최적의 결과를 얻으려면 유사한 이미지와 비디오를 사용하세요. conditioning 입력과 차이가 크면 생성된 비디오에서 갑작스러운 전환이 발생할 수 있습니다.
- transformer, VAE, text encoder에 권장되는 dtype는
LTX-Video 0.9.7에는 공간적 잠재 변수 업스케일러와 13B 파라미터 트랜스포머가 포함되어 있습니다. 추론 과정에서 먼저 저해상도 비디오가 빠르게 생성된 후, 업스케일링 및 정제가 수행됩니다.
예제 코드 보기
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 distilled 모델은 생성 속도를 높이기 위해 guidance와 timestep이 distilled 처리되었습니다.
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 distilled 모델은 0.9.7 변형과 유사합니다. guidance와 timestep이 distilled되어 있으며, 위와 동일한 추론 코드를 사용할 수 있습니다. 이 버전의 개선 사항은 매우 긴 비디오 생성을 지원한다는 점입니다. 또한,
tone_map_compression_ratio매개변수를 사용하여 tone mapping을 적용함으로써 생성된 비디오의 품질을 향상시킬 수 있습니다.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와 함께 사용하여 인코딩된 이미지 latents의 노이즈를 제거하는 데 사용되는 스케줄러입니다.
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 제어.
Reference: https://github.com/Lightricks/LTX-Video
호출[[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) : 초당 프레임 수(FPS); video_coords의 시간 좌표를 정규화하는 데 사용됩니다.
guidance_scale (float, 기본값 1.0) : CFG 스케일; 1보다 큰 값은 classifier-free guidance를 활성화합니다.
guidance_rescale (float, 기본값 0.0) : CFG에서 과노출을 완화하기 위한 선택적 rescale입니다(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) : 지정된 경우, 전역 latents를 위한 공유 생성기를 시드하고 각 시간 창별로 seed + w_start를 사용하여 창 로컬 생성기를 파생합니다.
cond_image (PIL.Image.Image 또는 torch.Tensor, 선택 사항) : 조건 이미지. cond_strength > 0일 때 토큰별 마스크를 통해 0번째 프레임을 고정합니다.
cond_strength (float, 기본값 0.5) : 첫 프레임 하드 컨디셔닝의 강도 (cond_mask 값이 작을수록 보존이 더 강함).
latents (torch.Tensor, 선택 사항) : 초기 latents [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) : 새로운 윈도우의 헤드에 이전 윈도우의 테일 latents를 주입할 때 사용할 강도.
adain_factor (float, 기본값 0.25) : 크로스 윈도우 일관성을 위한 AdaIN 정규화 강도 (0이면 비활성화).
guidance_latents (torch.Tensor, 선택 사항) : 윈도우 헤드에 주입되는 참조 잠재 변수. 이후 윈도우의 경우 오버랩에 따라 길이가 조정됩니다.
guiding_strength (float, 기본값 1.0) : guidance_latents의 주입 강도입니다.
negative_index_latents (torch.Tensor, 선택 사항) : "음수 인덱스" 의미를 위해 윈도우 앞에 추가되는 단일 프레임 잠재 변수(latent).
negative_index_strength (float, 기본값 1.0) : negative_index_latents에 대한 주입 강도.
skip_steps_sigma_threshold (float, 선택 사항, 기본값 1) : 시그마가 이 임계값을 초과하는 스텝을 건너뜁니다.
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"인 경우 디코딩 없이 latents를 반환합니다.
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]
Shapes: Latent 크기(자동 생성 시):
- F_lat = (num_frames - 1) // vae_temporal_compression_ratio + 1
- H_lat = height // vae_spatial_compression_ratio
- W_lat = width // vae_spatial_compression_ratio
참고:
- Seeding:
seed가 제공되면 각 시간 창은seed + w_start로 시드된 로컬 생성기를 사용하며, 생성기가 전달되지 않은 경우 전역 잠금 변수를 위해 공유 생성기가 한 번만 시드됩니다. 그렇지 않으면 전달된 생성기가 재사용됩니다. - CFG: 선택적
guidance_rescale를 지원하는 통합noise_pred = uncond + w * (text - uncond). - Memory: 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, 선택 사항, 기본값 1) : 프롬프트당 생성할 비디오의 수. 결과 임베딩을 배치할 torch 장치
prompt_embeds (torch.Tensor, 선택 사항) : 미리 생성된 텍스트 임베딩입니다. 예를 들어 프롬프트 가중치와 같은 텍스트 입력을 쉽게 조정하는 데 사용할 수 있습니다. 제공되지 않으면 prompt 입력 인자에서 텍스트 임베딩이 생성됩니다.
negative_prompt_embeds (torch.Tensor, 선택 사항) : 미리 생성된 부정 텍스트 임베딩입니다. 텍스트 입력을 쉽게 조정하는 데 사용할 수 있으며, 예를 들어 프롬프트 가중치 설정에 활용할 수 있습니다. 제공되지 않으면 negative_prompt 입력 인수에서 negative_prompt_embeds가 생성됩니다.
device : (torch.device, 선택 사항): torch device
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
기본 latents를 준비하고, 선택적으로 첫 프레임 조건부 latents를 주입합니다.
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": latents를 그대로 반환합니다(하위 단계 처리에 유용함) - "pt": VAE 출력 공간의 tensor를 반환합니다 - "np"/"pil": VideoProcessor.postprocess_video를 통해 후처리된 출력을 반환합니다
auto_denormalize : True인 경우, 내부적으로 latents에 LTX de-normalization을 적용합니다(권장)
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: 디코딩 전에 마지막 latent 프레임을 복제하고, 끝에서 time_scale_factor 프레임만큼 제거합니다.
- timestep_conditioning 및 decode_noise_scale 주입을 지원합니다.
- 기본적으로 "normalized latents"(denoising 출력)는 내부적으로 de-normalize됩니다(auto_denormalize=True).
- Tile fusion은 블러와 색상 변이를 줄이기 위해 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 (T5TokenizerFast) : T5TokenizerFast 클래스의 두 번째 Tokenizer.
텍스트-투-비디오 생성을 위한 Pipeline입니다.
Reference: https://github.com/Lightricks/LTX-Video
호출[[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 = 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 = ['latents'], max_sequence_length: int = 128)
매개변수:
prompt (str 또는 list[str], 선택 사항) : 이미지 생성을 안내할 프롬프트입니다. 정의되지 않은 경우 prompt_embeds를 대신 전달해야 합니다.
negative_prompt (str 또는 list[str], 선택 사항) : 이미지 생성을 유도하지 않을 프롬프트입니다. 정의되지 않은 경우 대신 negative_prompt_embeds를 전달해야 합니다. 가이던스를 사용하지 않을 때(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, 선택 사항, 기본값 0.0) : Common Diffusion Noise Schedules and Sample Steps are Flawed에서 제안한 Guidance rescale factor입니다. guidance_scale은 Common Diffusion Noise Schedules and Sample Steps are Flawed의 16번 식에서 φ로 정의됩니다. Guidance rescale factor는 zero terminal SNR을 사용할 때 과노출 문제를 해결해야 합니다.
num_videos_per_prompt (int, 선택 사항, 기본값 1) : 프롬프트당 생성할 비디오의 수입니다.
generator (torch.Generator 또는 list[torch.Generator], 선택 사항) : 생성을 결정적으로 만들기 위한 torch generator 하나 또는 목록.
latents (torch.Tensor, 선택 사항) : 이미지 생성의 입력으로 사용할 가우시안 분포에서 샘플링된 사전 생성된 노이즈된 latents입니다. 동일한 생성을 다른 프롬프트로 조정하는 데 사용할 수 있습니다. 제공되지 않으면, 제공된 랜덤 generator를 사용하여 샘플링하여 latents 텐서가 생성됩니다.
prompt_embeds (torch.Tensor, 선택 사항) : 미리 생성된 텍스트 임베딩입니다. 예를 들어 프롬프트 가중치와 같은 텍스트 입력을 쉽게 조정하는 데 사용할 수 있습니다. 제공되지 않으면 prompt 입력 인자에서 텍스트 임베딩이 생성됩니다.
prompt_attention_mask (torch.Tensor, 선택 사항) : 텍스트 임베딩을 위한 사전 생성된 어텐션 마스크입니다.
negative_prompt_embeds (torch.FloatTensor, 선택) : 미리 생성된 부정 텍스트 임베딩입니다. PixArt-Sigma의 경우 이 negative prompt는 ""여야 합니다. 제공되지 않으면 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, 선택 사항, 기본값 1) : 프롬프트당 생성할 비디오의 수. 결과 임베딩을 배치할 torch 장치
prompt_embeds (torch.Tensor, 선택 사항) : 미리 생성된 텍스트 임베딩입니다. 예를 들어 프롬프트 가중치와 같은 텍스트 입력을 쉽게 조정하는 데 사용할 수 있습니다. 제공되지 않으면 prompt 입력 인자에서 텍스트 임베딩이 생성됩니다.
negative_prompt_embeds (torch.Tensor, 선택 사항) : 미리 생성된 부정 텍스트 임베딩입니다. 텍스트 입력을 쉽게 조정하는 데 사용할 수 있으며, 예를 들어 프롬프트 가중치 설정에 활용할 수 있습니다. 제공되지 않으면 negative_prompt 입력 인수에서 negative_prompt_embeds가 생성됩니다.
device : (torch.device, 선택 사항): torch device
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 (T5TokenizerFast) : T5TokenizerFast 클래스의 두 번째 Tokenizer.
이미지에서 비디오를 생성하는 Pipeline입니다.
Reference: https://github.com/Lightricks/LTX-Video
호출[[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 = 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 = ['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_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, 선택 사항, 기본값 0.0) : Common Diffusion Noise Schedules and Sample Steps are Flawed에서 제안한 Guidance rescale factor입니다. guidance_scale은 Common Diffusion Noise Schedules and Sample Steps are Flawed의 16번 식에서 φ로 정의됩니다. Guidance rescale factor는 zero terminal SNR을 사용할 때 과노출 문제를 해결해야 합니다.
num_videos_per_prompt (int, 선택 사항, 기본값 1) : 프롬프트당 생성할 비디오의 수입니다.
generator (torch.Generator 또는 list[torch.Generator], 선택 사항) : 생성을 결정적으로 만들기 위한 torch generator 하나 또는 목록.
latents (torch.Tensor, 선택 사항) : 이미지 생성의 입력으로 사용할 가우시안 분포에서 샘플링된 사전 생성된 노이즈된 latents입니다. 동일한 생성을 다른 프롬프트로 조정하는 데 사용할 수 있습니다. 제공되지 않으면, 제공된 랜덤 generator를 사용하여 샘플링하여 latents 텐서가 생성됩니다.
prompt_embeds (torch.Tensor, 선택 사항) : 미리 생성된 텍스트 임베딩입니다. 예를 들어 프롬프트 가중치와 같은 텍스트 입력을 쉽게 조정하는 데 사용할 수 있습니다. 제공되지 않으면 prompt 입력 인자에서 텍스트 임베딩이 생성됩니다.
prompt_attention_mask (torch.Tensor, 선택 사항) : 텍스트 임베딩을 위한 사전 생성된 어텐션 마스크입니다.
negative_prompt_embeds (torch.FloatTensor, 선택) : 미리 생성된 부정 텍스트 임베딩입니다. PixArt-Sigma의 경우 이 negative prompt는 ""여야 합니다. 제공되지 않으면 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, 선택 사항, 기본값 1) : 프롬프트당 생성할 비디오의 수. 결과 임베딩을 배치할 torch 장치
prompt_embeds (torch.Tensor, 선택 사항) : 미리 생성된 텍스트 임베딩입니다. 예를 들어 프롬프트 가중치와 같은 텍스트 입력을 쉽게 조정하는 데 사용할 수 있습니다. 제공되지 않으면 prompt 입력 인자에서 텍스트 임베딩이 생성됩니다.
negative_prompt_embeds (torch.Tensor, 선택 사항) : 미리 생성된 부정 텍스트 임베딩입니다. 텍스트 입력을 쉽게 조정하는 데 사용할 수 있으며, 예를 들어 프롬프트 가중치 설정에 활용할 수 있습니다. 제공되지 않으면 negative_prompt 입력 인수에서 negative_prompt_embeds가 생성됩니다.
device : (torch.device, 선택 사항): torch device
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 (T5TokenizerFast) : T5TokenizerFast 클래스의 두 번째 Tokenizer.
텍스트/이미지/비디오-투-비디오 생성을 위한 Pipeline
Reference: https://github.com/Lightricks/LTX-Video
호출[[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 = 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 = 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 = ['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에 더 많은 노이즈가 추가되어 원본 비디오와 생성된 비디오 간의 차이가 커집니다. 비디오-투-비디오 편집에 유용합니다.
prompt (str 또는 list[str], 선택 사항) : 이미지 생성을 안내할 프롬프트입니다. 정의되지 않은 경우 prompt_embeds를 대신 전달해야 합니다.
negative_prompt (str 또는 list[str], 선택 사항) : 이미지 생성을 유도하지 않을 프롬프트입니다. 정의되지 않은 경우 대신 negative_prompt_embeds를 전달해야 합니다. 가이던스를 사용하지 않을 때(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, 선택 사항, 기본값 0.0) : Common Diffusion Noise Schedules and Sample Steps are Flawed에서 제안한 Guidance rescale factor입니다. guidance_scale은 Common Diffusion Noise Schedules and Sample Steps are Flawed의 16번 식에서 φ로 정의됩니다. Guidance rescale factor는 zero terminal SNR을 사용할 때 과노출 문제를 해결해야 합니다.
image_cond_noise_scale (float, 기본값 0.15) : 조건부 이미지 latents에 추가되는 노이즈의 스케일입니다.
num_videos_per_prompt (int, 선택 사항, 기본값 1) : 프롬프트당 생성할 비디오의 수입니다.
generator (torch.Generator 또는 list[torch.Generator], 선택 사항) : 생성을 결정적으로 만들기 위한 torch generator 하나 또는 목록.
latents (torch.Tensor, 선택 사항) : 이미지 생성의 입력으로 사용할 가우시안 분포에서 샘플링된 사전 생성된 노이즈된 latents입니다. 동일한 생성을 다른 프롬프트로 조정하는 데 사용할 수 있습니다. 제공되지 않으면, 제공된 랜덤 generator를 사용하여 샘플링하여 latents 텐서가 생성됩니다.
prompt_embeds (torch.Tensor, 선택 사항) : 미리 생성된 텍스트 임베딩입니다. 예를 들어 프롬프트 가중치와 같은 텍스트 입력을 쉽게 조정하는 데 사용할 수 있습니다. 제공되지 않으면 prompt 입력 인자에서 텍스트 임베딩이 생성됩니다.
prompt_attention_mask (torch.Tensor, 선택 사항) : 텍스트 임베딩을 위한 사전 생성된 어텐션 마스크입니다.
negative_prompt_embeds (torch.FloatTensor, 선택) : 미리 생성된 부정 텍스트 임베딩입니다. PixArt-Sigma의 경우 이 negative prompt는 ""여야 합니다. 제공되지 않으면 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)
이미지 조건화 잠재값에 노이즈 추가[[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)
hard-conditioning latent에 timestep에 의존하는 노이즈를 추가합니다. 이는 단일 프레임으로 조건부 생성을 수행할 때 특히 동작의 연속성을 유지하는 데 도움이 됩니다.
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, 선택 사항, 기본값 1) : 프롬프트당 생성할 비디오의 수. 결과 임베딩을 배치할 torch 장치
prompt_embeds (torch.Tensor, 선택 사항) : 미리 생성된 텍스트 임베딩입니다. 예를 들어 프롬프트 가중치와 같은 텍스트 입력을 쉽게 조정하는 데 사용할 수 있습니다. 제공되지 않으면 prompt 입력 인자에서 텍스트 임베딩이 생성됩니다.
negative_prompt_embeds (torch.Tensor, 선택 사항) : 미리 생성된 부정 텍스트 임베딩입니다. 텍스트 입력을 쉽게 조정하는 데 사용할 수 있으며, 예를 들어 프롬프트 가중치 설정에 활용할 수 있습니다. 제공되지 않으면 negative_prompt 입력 인수에서 negative_prompt_embeds가 생성됩니다.
device : (torch.device, 선택 사항): torch device
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)
호출[[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) : 업샘플링된 latents가 디코딩되는 timestep입니다.
decode_noise_scale (float 또는 list[float], 선택 사항) : 디코딩 타임스텝에서 랜덤 노이즈와 디노이즈된 레이턴트 사이의 보간 계수입니다.
adain_factor (float, 기본값 0.0) : 업샘플링된 latents에 적용되는 AdaIN 통계 매칭의 강도.
tone_map_compression_ratio (float, 기본값 0.0) : 업샘플링된 latents를 톤 매핑할 때 사용되는 압축 비율. 값은 [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"인 경우 잠재 변수).
latent upsampling을 위해 pipeline을 호출할 때 호출되는 함수입니다.
adain_filter_latent[[diffusers.LTXLatentUpsamplePipeline.adain_filter_latent]]
adain_filter_latent(latents: Tensor, reference_latents: Tensor, factor: float = 1.0)
매개변수:
latents (torch.Tensor) : 정규화할 입력 latents
reference_latents (torch.Tensor) : 스타일 통계를 제공하는 참조 잠재 변수(latents).
factor (float) : 원본과 변환된 latent 사이의 블렌딩 계수. 범위: -10.0에서 10.0, 기본값: 1.0
반환값: torch.Tensor
변환된 잠재 텐서
참조 latent tensor의 통계량을 기반으로 latent 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 입력과 동일한 shape를 가진 tone-mapped latent tensor.
시그모이드 기반 압축을 사용하여 잠재 값의 동적 범위를 지각적으로 매끄러운 방식으로 줄이기 위해 비선형 톤 매핑 함수를 적용합니다.
compression 계수로 동적 동작을 제어하는 경우를 포함하여, 생성 과정에서 출력을 조건화하거나 높은 분산의 latents를 정규화하는 데 유용합니다.
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:
- 88.4 kB
- Xet hash:
- 431ae97d33d39783681970c14b909a71a28ac7ee2be66358d26f68a87345c5c8
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.