# Kandinsky 6

Kandinsky 6은 [Kandinsky Lab](https://huggingface.co/kandinskylab)에서 개발한 비디오 생성 모델 계열입니다. 주요 모델은 단일 멀티모달 확산 변환기를 사용하여 텍스트 또는 참조 이미지로부터 비디오와 동기화된 오디오를 생성합니다. 비디오와 오디오 잠재 변수는 두 모달리티 간에 교차 주의를 수행하는 융합 블록을 통해 함께 노이즈 제거되며, 각각 자체 Qwen2.5-VL 텍스트 분기 및 CLIP 풀링 임베딩에 조건부화됩니다. 별도의 초해상도 모델은 인과적 3D K-VAE의 잠재 공간에서 생성된 비디오를 타일 단위로 업스케일링합니다.

> [!TIP]
> Hub의 [Kandinsky Lab](https://huggingface.co/kandinskylab) 조직에서 base 및 super-resolution 모델의 flow-matching 및 distilled 변형을 포함한 공식 체크포인트 전체를 확인해 보세요.
>
> Distilled checkpoints에는 few-step [PiflowScheduler](/docs/diffusers/main/ko/api/schedulers/piflow#diffusers.PiflowScheduler)가 함께 제공되며, `guidance_scale=1.0`로 실행해야 합니다.

## 사용 가능한 모델

| 모델 | Pipeline | The input is a single word "Notes".

참고 |
|---|---|---|
| [`kandinskylab/Kandinsky-6.0-Pro-5s-Diffusers`](https://huggingface.co/kandinskylab/Kandinsky-6.0-Pro-5s-Diffusers) | [Kandinsky6TI2VAPipeline](/docs/diffusers/main/ko/api/pipelines/kandinsky6#diffusers.Kandinsky6TI2VAPipeline) | Flow matching, `guidance_scale=5.0`, 50단계 |
| [`kandinskylab/Kandinsky-6.0-Pro-distill-5s-Diffusers`](https://huggingface.co/kandinskylab/Kandinsky-6.0-Pro-distill-5s-Diffusers) | [Kandinsky6TI2VAPipeline](/docs/diffusers/main/ko/api/pipelines/kandinsky6#diffusers.Kandinsky6TI2VAPipeline) | Distilled, `guidance_scale=1.0`, 10단계 |
| [`kandinskylab/Kandinsky-6.0-Lite-5s-Diffusers`](https://huggingface.co/kandinskylab/Kandinsky-6.0-Lite-5s-Diffusers) | [Kandinsky6TI2VAPipeline](/docs/diffusers/main/ko/api/pipelines/kandinsky6#diffusers.Kandinsky6TI2VAPipeline) | Flow matching, `guidance_scale=5.0`, 50단계 |
| [`kandinskylab/Kandinsky-6.0-Lite-distill-5s-Diffusers`](https://huggingface.co/kandinskylab/Kandinsky-6.0-Lite-distill-5s-Diffusers) | [Kandinsky6TI2VAPipeline](/docs/diffusers/main/ko/api/pipelines/kandinsky6#diffusers.Kandinsky6TI2VAPipeline) | Distilled, `guidance_scale=1.0`, 10단계 |
| [`kandinskylab/Kandinsky-6.0-Pro-pretrain-5s-Diffusers`](https://huggingface.co/kandinskylab/Kandinsky-6.0-Pro-pretrain-5s-Diffusers) | [Kandinsky6TI2VAPipeline](/docs/diffusers/main/ko/api/pipelines/kandinsky6#diffusers.Kandinsky6TI2VAPipeline) | Flow matching, `guidance_scale=5.0`, 50단계 |
| [`kandinskylab/Kandinsky-6.0-Lite-pretrain-5s-Diffusers`](https://huggingface.co/kandinskylab/Kandinsky-6.0-Lite-pretrain-5s-Diffusers) | [Kandinsky6TI2VAPipeline](/docs/diffusers/main/ko/api/pipelines/kandinsky6#diffusers.Kandinsky6TI2VAPipeline) | Flow matching, `guidance_scale=5.0`, 50단계 |
| [`kandinskylab/Kandinsky-6.0-VSR-5s-Diffusers`](https://huggingface.co/kandinskylab/Kandinsky-6.0-VSR-5s-Diffusers) | [Kandinsky6SRPipeline](/docs/diffusers/main/ko/api/pipelines/kandinsky6#diffusers.Kandinsky6SRPipeline) | Flow matching 초고해상도 |
| [`kandinskylab/Kandinsky-6.0-VSR-distilled2steps-5s-Diffusers`](https://huggingface.co/kandinskylab/Kandinsky-6.0-VSR-distilled2steps-5s-Diffusers) | [Kandinsky6SRPipeline](/docs/diffusers/main/ko/api/pipelines/kandinsky6#diffusers.Kandinsky6SRPipeline) | 디스틸드 초고해상도, 2단계 |

## 텍스트/이미지-비디오-오디오

```python
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](/docs/diffusers/main/ko/api/pipelines/kandinsky6#diffusers.Kandinsky6SRPipeline)는 [Kandinsky6TI2VAPipeline](/docs/diffusers/main/ko/api/pipelines/kandinsky6#diffusers.Kandinsky6TI2VAPipeline)이 생성한 프레임을 `2`, `4`, 또는 `2.25`배로 업스케일링합니다(1.125x 이중선형 사전 업스케일링 후 2x 경로 적용). 비디오는 겹치는 타일로 분할되며, 각 타일은 SR transformer가 학습된 타일 크기 중 하나로 정제된 후 Hann 윈도우를 사용하여 다시 블렌딩됩니다.

```python
# 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]
```

## 메모리 최적화

일반적인 기법 집합에 대해서는 [메모리 사용량 줄이기](../../optimization/memory) 가이드를 참조하세요. [Kandinsky6TI2VAPipeline](/docs/diffusers/main/ko/api/pipelines/kandinsky6#diffusers.Kandinsky6TI2VAPipeline)과 [Kandinsky6SRPipeline](/docs/diffusers/main/ko/api/pipelines/kandinsky6#diffusers.Kandinsky6SRPipeline) 모두 [모델 오프로딩](../../optimization/memory#model-offloading)(위에서 사용됨)을 지원하며, 속도를 희생하여 더 작은 footprint를 원할 경우 [순차적 CPU 오프로딩](../../optimization/memory#cpu-offloading)도 지원합니다:

```python
pipe.enable_sequential_cpu_offload()
```

[Kandinsky6TI2VAPipeline](/docs/diffusers/main/ko/api/pipelines/kandinsky6#diffusers.Kandinsky6TI2VAPipeline)의 비디오 VAE도 고해상도 또는 긴 비디오를 위한 [tiled decoding](../../optimization/memory#vae-tiling)을 지원합니다:

```python
pipe.vae.enable_tiling()
```

## The input is a single word "Notes".

참고

- `height`와 `width`는 비디오 VAE의 공간 압축 비율과 transformer의 patch size의 곱으로 나누어떨어져야 합니다. 기본 [Kandinsky6TI2VAPipeline](/docs/diffusers/main/ko/api/pipelines/kandinsky6#diffusers.Kandinsky6TI2VAPipeline) 구성에서는 이 값이 `16`입니다(`8`의 압축 비율을 가진 `AutoencoderKLHunyuanVideo`, `patch_size=(1, 2, 2)`). 위 예제에서 사용한 `480x864`는 이 조건을 충족합니다.
- [Kandinsky6SRPipeline](/docs/diffusers/main/ko/api/pipelines/kandinsky6#diffusers.Kandinsky6SRPipeline)의 입력 `video`는 정수 `k`에 대해 `1 + k * vae_scale_factor_temporal` 프레임이어야 합니다(기본 K-VAE 구성에서 시간 축 압축 비율이 `4`이므로 `121` 프레임은 가능하지만 `120` 프레임은 불가합니다). 이 조건을 이미 충족하지 않는 비디오는 업스케일링 전에 잘라내거나 패딩을 추가하세요.
- `expand_prompts=True`는 노이즈 제거 전에 추가 생성 패스를 위해 이미 로드된 Qwen2.5-VL 텍스트 인코더를 재사용하므로 지연 시간은 증가하지만 추가 모델 가중치는 필요하지 않습니다.
- 반복 추론을 더 빠르게 수행하기 위해 반복되는 transformer 블록을 컴파일합니다:
  ```python
  pipe.transformer.compile_repeated_blocks(fullgraph=True)
  ```

## Kandinsky6TI2VAPipeline[[diffusers.Kandinsky6TI2VAPipeline]]

#### diffusers.Kandinsky6TI2VAPipeline[[diffusers.Kandinsky6TI2VAPipeline]]

```python
diffusers.Kandinsky6TI2VAPipeline(transformer: Kandinsky6Transformer3DModel, vae: AutoencoderKLHunyuanVideo, text_encoder: Qwen2_5_VLForConditionalGeneration, tokenizer: Qwen2_5_VLProcessor, text_encoder_2: CLIPTextModel, tokenizer_2: CLIPTokenizer, scheduler: diffusers.schedulers.scheduling_flow_match_euler_discrete.FlowMatchEulerDiscreteScheduler | diffusers.schedulers.scheduling_piflow.PiflowScheduler, audio_vae: diffusers.models.autoencoders.autoencoder_mmaudio.MMAudioVAE | None = None, vocoder: diffusers.models.autoencoders.mmaudio_vocoder.MMAudioVocoder | None = None)
```

[소스](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/kandinsky6/pipeline_kandinsky6_ti2va.py#L178)

**매개변수:**

transformer ([Kandinsky6Transformer3DModel](/docs/diffusers/main/ko/api/models/kandinsky6_transformer#diffusers.Kandinsky6Transformer3DModel)) : 비디오와 오디오 잠재를 디노이즈하는 멀티모달 트랜스포머입니다.

vae ([AutoencoderKLHunyuanVideo](/docs/diffusers/main/ko/api/models/autoencoder_kl_hunyuan_video#diffusers.AutoencoderKLHunyuanVideo)) : 참조 이미지를 인코딩하고 생성된 비디오를 디코딩하는 데 사용되는 비디오 VAE입니다.

text_encoder ([Qwen2_5_VLForConditionalGeneration](https://huggingface.co/docs/transformers/main/en/model_doc/qwen2_5_vl#transformers.Qwen2_5_VLForConditionalGeneration)) : 토큰 수준의 텍스트 임베딩을 제공하며, 선택적으로 프롬프트 확장을 지원하는 Qwen2.5-VL 모델입니다.

tokenizer ([Qwen2_5_VLProcessor](https://huggingface.co/docs/transformers/main/en/model_doc/qwen2_5_vl#transformers.Qwen2_5_VLProcessor)) : `text_encoder`의 프로세서입니다.

text_encoder_2 ([CLIPTextModel](https://huggingface.co/docs/transformers/main/en/model_doc/clip#transformers.CLIPTextModel)) : 풀된 텍스트 임베딩을 제공하는 CLIP 텍스트 인코더

tokenizer_2 ([CLIPTokenizer](https://huggingface.co/docs/transformers/main/en/model_doc/clip#transformers.CLIPTokenizer)) : `text_encoder_2`의 Tokenizer입니다.

scheduler ([FlowMatchEulerDiscreteScheduler](/docs/diffusers/main/ko/api/schedulers/flow_match_euler_discrete#diffusers.FlowMatchEulerDiscreteScheduler) 또는 [PiflowScheduler](/docs/diffusers/main/ko/api/schedulers/piflow#diffusers.PiflowScheduler)) : `transformer`와 함께 latents의 노이즈를 제거하는 데 사용되는 스케줄러입니다. Distilled 체크포인트에는 [PiflowScheduler](/docs/diffusers/main/ko/api/schedulers/piflow#diffusers.PiflowScheduler)가 포함되어 있으며, `guidance_scale=1.0`로 실행해야 합니다.

audio_vae ([MMAudioVAE](/docs/diffusers/main/ko/api/models/kandinsky6_vae#diffusers.MMAudioVAE), *선택 사항*) : 생성된 오디오 latents를 mel spectrogram으로 디코딩하는 데 사용되는 오디오 VAE입니다. `sample_audio=True`인 경우에만 필요합니다.

vocoder ([MMAudioVocoder](/docs/diffusers/main/ko/api/models/kandinsky6_vae#diffusers.MMAudioVocoder), *선택 사항*) : `audio_vae`가 디코딩한 멜 스펙트로그램을 웨이브폼으로 변환하는 데 사용되는 Vocoder. `sample_audio=True`인 경우에만 필요합니다.

Kandinsky 6을 사용한 텍스트/이미지-비디오-오디오 생성을 위한 Pipeline

Video and audio latents는 Qwen2.5-VL 텍스트 토큰과 CLIP 풀링 임베딩에 조건부화된 단일 멀티모달 트랜스포머에 의해 함께 디노이즈됩니다. 선택적인 참조 이미지는 첫 번째 프레임에 조건을 부여합니다.

이 모델은 [DiffusionPipeline](/docs/diffusers/main/ko/api/pipelines/overview#diffusers.DiffusionPipeline)에서 상속됩니다. 모든 파이프라인에 대해 구현된 일반적 메서드(다운로드, 저장, 특정 디바이스에서 실행 등)에 대해서는 상위 클래스 문서를 확인하세요.

#### __호출__[[diffusers.Kandinsky6TI2VAPipeline.__call__]]

```python
__call__(prompt: str | list[str] | None = None, image: typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor], NoneType] = None, negative_prompt: str | list[str] | None = None, height: int = 512, width: int = 768, num_frames: int = 121, frame_rate: float = 24.0, num_inference_steps: int = 50, timesteps: list[int] | None = None, sigmas: list[float] | None = None, guidance_scale: float = 5.0, num_videos_per_prompt: int = 1, generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = None, latents: typing.Optional[torch.Tensor] = None, audio_latents: typing.Optional[torch.Tensor] = None, prompt_embeds: typing.Optional[torch.Tensor] = None, pooled_prompt_embeds: typing.Optional[torch.Tensor] = None, negative_prompt_embeds: typing.Optional[torch.Tensor] = None, negative_pooled_prompt_embeds: typing.Optional[torch.Tensor] = None, sample_audio: bool = True, expand_prompts: bool = False, max_sequence_length: int = 1024, output_type: str = 'pil', return_dict: bool = True, callback_on_step_end: collections.abc.Callable[[int, int, dict], None] | None = None, callback_on_step_end_tensor_inputs: list = ['latents'])
```

[소스](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/kandinsky6/pipeline_kandinsky6_ti2va.py#L644)

**매개변수:**

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]`, *선택 사항*) : 이를 지원하는 스케줄러에 대한 사용자 정의 시그마.

guidance_scale (`float`, 기본값 `5.0`) : Classifier-free guidance scale. [PiflowScheduler](/docs/diffusers/main/ko/api/schedulers/piflow#diffusers.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`, *선택 사항*) : 사전 생성된 Qwen2.5-VL 텍스트 임베딩의 음수(negative) 값.

negative_pooled_prompt_embeds (`torch.Tensor`, *선택 사항*) : 미리 생성된 부정 CLIP 풀링 텍스트 임베딩.

sample_audio (`bool`, 기본값 `True`) : 동기화된 오디오를 생성할지 여부입니다. 파이프라인에 `audio_vae`와 `vocoder`가 있어야 합니다.

expand_prompts (`bool`, 기본값 `False`) : 인코딩 전에 [expand_prompts()](/docs/diffusers/main/ko/api/pipelines/kandinsky6#diffusers.Kandinsky6TI2VAPipeline.expand_prompts)로 프롬프트를 재작성할지 여부.

max_sequence_length (`int`, 기본값 `1024`) : 채팅 템플릿 적용 후 프롬프트 토큰의 최대 개수.

output_type (`str`, 기본값 `"pil"`) : 생성된 비디오의 출력 형식: `"pil"`, `"np"`, `"pt"` 또는 `"latent"`.

return_dict (`bool`, 기본값 `True`) : 일반 튜플 대신 [Kandinsky6TI2VAPipelineOutput](/docs/diffusers/main/ko/api/pipelines/kandinsky6#diffusers.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`에 전달되는 Tensor 입력. `_callback_tensor_inputs`의 부분 집합입니다.

**반환값:** [Kandinsky6TI2VAPipelineOutput](/docs/diffusers/main/ko/api/pipelines/kandinsky6#diffusers.Kandinsky6TI2VAPipelineOutput) 또는 `tuple`

생성된 비디오와 오디오; `return_dict=False`인 경우 `(frames, audio)` 튜플.

생성을 위한 pipeline의 호출 함수.

예:
```python
>>> 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[[diffusers.Kandinsky6TI2VAPipeline.encode_image]]

```python
encode_image(image: typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor]], height: int, width: int, device: device, dtype: dtype, num_videos_per_prompt: int = 1, generator: typing.Optional[torch.Generator] = None)
```

[소스](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/kandinsky6/pipeline_kandinsky6_ti2va.py#L551)

참조 이미지를 VAE의 `scaling_factor`로 스케일링된 `(batch_size, latent_height, latent_width, latent_channels)` 형태의 첫 프레임 latents로 인코딩합니다. PIL 이미지는 `height x width`로 리사이즈 및 중앙 크롭됩니다. 텐서와 배열은 이미 해당 크기를 가져야 합니다. latents는 배치 차원 방향으로 `num_videos_per_prompt`회 반복됩니다.

#### encode_prompt[[diffusers.Kandinsky6TI2VAPipeline.encode_prompt]]

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

[소스](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/kandinsky6/pipeline_kandinsky6_ti2va.py#L309)

**매개변수:**

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`, *선택 사항*) : 사전 생성된 Qwen2.5-VL 텍스트 임베딩의 음수(negative) 값.

negative_pooled_prompt_embeds (`torch.Tensor`, *선택 사항*) : 미리 생성된 부정 CLIP 풀링 텍스트 임베딩.

negative_prompt_attention_mask (`torch.Tensor`, *선택 사항*) : `negative_prompt_embeds`의 Boolean 패딩 마스크입니다.

max_sequence_length (`int`, 기본값 `1024`) : 채팅 템플릿 적용 후 프롬프트 토큰의 최대 개수.

device (`torch.device`, *선택 사항*) : 텍스트 인코더를 실행할 장치.

dtype (`torch.dtype`, *선택 사항*) : 반환되는 임베딩의 Dtype입니다.

프롬프트를 텍스트 인코더의 히든 상태로 인코딩합니다.

#### expand_prompts[[diffusers.Kandinsky6TI2VAPipeline.expand_prompts]]

```python
expand_prompts(prompt: str | list[str], tokenizer, text_encoder, device: device, image: PIL.Image.Image | list[PIL.Image.Image] | None = None, max_sequence_length: int = 1024, generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = None)
```

[소스](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/kandinsky6/pipeline_kandinsky6_ti2va.py#L412)

**매개변수:**

prompt (`str` 또는 `list[str]`) : 확장할 프롬프트 또는 프롬프트 목록.

tokenizer : Qwen2.5-VL 프로세서, 예: `pipe.tokenizer`.

text_encoder : Qwen2.5-VL 모델, 예: `pipe.text_encoder`.

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[[diffusers.Kandinsky6TI2VAPipeline.prepare_audio_latents]]

```python
prepare_audio_latents(batch_size: int, num_channels_latents: int, audio_length: int, dtype: dtype, device: device, generator: typing.Union[torch.Generator, list[torch.Generator], NoneType], audio_latents: typing.Optional[torch.Tensor] = None)
```

[소스](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/kandinsky6/pipeline_kandinsky6_ti2va.py#L607)

transformer의 `(batch_size, audio_length, channels)` 레이아웃으로 오디오 latents를 반환합니다. 사용자가 제공한 `audio_latents` 텐서는 `(batch_size, channels, audio_length)` 레이아웃으로 예상됩니다.

#### prepare_latents[[diffusers.Kandinsky6TI2VAPipeline.prepare_latents]]

```python
prepare_latents(batch_size: int, num_channels_latents: int, height: int, width: int, num_frames: int, dtype: dtype, device: device, generator: typing.Union[torch.Generator, list[torch.Generator], NoneType], latents: typing.Optional[torch.Tensor] = None)
```

[소스](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/kandinsky6/pipeline_kandinsky6_ti2va.py#L578)

transformer의 `(batch_size, num_frames, height, width, channels)` 레이아웃으로 비디오 latents를 반환합니다. 사용자가 제공한 `latents` 텐서는 `(batch_size, channels, num_frames, height, width)` 레이아웃으로 예상됩니다.

## Kandinsky6SRPipeline[[diffusers.Kandinsky6SRPipeline]]

#### diffusers.Kandinsky6SRPipeline[[diffusers.Kandinsky6SRPipeline]]

```python
diffusers.Kandinsky6SRPipeline(transformer: Kandinsky6SRTransformer3DModel, vae: Kandinsky6SRVAE, scheduler: diffusers.schedulers.scheduling_flow_match_euler_discrete.FlowMatchEulerDiscreteScheduler | diffusers.schedulers.scheduling_piflow.PiflowScheduler, latent_upscaler: diffusers.models.latent_upscaler.latent_upscaler_kandinsky6_sr.Kandinsky6SRLatentUpscalerBank | None = None)
```

[소스](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/kandinsky6/pipeline_kandinsky6_sr.py#L143)

**매개변수:**

transformer ([Kandinsky6SRTransformer3DModel](/docs/diffusers/main/ko/api/models/kandinsky6_transformer#diffusers.Kandinsky6SRTransformer3DModel)) : 잠재 타일을 정제하는 Transformer입니다.

vae ([Kandinsky6SRVAE](/docs/diffusers/main/ko/api/models/kandinsky6_vae#diffusers.Kandinsky6SRVAE)) : 입력 비디오를 인코딩하고 정제된 타일을 디코딩하는 데 사용되는 인과적 비디오 K-VAE입니다.

scheduler ([FlowMatchEulerDiscreteScheduler](/docs/diffusers/main/ko/api/schedulers/flow_match_euler_discrete#diffusers.FlowMatchEulerDiscreteScheduler) 또는 [PiflowScheduler](/docs/diffusers/main/ko/api/schedulers/piflow#diffusers.PiflowScheduler)) : `transformer`와 함께 타일의 노이즈를 제거하는 데 사용되는 스케줄러입니다. 디스틸된 체크포인트에는 [PiflowScheduler](/docs/diffusers/main/ko/api/schedulers/piflow#diffusers.PiflowScheduler)가 함께 제공됩니다.

latent_upscaler ([Kandinsky6SRLatentUpscalerBank](/docs/diffusers/main/ko/api/pipelines/kandinsky6#diffusers.Kandinsky6SRLatentUpscalerBank), *선택 사항*) : 지원되는 스케일에 대한 Latent 업스케일러입니다.

Kandinsky 6을 활용한 비디오 초해상도 파이프라인.

비디오는 겹치는 공간 타일로 분할되며, 각 타일은 모델이 학습된 타일 크기 중 하나(`transformer.config.tile_sizes`)에서 SR transformer에 의해 정제되고, 정제된 타일은 Hann 윈도우를 사용하여 다시 블렌딩됩니다. 파이프라인에 `latent_upscaler`가 있는 경우, 타일은 전체 비디오의 K-VAE 잠재 공간에서 잘라내어 잠재 공간에서 업스케일링됩니다. 그렇지 않으면 픽셀 타일이 이선형 보간으로 업스케일링된 후 인코딩됩니다.

이 모델은 [DiffusionPipeline](/docs/diffusers/main/ko/api/pipelines/overview#diffusers.DiffusionPipeline)에서 상속됩니다. 모든 파이프라인에 대해 구현된 일반적 메서드(다운로드, 저장, 특정 디바이스에서 실행 등)에 대해서는 상위 클래스 문서를 확인하세요.

#### __호출__[[diffusers.Kandinsky6SRPipeline.__call__]]

```python
__call__(video: typing.Union[list[PIL.Image.Image], list[list[PIL.Image.Image]], numpy.ndarray, torch.Tensor], resolution_scale: float = 2.25, num_inference_steps: int = 4, timesteps: list[int] | None = None, sigmas: list[float] | None = None, lq_noise_scale: float = 0.7, min_overlap: float = 0.2, tiles_batch_size: int = 1, generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = None, output_type: str = 'pil', return_dict: bool = True)
```

[소스](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/kandinsky6/pipeline_kandinsky6_sr.py#L228)

**매개변수:**

video (`list[PIL.Image.Image]`, `np.ndarray` 또는 `torch.Tensor`) : [preprocess_video()](/docs/diffusers/main/ko/api/video_processor#diffusers.VideoProcessor.preprocess_video)가 허용하는 모든 형식의 저해상도 비디오로, `1 + k * 4`개의 프레임을 가집니다. 크기는 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]`, *선택 사항*) : 이를 지원하는 스케줄러에 대한 사용자 정의 시그마.

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](/docs/diffusers/main/ko/api/pipelines/kandinsky6#diffusers.Kandinsky6SRPipelineOutput)를 반환할지 여부.

**반환값:** [Kandinsky6SRPipelineOutput](/docs/diffusers/main/ko/api/pipelines/kandinsky6#diffusers.Kandinsky6SRPipelineOutput) 또는 `tuple`

초해상도 영상. `return_dict=False`인 경우 1개 요소의 튜플입니다.

슈퍼 레졸루션을 위한 파이프라인의 호출 함수.

예:
```python
>>> 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)
```

#### decode_latents[[diffusers.Kandinsky6SRPipeline.decode_latents]]

```python
decode_latents(latents: Tensor)
```

[소스](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/kandinsky6/pipeline_kandinsky6_sr.py#L223)

스케일된 K-VAE latents를 `[-1, 1]` 범위의 `(batch_size, channels, num_frames, height, width)` 비디오로 디코딩합니다.

#### encode_video[[diffusers.Kandinsky6SRPipeline.encode_video]]

```python
encode_video(video: Tensor)
```

[소스](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/kandinsky6/pipeline_kandinsky6_sr.py#L213)

`[-1, 1]` 범위의 `(batch_size, channels, num_frames, height, width)` 비디오를 VAE의 `scaling_factor`로 스케일링된 K-VAE 잠재 변수로 인코딩합니다.

## Kandinsky6SRLatentUpscalerBank[[diffusers.Kandinsky6SRLatentUpscalerBank]]

#### diffusers.Kandinsky6SRLatentUpscalerBank[[diffusers.Kandinsky6SRLatentUpscalerBank]]

```python
diffusers.Kandinsky6SRLatentUpscalerBank(in_channels: int = 64, stage_channels: tuple[int, int, int] = (2048, 1024, 512), num_pre_blocks: int = 5, num_mid_blocks: int = 3, num_post_blocks: int = 3, num_x2_adapter_blocks: int = 2, scales: tuple[int, ...] = (2, 4), scaling_factor: float = 0.910344004631042)
```

[소스](https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/latent_upscaler/latent_upscaler_kandinsky6_sr.py#L251)

**매개변수:**

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)`) : 업스케일러를 제공하는 뱅크의 공간 스케일입니다.

scaling_factor (`float`, 기본값 `0.910344`) : 입력 latents가 가질 것으로 예상되는 스케일(K-VAE의 `scaling_factor`).

[Kandinsky6SRPipeline](/docs/diffusers/main/ko/api/pipelines/kandinsky6#diffusers.Kandinsky6SRPipeline)에서 사용하는 잠재 업스케일러 뱅크: 지원되는 공간 스케일마다 `Kandinsky6SRLatentUpscaler` 하나씩, K-VAE 잠재 변수에서 동작합니다.

#### forward[[diffusers.Kandinsky6SRLatentUpscalerBank.forward]]

```python
forward(latents: Tensor, scale: int, return_dict: bool = True)
```

[소스](https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/latent_upscaler/latent_upscaler_kandinsky6_sr.py#L305)

**매개변수:**

latents (`torch.Tensor`, shape `(batch_size, in_channels, num_frames, height, width)`) : `scaling_factor`로 스케일링된 K-VAE latents.

scale (`int`) : 공간 업스케일 팩터; `scales` 중 하나입니다.

return_dict (`bool`, 기본값 `True`) : 일반 튜플 대신 `~models.autoencoder_kl.DecoderOutput`를 반환할지 여부.

**반환값:**

`(batch_size, in_channels, num_frames, height * scale, width * scale)` 형태의 업스케일된 latents입니다.

## Kandinsky6TI2VAPipelineOutput[[diffusers.Kandinsky6TI2VAPipelineOutput]]

#### diffusers.Kandinsky6TI2VAPipelineOutput[[diffusers.Kandinsky6TI2VAPipelineOutput]]

```python
diffusers.Kandinsky6TI2VAPipelineOutput(frames: typing.Union[torch.Tensor, numpy.ndarray, list[list[PIL.Image.Image]]], audio: typing.Union[torch.Tensor, numpy.ndarray, NoneType] = None)
```

[소스](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/kandinsky6/pipeline_output.py#L25)

**매개변수:**

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)` 모양의 비디오 잠재 변수(latents)입니다.

audio (`torch.Tensor` 또는 `np.ndarray`, *선택 사항*) : 오디오 VAE의 샘플 레이트에서 `[-1, 1]` 범위의 `(batch_size, num_samples)` 모양으로 생성된 웨이브폼, 또는 오디오가 샘플링되지 않은 경우 `None`. `output_type="latent"`인 경우 `(batch_size, channels, audio_length)` 모양의 오디오 라텐트.

[Kandinsky6TI2VAPipeline](/docs/diffusers/main/ko/api/pipelines/kandinsky6#diffusers.Kandinsky6TI2VAPipeline)의 출력 클래스입니다.

## Kandinsky6SRPipelineOutput[[diffusers.Kandinsky6SRPipelineOutput]]

#### diffusers.Kandinsky6SRPipelineOutput[[diffusers.Kandinsky6SRPipelineOutput]]

```python
diffusers.Kandinsky6SRPipelineOutput(frames: typing.Union[torch.Tensor, numpy.ndarray, list[list[PIL.Image.Image]]])
```

[소스](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/kandinsky6/pipeline_output.py#L46)

**매개변수:**

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 텐서입니다.

[Kandinsky6SRPipeline](/docs/diffusers/main/ko/api/pipelines/kandinsky6#diffusers.Kandinsky6SRPipeline)의 출력 클래스입니다.

