Diffusers documentation
Kandinsky 6
Kandinsky 6
Kandinsky 6은 Kandinsky Lab에서 개발한 비디오 생성 모델 계열입니다. 주요 모델은 단일 멀티모달 확산 변환기를 사용하여 텍스트 또는 참조 이미지로부터 비디오와 동기화된 오디오를 생성합니다. 비디오와 오디오 잠재 변수는 두 모달리티 간에 교차 주의를 수행하는 융합 블록을 통해 함께 노이즈 제거되며, 각각 자체 Qwen2.5-VL 텍스트 분기 및 CLIP 풀링 임베딩에 조건부화됩니다. 별도의 초해상도 모델은 인과적 3D K-VAE의 잠재 공간에서 생성된 비디오를 타일별로 업스케일링합니다.
Hub의 Kandinsky Lab 조직에서 base 모델과 super-resolution 모델의 flow-matching 및 distilled 변형을 포함한 공식 체크포인트 전체를 확인해 보세요.
Distilled checkpoints에는 few-step PiflowScheduler가 함께 제공되며,
guidance_scale=1.0로 실행해야 합니다.
사용 가능한 모델
| 모델 | Pipeline | The input is a single word "Notes". 참고 |
|---|---|---|
kandinskylab/Kandinsky-6.0-Pro-5s-Diffusers | Kandinsky6TI2VAPipeline | Flow matching, guidance_scale=5.0, 50단계 |
kandinskylab/Kandinsky-6.0-Pro-distill-5s-Diffusers | Kandinsky6TI2VAPipeline | Distilled, guidance_scale=1.0, 10단계 |
kandinskylab/Kandinsky-6.0-Lite-5s-Diffusers | Kandinsky6TI2VAPipeline | Flow matching, guidance_scale=5.0, 50단계 |
kandinskylab/Kandinsky-6.0-Lite-distill-5s-Diffusers | Kandinsky6TI2VAPipeline | Distilled, guidance_scale=1.0, 10단계 |
kandinskylab/Kandinsky-6.0-Pro-pretrain-5s-Diffusers | Kandinsky6TI2VAPipeline | Flow matching, guidance_scale=5.0, 50단계 |
kandinskylab/Kandinsky-6.0-Lite-pretrain-5s-Diffusers | Kandinsky6TI2VAPipeline | Flow matching, guidance_scale=5.0, 50단계 |
kandinskylab/Kandinsky-6.0-VSR-5s-Diffusers | Kandinsky6SRPipeline | Flow matching 초고해상도 |
kandinskylab/Kandinsky-6.0-VSR-distilled2steps-5s-Diffusers | Kandinsky6SRPipeline | 디스틸드 초고해상도, 2단계 |
텍스트/이미지-비디오-오디오
import torch
from diffusers import Kandinsky6TI2VAPipeline
from diffusers.utils import encode_video
pipe = Kandinsky6TI2VAPipeline.from_pretrained(
"kandinskylab/Kandinsky-6.0-Pro-distill-5s-Diffusers", torch_dtype=torch.bfloat16
)
pipe.enable_model_cpu_offload()
output = pipe(
prompt="A cat and a dog baking a cake together in a kitchen.",
height=480,
width=864,
num_frames=121,
num_inference_steps=10,
guidance_scale=1.0,
)
encode_video(
output.frames[0],
fps=24,
output_path="output.mp4",
audio=output.audio[0][None],
audio_sample_rate=pipe.audio_sample_rate,
)image=를 전달하여 첫 번째 프레임을 참조 이미지에 조건화하고, sample_audio=False를 전달하여 비디오만 생성하며, expand_prompts=True를 전달하여 Qwen2.5-VL 텍스트 인코더가 짧은 프롬프트를 먼저 상세한 프롬프트로 재작성하도록 합니다.
비디오 초해상도
Kandinsky6SRPipeline는 Kandinsky6TI2VAPipeline이 생성한 프레임을 2, 4, 또는 2.25배로 업스케일링합니다(1.125x 이중선형 사전 업스케일링 후 2x 경로 적용). 비디오는 겹치는 타일로 분할되며, 각 타일은 SR transformer가 학습된 타일 크기 중 하나로 정제된 후 Hann 윈도우를 사용하여 다시 블렌딩됩니다.
# required: lets inductor pick flex-attention tiles that fit the SR block mask
torch._inductor.config.max_autotune = True
sr_pipe = Kandinsky6SRPipeline.from_pretrained(
"kandinskylab/Kandinsky-6.0-VSR-distilled2steps-5s-Diffusers", torch_dtype=torch.bfloat16
)
# The SR transformer always runs NABLA sparse attention on the `flex` backend. Compile it, otherwise flex falls
# back to an eager implementation that needs far more memory at video resolutions.
sr_pipe.enable_model_cpu_offload()
sr_pipe.transformer.set_attention_backend("flex")
sr_pipe.transformer.compile_repeated_blocks(fullgraph=True)
upscaled = sr_pipe(video=output.frames[0], resolution_scale=2.25, num_inference_steps=2).frames[0]메모리 최적화
일반적인 기법 집합에 대해서는 메모리 사용량 줄이기 가이드를 참조하세요. Kandinsky6TI2VAPipeline과 Kandinsky6SRPipeline 모두 모델 오프로딩(위에서 사용됨)을 지원하며, 속도를 희생하여 더 작은 footprint를 원할 경우 순차적 CPU 오프로딩도 지원합니다:
pipe.enable_sequential_cpu_offload()
Kandinsky6TI2VAPipeline의 비디오 VAE도 고해상도 또는 긴 비디오를 위한 tiled decoding을 지원합니다:
pipe.vae.enable_tiling()
The input is a single word "Notes". 참고
height와width는 비디오 VAE의 공간 압축 비율과 transformer의 patch size의 곱으로 나누어떨어져야 합니다. 기본 Kandinsky6TI2VAPipeline 구성에서는 이 값이16입니다(8의 압축 비율을 가진AutoencoderKLHunyuanVideo,patch_size=(1, 2, 2)). 위 예제에서 사용한480x864는 이 조건을 충족합니다.- Kandinsky6SRPipeline의 입력
video는 정수k에 대해1 + k * vae_scale_factor_temporal프레임이어야 합니다(기본 K-VAE 구성에서 시간 축 압축 비율이4이므로121프레임은 가능하지만120프레임은 불가합니다). — 업스케일링 전에 이 조건을 이미 충족하지 않는 비디오는 잘라내거나 패딩을 적용하세요. expand_prompts=True는 노이즈 제거 전에 추가 생성 패스를 위해 이미 로드된 Qwen2.5-VL 텍스트 인코더를 재사용하므로 지연 시간은 증가하지만 추가 모델 가중치는 필요하지 않습니다.- 반복 추론을 더 빠르게 수행하기 위해 반복되는 transformer 블록을 컴파일합니다:
pipe.transformer.compile_repeated_blocks(fullgraph=True)
Kandinsky6TI2VAPipeline
class diffusers.Kandinsky6TI2VAPipeline
< source >( transformer: Kandinsky6Transformer3DModelvae: AutoencoderKLHunyuanVideotext_encoder: Qwen2_5_VLForConditionalGenerationtokenizer: Qwen2_5_VLProcessortext_encoder_2: CLIPTextModeltokenizer_2: CLIPTokenizerscheduler: diffusers.schedulers.scheduling_flow_match_euler_discrete.FlowMatchEulerDiscreteScheduler | diffusers.schedulers.scheduling_piflow.PiflowScheduleraudio_vae: diffusers.models.autoencoders.autoencoder_mmaudio.MMAudioVAE | None = Nonevocoder: diffusers.models.autoencoders.mmaudio_vocoder.MMAudioVocoder | None = None )
매개변수
- transformer (Kandinsky6Transformer3DModel) — 비디오와 오디오 잠재를 디노이즈하는 멀티모달 transformer입니다.
- vae (AutoencoderKLHunyuanVideo) — 참조 이미지를 인코딩하고 생성된 비디오를 디코딩하는 데 사용되는 비디오 VAE입니다.
- text_encoder (Qwen2_5_VLForConditionalGeneration) — 토큰 수준의 텍스트 임베딩을 제공하고, 선택적으로 프롬프트 확장을 수행하는 Qwen2.5-VL 모델입니다.
- tokenizer (Qwen2_5_VLProcessor) —
text_encoder의 프로세서입니다. - text_encoder_2 (CLIPTextModel) — 풀드 텍스트 임베딩을 제공하는 CLIP 텍스트 인코더.
- tokenizer_2 (CLIPTokenizer) —
text_encoder_2의 토크나이저. - scheduler (FlowMatchEulerDiscreteScheduler 또는 PiflowScheduler) —
transformer와 함께 latents의 노이즈를 제거하는 데 사용되는 스케줄러입니다. Distilled 체크포인트에는 PiflowScheduler가 포함되어 있으며,guidance_scale=1.0으로 실행해야 합니다. - audio_vae (MMAudioVAE, 선택 사항) —
생성된 오디오 latents를 mel spectrogram으로 디코딩하는 데 사용되는 오디오 VAE입니다.
sample_audio=True인 경우에만 필요합니다. - vocoder (MMAudioVocoder, 선택) —
audio_vae가 디코딩한 멜 스펙트로그램을 웨이브폼으로 변환하는 데 사용되는 Vocoder.sample_audio=True인 경우에만 필요합니다.
Kandinsky 6을 사용한 텍스트/이미지-비디오-오디오 생성을 위한 Pipeline
Video와 audio latents는 Qwen2.5-VL 텍스트 토큰과 CLIP pooled embedding에 조건부화된 단일 multimodal transformer에 의해 함께 denoise됩니다. 선택 사항인 reference image는 첫 번째 프레임에 조건을 부여합니다.
이 모델은 DiffusionPipeline에서 상속됩니다. 모든 파이프라인에 대해 구현된 일반적 메서드(다운로드, 저장, 특정 디바이스에서 실행 등)에 대해서는 상위 클래스 문서를 확인하세요.
__call__
< source >( prompt: str | list[str] | None = Noneimage: typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor], NoneType] = Nonenegative_prompt: str | list[str] | None = Noneheight: int = 512width: int = 768num_frames: int = 121frame_rate: float = 24.0num_inference_steps: int = 50timesteps: list[int] | None = Nonesigmas: list[float] | None = Noneguidance_scale: float = 5.0num_videos_per_prompt: int = 1generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = Nonelatents: typing.Optional[torch.Tensor] = Noneaudio_latents: typing.Optional[torch.Tensor] = Noneprompt_embeds: typing.Optional[torch.Tensor] = Nonepooled_prompt_embeds: typing.Optional[torch.Tensor] = Nonenegative_prompt_embeds: typing.Optional[torch.Tensor] = Nonenegative_pooled_prompt_embeds: typing.Optional[torch.Tensor] = Nonesample_audio: bool = Trueexpand_prompts: bool = Falsemax_sequence_length: int = 1024output_type: str = 'pil'return_dict: bool = Truecallback_on_step_end: collections.abc.Callable[[int, int, dict], None] | None = Nonecallback_on_step_end_tensor_inputs: list = ['latents'] ) → Kandinsky6TI2VAPipelineOutput or tuple
매개변수
- prompt (
str또는list[str], 선택 사항) — 생성을 안내할 프롬프트입니다.prompt_embeds가 제공되지 않는 한 필수입니다. - image (
PipelineImageInput, 선택 사항) — 첫 번째 프레임을 조건화하는 참조 이미지(이미지-비디오-오디오 변환). - negative_prompt (
str또는list[str], 선택 사항) — 생성을 안내하지 않을 프롬프트입니다. 기본값은 Kandinsky 6의 negative prompt입니다. - height (
int, 기본값512) — 생성된 비디오의 픽셀 단위 높이입니다. - width (
int, 기본값768) — 생성된 비디오의 픽셀 단위 너비입니다. - num_frames (
int, 기본값121) — 생성할 프레임 수. - frame_rate (
float, 기본값24.0) — 동영상이 생성되는 프레임 레이트입니다. 동기화 오디오의 길이를 설정합니다. - num_inference_steps (
int, 기본값50) — 디노이징 단계 수입니다. 증류된 체크포인트를 사용할 경우16을(를) 사용하세요. - timesteps (
list[int], 선택 사항) — 이를 지원하는 스케줄러에 사용할 커스텀 timesteps입니다. - sigmas (
list[float], 선택 사항) — 지원하는 스케줄러에 사용할 커스텀 sigmas입니다. - guidance_scale (
float, 기본값5.0) — Classifier-free guidance scale. PiflowScheduler를 사용할 경우1.0이어야 합니다. - num_videos_per_prompt (
int, 기본값1) — 프롬프트당 생성할 비디오의 수입니다. - generator (
torch.Generator또는list[torch.Generator], 선택 사항) — 초기 노이즈 및 참조 이미지 인코딩에 사용되는 Generator입니다. - latents (
torch.Tensor, 선택 사항) —(batch_size, channels, num_latent_frames, latent_height, latent_width)모양의 사전 생성된 비디오 latents입니다. - audio_latents (
torch.Tensor, 선택 사항) —(batch_size, channels, audio_length)형태의 사전 생성된 오디오 잠재 변수(latents). - prompt_embeds (
torch.Tensor, 선택 사항) — 미리 생성된 Qwen2.5-VL 텍스트 임베딩입니다. - pooled_prompt_embeds (
torch.Tensor, 선택) — 미리 생성된 CLIP 풀링 텍스트 임베딩입니다. - negative_prompt_embeds (
torch.Tensor, 선택 사항) — 미리 생성된 negative Qwen2.5-VL 텍스트 임베딩입니다. - negative_pooled_prompt_embeds (
torch.Tensor, 선택 사항) — 미리 생성된 negative CLIP pooled text embeddings입니다. - sample_audio (
bool, 기본값True) — 동기화된 오디오를 생성할지 여부입니다. 파이프라인에audio_vae와vocoder가 있어야 합니다. - expand_prompts (
bool, 기본값False) — 인코딩 전에 expand_prompts()로 프롬프트를 재작성할지 여부. - max_sequence_length (
int, 기본값1024) — 채팅 템플릿 적용 후 프롬프트 토큰의 최대 개수입니다. - output_type (
str, 기본값"pil") — 생성된 비디오의 출력 형식:"pil","np","pt"또는"latent". - return_dict (
bool, 기본값True) — 단순 튜플 대신 Kandinsky6TI2VAPipelineOutput를 반환할지 여부. - callback_on_step_end (
Callable, 선택 사항) —callback_on_step_end(self, step, timestep, callback_kwargs)를 인수로 받는 함수로, 각 디노이징 단계의 끝에서 호출됩니다. 나열된 텐서를 오버라이드하는 딕을 반환할 수 있습니다. - callback_on_step_end_tensor_inputs (
list[str], 기본값["latents"]) —callback_on_step_end에 전달되는 텐서 입력._callback_tensor_inputs의 부분 집합입니다.
반환값
Kandinsky6TI2VAPipelineOutput 또는 tuple
생성된 비디오와 오디오; return_dict=False인 경우 (frames, audio) 튜플.
생성을 위한 pipeline의 호출 함수.
예:
>>> import torch
>>> from diffusers import Kandinsky6TI2VAPipeline
>>> from diffusers.utils import encode_video
>>> pipe = Kandinsky6TI2VAPipeline.from_pretrained(
... "kandinskylab/Kandinsky-6.0-Pro-distill-5s-Diffusers", torch_dtype=torch.bfloat16
... )
>>> pipe.enable_model_cpu_offload()
>>> output = pipe(
... prompt="A cat and a dog baking a cake together in a kitchen.",
... height=480,
... width=864,
... num_frames=121,
... num_inference_steps=16,
... guidance_scale=1.0,
... )
>>> encode_video(
... output.frames[0],
... fps=24,
... output_path="output.mp4",
... audio=output.audio[0][None],
... audio_sample_rate=pipe.audio_sample_rate,
... )encode_image
< source >( image: typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor]]height: intwidth: intdevice: devicedtype: dtypenum_videos_per_prompt: int = 1generator: typing.Optional[torch.Generator] = None )
참조 이미지를 VAE의 scaling_factor로 스케일링된 (batch_size, latent_height, latent_width, latent_channels) 형태의 첫 프레임 latents로 인코딩합니다. PIL 이미지는 height x width로 리사이즈 및 중앙 크롭됩니다. 텐서와 배열은 이미 해당 크기를 가져야 합니다. latents는 배치 차원 방향으로 num_videos_per_prompt회 반복됩니다.
encode_prompt
< source >( prompt: str | list[str]negative_prompt: str | list[str] | None = Nonedo_classifier_free_guidance: bool = Truenum_videos_per_prompt: int = 1prompt_embeds: typing.Optional[torch.Tensor] = Nonepooled_prompt_embeds: typing.Optional[torch.Tensor] = Noneprompt_attention_mask: typing.Optional[torch.Tensor] = Nonenegative_prompt_embeds: typing.Optional[torch.Tensor] = Nonenegative_pooled_prompt_embeds: typing.Optional[torch.Tensor] = Nonenegative_prompt_attention_mask: typing.Optional[torch.Tensor] = Nonemax_sequence_length: int = 1024device: typing.Optional[torch.device] = Nonedtype: typing.Optional[torch.dtype] = None )
매개변수
- prompt (
str또는list[str]) — 인코딩할 프롬프트. - negative_prompt (
str또는list[str], 선택 사항) — 생성을 유도하지 않을 프롬프트입니다.do_classifier_free_guidance가False인 경우 무시됩니다. - do_classifier_free_guidance (
bool, 기본값True) — 부정 프롬프트도 인코딩할지 여부. - num_videos_per_prompt (
int, 기본값1) — 프롬프트당 생성되는 비디오의 수입니다. 임베딩은 이에 따라 반복됩니다. - prompt_embeds (
torch.Tensor, 선택 사항) — 미리 생성된 Qwen2.5-VL 텍스트 임베딩입니다.prompt인코딩을 건너뜁니다. - pooled_prompt_embeds (
torch.Tensor, 선택) — 미리 생성된 CLIP 풀링 텍스트 임베딩입니다.prompt_embeds와 함께 제공해야 합니다. - prompt_attention_mask (
torch.Tensor, 선택 사항) —prompt_embeds의 Boolean 패딩 마스크입니다. - negative_prompt_embeds (
torch.Tensor, 선택 사항) — 미리 생성된 negative Qwen2.5-VL 텍스트 임베딩입니다. - negative_pooled_prompt_embeds (
torch.Tensor, 선택 사항) — 미리 생성된 negative CLIP pooled text embeddings입니다. - negative_prompt_attention_mask (
torch.Tensor, 선택 사항) —negative_prompt_embeds의 Boolean 패딩 마스크입니다. - max_sequence_length (
int, 기본값1024) — 채팅 템플릿 적용 후 프롬프트 토큰의 최대 개수입니다. - device (
torch.device, 선택 사항) — 텍스트 인코더를 실행할 장치. - dtype (
torch.dtype, 선택 사항) — 반환되는 임베딩의 Dtype입니다.
프롬프트를 텍스트 인코더의 히든 상태로 인코딩합니다.
expand_prompts
< source >( prompt: str | list[str]tokenizertext_encoderdevice: deviceimage: PIL.Image.Image | list[PIL.Image.Image] | None = Nonemax_sequence_length: int = 1024generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = None ) → str or list[str]
매개변수
- prompt (
str또는list[str]) — 확장할 프롬프트 또는 프롬프트 목록. - tokenizer —
Qwen2.5-VL 프로세서, 예:
pipe.tokenizer. - text_encoder —
예를 들어
pipe.text_encoder인 Qwen2.5-VL 모델입니다. - device (
torch.device) — 텍스트 인코더를 실행할 장치. - image (
PIL.Image.Image또는list[PIL.Image.Image], 선택 사항) — 이미지-비디오 호출의 참조 이미지입니다. - max_sequence_length (
int, 기본값1024) — 프롬프트당 생성되는 최대 토큰 수. - generator (
torch.Generator또는list[torch.Generator], 선택 사항) — 샘플링된 확장의 시드를 설정합니다. 리스트인 경우prompt의 길이와 일치해야 하며, 항목별로 하나의 생성기를 사용합니다.generate는 전역 RNG에서 값을 추출하므로, 전역 RNG는 이 생성기의 시드로 시드됩니다. 이후randn_tensor호출은generator를 직접 계속 사용합니다.
반환값
str 또는 list[str]
확장된 프롬프트입니다.
Qwen2.5-VL 텍스트 인코더를 사용하여 짧은 프롬프트를 상세한 비디오+오디오 프롬프트로 재작성하며, 참조 이미지가 제공된 경우 이를 기반으로 합니다. 파이프라인 실행 전에 독립적으로 사용할 수 있도록 staticmethod로 구현되어 있습니다.
prepare_audio_latents
< source >( batch_size: intnum_channels_latents: intaudio_length: intdtype: dtypedevice: devicegenerator: typing.Union[torch.Generator, list[torch.Generator], NoneType]audio_latents: typing.Optional[torch.Tensor] = None )
transformer의 (batch_size, audio_length, channels) 레이아웃으로 오디오 latents를 반환합니다. 사용자가 제공한 audio_latents 텐서는 (batch_size, channels, audio_length) 레이아웃으로 예상됩니다.
prepare_latents
< source >( batch_size: intnum_channels_latents: intheight: intwidth: intnum_frames: intdtype: dtypedevice: devicegenerator: typing.Union[torch.Generator, list[torch.Generator], NoneType]latents: typing.Optional[torch.Tensor] = None )
transformer의 (batch_size, num_frames, height, width, channels) 레이아웃으로 비디오 latents를 반환합니다.
사용자가 제공한 latents 텐서는 (batch_size, channels, num_frames, height, width) 레이아웃으로 예상됩니다.
Kandinsky6SRPipeline
class diffusers.Kandinsky6SRPipeline
< source >( transformer: Kandinsky6SRTransformer3DModelvae: Kandinsky6SRVAEscheduler: diffusers.schedulers.scheduling_flow_match_euler_discrete.FlowMatchEulerDiscreteScheduler | diffusers.schedulers.scheduling_piflow.PiflowSchedulerlatent_upscaler: diffusers.models.latent_upscaler.latent_upscaler_kandinsky6_sr.Kandinsky6SRLatentUpscalerBank | None = None )
매개변수
- transformer (Kandinsky6SRTransformer3DModel) — 잠재 타일을 정제하는 Transformer입니다.
- vae (Kandinsky6SRVAE) — 입력 비디오를 인코딩하고 정제된 타일을 디코딩하는 데 사용되는 Causal video K-VAE입니다.
- scheduler (FlowMatchEulerDiscreteScheduler 또는 PiflowScheduler) —
transformer와 함께 타일의 노이즈를 제거하는 데 사용되는 스케줄러입니다. 디스틸된 체크포인트에는 PiflowScheduler가 함께 제공됩니다. - latent_upscaler (Kandinsky6SRLatentUpscalerBank, 선택 사항) — 지원되는 스케일에 대한 Latent 업스케일러입니다.
Kandinsky 6을 활용한 비디오 초해상도 파이프라인.
비디오는 겹치는 공간 타일로 분할되며, 각 타일은 모델이 학습된 타일 크기(transformer.config.tile_sizes) 중 하나에서 SR transformer에 의해 정제되고, 정제된 타일은 Hann 윈도우를 사용하여 다시 블렌딩됩니다. 파이프라인에 latent_upscaler가 있는 경우, 타일은 전체 비디오의 K-VAE 잠재 공간에서 잘라내어 잠재 공간에서 업스케일링됩니다. 그렇지 않으면 픽셀 타일이 이선형 보간으로 업스케일링된 후 인코딩됩니다.
이 모델은 DiffusionPipeline에서 상속됩니다. 모든 파이프라인에 대해 구현된 일반적 메서드(다운로드, 저장, 특정 디바이스에서 실행 등)에 대해서는 상위 클래스 문서를 확인하세요.
__call__
< source >( video: typing.Union[list[PIL.Image.Image], list[list[PIL.Image.Image]], numpy.ndarray, torch.Tensor]resolution_scale: float = 2.25num_inference_steps: int = 4timesteps: list[int] | None = Nonesigmas: list[float] | None = Nonelq_noise_scale: float = 0.7min_overlap: float = 0.2tiles_batch_size: int = 1generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = Noneoutput_type: str = 'pil'return_dict: bool = True ) → Kandinsky6SRPipelineOutput or tuple
매개변수
- video (
list[PIL.Image.Image],np.ndarray또는torch.Tensor) —1 + k * 4개의 프레임을 가진 저해상도 비디오입니다. preprocess_video()가 허용하는 모든 형식을 사용할 수 있으며, 크기는 VAE 공간 계수의 배수로 아래로 반올림됩니다. - resolution_scale (
float, 기본값2.25) — 전체 공간 업스케일:2,4또는2.25(1.125x 이중선형 사전 업스케일 후 2x 경로 적용). - num_inference_steps (
int, 기본값4) — 타일당 디노이징 단계 수입니다. 증류된 체크포인트를 사용할 때는2를 사용하세요. - timesteps (
list[int], 선택 사항) — 이를 지원하는 스케줄러에 사용할 커스텀 timesteps입니다. - sigmas (
list[float], 선택 사항) — 지원하는 스케줄러에 사용할 커스텀 sigmas입니다. - lq_noise_scale (
float, 기본값0.7) — 디노이징 전에 저해상도 라텐트에 혼합되는 가우시안 노이즈의 양(분산 보존). - min_overlap (
float, 기본값0.2) — 타일 크기에 대한 인접 타일 간 최소 겹침 비율. - tiles_batch_size (
int, 기본값1) — transformer 호출마다 노이즈를 제거할 타일 수입니다. - generator (
torch.Generator또는list[torch.Generator], 선택 사항) — 타일에 혼합되는 노이즈에 사용되는 생성기입니다. - output_type (
str, 기본값"pil") — 생성된 비디오의 출력 형식:"pil","np"또는"pt". - return_dict (
bool, 기본값True) — 단순 튜플 대신 Kandinsky6SRPipelineOutput를 반환할지 여부.
반환값
Kandinsky6SRPipelineOutput 또는 tuple
초해상도 영상. return_dict=False인 경우 1개 요소의 튜플입니다.
슈퍼 레졸루션을 위한 파이프라인의 호출 함수.
예:
>>> import torch
>>> from diffusers import Kandinsky6SRPipeline, Kandinsky6TI2VAPipeline
>>> from diffusers.utils import export_to_video
>>> pipe = Kandinsky6TI2VAPipeline.from_pretrained(
... "kandinskylab/Kandinsky-6.0-Pro-distill-5s-Diffusers", torch_dtype=torch.bfloat16
... )
>>> pipe.enable_model_cpu_offload()
>>> video = pipe(
... prompt="A cat and a dog baking a cake together in a kitchen.",
... height=480,
... width=864,
... num_inference_steps=16,
... guidance_scale=1.0,
... sample_audio=False,
... ).frames[0]
>>> sr_pipe = Kandinsky6SRPipeline.from_pretrained(
... "kandinskylab/Kandinsky-6.0-VSR-distilled2steps-5s-Diffusers", torch_dtype=torch.bfloat16
... )
>>> # The transformer always runs attention through the `flex` backend; compiling avoids the eager
>>> # fallback's much higher memory use at video resolutions.
>>> sr_pipe.transformer.compile_repeated_blocks(fullgraph=True)
>>> sr_pipe.enable_model_cpu_offload()
>>> output = sr_pipe(video=video, resolution_scale=2.25, num_inference_steps=2)
>>> export_to_video(output.frames[0], "output_sr.mp4", fps=24)스케일된 K-VAE latents를 [-1, 1] 범위의 (batch_size, channels, num_frames, height, width) 비디오로 디코딩합니다.
(batch_size, channels, num_frames, height, width) 크기의 [-1, 1] 범위를 가진 비디오를 VAE의 scaling_factor로 스케일링된 K-VAE latents로 인코딩합니다.
Kandinsky6SRLatentUpscalerBank
class diffusers.Kandinsky6SRLatentUpscalerBank
< source >( in_channels: int = 64stage_channels: tuple[int, int, int] = (2048, 1024, 512)num_pre_blocks: int = 5num_mid_blocks: int = 3num_post_blocks: int = 3num_x2_adapter_blocks: int = 2scales: tuple[int, ...] = (2, 4)scaling_factor: float = 0.910344004631042 )
매개변수
- in_channels (
int, 기본값64) — 잠재 채널의 수입니다. - stage_channels (
tuple[int, int, int], 기본값(2048, 1024, 512)) — 캐스케이드의 세 단계에 대한 특징 폭입니다. - num_pre_blocks (
int, 기본값5) — x4 모델의 첫 번째 업샘플링 이전의 잔차 블록 수. - num_mid_blocks (
int, 기본값3) — 두 업샘플링 사이에 위치하는 잔차 블록의 수. - num_post_blocks (
int, 기본값3) — 마지막 업샘플링 이후의 잔차 블록 수. - num_x2_adapter_blocks (
int, 기본값2) — x2 모델 어댑터의 잔차 블록 수. - scales (
tuple[int, ...], 기본값(2, 4)) — 해당 bank가 업스케일러를 제공하는 공간 스케일입니다. - scaling_factor (
float, 기본값0.910344) — 입력 latents가 가질 것으로 예상되는 스케일(K-VAE의scaling_factor)입니다.
Kandinsky6SRPipeline에서 사용하는 잠재 업스케일러 뱅크: 지원되는 공간 스케일마다 Kandinsky6SRLatentUpscaler 하나씩, K-VAE 잠재 변수에서 동작합니다.
forward
< source >( latents: Tensorscale: intreturn_dict: bool = True )
Kandinsky6TI2VAPipelineOutput
클래스 diffusers.Kandinsky6TI2VAPipelineOutput
< source >( frames: typing.Union[torch.Tensor, numpy.ndarray, list[list[PIL.Image.Image]]]audio: typing.Union[torch.Tensor, numpy.ndarray, NoneType] = None )
매개변수
- frames (
torch.Tensor,np.ndarray또는list[list[PIL.Image.Image]]) — 생성된 비디오입니다. 각 요소에num_frames개의 PIL 이미지를 포함하는 길이가batch_size인 중첩 리스트이거나,(batch_size, num_frames, height, width, channels)/(batch_size, num_frames, channels, height, width)모양의 NumPy 배열 또는 torch 텐서입니다.output_type="latent"인 경우,(batch_size, channels, num_latent_frames, latent_height, latent_width)모양의 비디오 latent입니다. - audio (
torch.Tensor또는np.ndarray, 선택 사항) — 오디오 VAE의 샘플 레이트에서[-1, 1]범위의(batch_size, num_samples)모양으로 생성된 웨이브폼, 또는 오디오가 샘플링되지 않은 경우None.output_type="latent"인 경우(batch_size, channels, audio_length)모양의 오디오 라텐트.
Kandinsky6TI2VAPipeline의 출력 클래스입니다.
Kandinsky6SRPipelineOutput
class diffusers.Kandinsky6SRPipelineOutput
< source >( frames: typing.Union[torch.Tensor, numpy.ndarray, list[list[PIL.Image.Image]]] )
Kandinsky6SRPipeline의 출력 클래스입니다.