# Kandinsky 5.0 이미지

[Kandinsky 5.0](https://arxiv.org/abs/2511.14993)은 비디오 및 이미지 생성을 위한 확산 모델 계열입니다.

Kandinsky 5.0 Image Lite는 경량 이미지 생성 모델(6B 파라미터)입니다.

이 모델은 몇 가지 주요 혁신을 도입합니다:
- **Latent diffusion pipeline**에 **Flow Matching**을 적용하여 학습 안정성 향상
- **Diffusion Transformer (DiT)**를 주요 생성 백본으로 사용하고 텍스트 임베딩에 대한 크로스 어텐션을 적용
- **Qwen2.5-VL**와 **CLIP**를 사용한 이중 텍스트 인코딩으로 포괄적인 텍스트 이해
- 효율적인 이미지 인코딩 및 디코딩을 위한 **Flux VAE**

원본 코드베이스는 [kandinskylab/Kandinsky-5](https://github.com/kandinskylab/Kandinsky-5)에서 찾을 수 있습니다.

> [!TIP]
> Hub의 [Kandinsky Lab](https://huggingface.co/kandinskylab) 조직에서 텍스트-비디오 생성을 위한 공식 모델 체크포인트를 확인해 보세요. 사전 학습, SFT, no-CFG, 증류된 변형이 포함되어 있습니다.

## 사용 가능한 모델

Kandinsky 5.0 Image Lite:

| model_id | 설명 | 사용 사례 |
|------------|-------------|-----------|
| [**kandinskylab/Kandinsky-5.0-T2I-Lite-sft-Diffusers**](https://huggingface.co/kandinskylab/Kandinsky-5.0-T2I-Lite-sft-Diffusers) | 6B 이미지 Supervised Fine-Tuned 모델 | 가장 높은 생성 품질 |
| [**kandinskylab/Kandinsky-5.0-I2I-Lite-sft-Diffusers**](https://huggingface.co/kandinskylab/Kandinsky-5.0-I2I-Lite-sft-Diffusers) | 6B 이미지 편집 SFT 모델 | 가장 높은 생성 품질 |
| [**kandinskylab/Kandinsky-5.0-T2I-Lite-pretrain-Diffusers**](https://huggingface.co/kandinskylab/Kandinsky-5.0-T2I-Lite-pretrain-Diffusers) | 6B 이미지 Base 사전 학습 모델 | 연구 및 미세 조정 |
| [**kandinskylab/Kandinsky-5.0-I2I-Lite-pretrain-Diffusers**](https://huggingface.co/kandinskylab/Kandinsky-5.0-I2I-Lite-pretrain-Diffusers) | 6B 이미지 편집 Base 사전 학습 모델 | 연구 및 미세 조정 |

## 사용 예시

### 기본 텍스트-이미지 생성

```python
import torch
from diffusers import Kandinsky5T2IPipeline

# Load the pipeline
model_id = "kandinskylab/Kandinsky-5.0-T2I-Lite-sft-Diffusers"
pipe = Kandinsky5T2IPipeline.from_pretrained(model_id)
_ = pipe.to(device='cuda',dtype=torch.bfloat16)  # or "mps", "xpu", "cpu"

# Generate image
prompt = "A fluffy, expressive cat wearing a bright red hat with a soft, slightly textured fabric. The hat should look cozy and well-fitted on the cat’s head. On the front of the hat, add clean, bold white text that reads “SWEET”, clearly visible and neatly centered. Ensure the overall lighting highlights the hat’s color and the cat’s fur details."

output = pipe(
    prompt=prompt,
    negative_prompt="",
    height=1024,
    width=1024,
    num_inference_steps=50,
    guidance_scale=3.5,
).image[0]
```

### 기본 이미지-이미지 생성

```python
import torch
from diffusers import Kandinsky5I2IPipeline
from diffusers.utils import load_image 
# Load the pipeline
model_id = "kandinskylab/Kandinsky-5.0-I2I-Lite-sft-Diffusers"
pipe = Kandinsky5I2IPipeline.from_pretrained(model_id)

_ = pipe.to(device='cuda',dtype=torch.bfloat16)  # or "mps", "xpu", "cpu"
pipe.enable_model_cpu_offload()                                               # <--- Enable CPU offloading for single GPU inference

# Edit the input image
image = load_image(
    "https://huggingface.co/kandinsky-community/kandinsky-3/resolve/main/assets/title.jpg?download=true"
)

prompt = "Change the background from a winter night scene to a bright summer day. Place the character on a sandy beach with clear blue sky, soft sunlight, and gentle waves in the distance. Replace the winter clothing with a light short-sleeved T-shirt (in soft pastel colors) and casual shorts. Ensure the character’s fur reflects warm daylight instead of cold winter tones. Add small beach details such as seashells, footprints in the sand, and a few scattered beach toys nearby. Keep the oranges in the scene, but place them naturally on the sand."
negative_prompt = ""

output = pipe(
    image=image,
    prompt=prompt,
    negative_prompt=negative_prompt,
    guidance_scale=3.5,
).image[0]
```

## Kandinsky5T2IPipeline[[diffusers.Kandinsky5T2IPipeline]]

#### diffusers.Kandinsky5T2IPipeline[[diffusers.Kandinsky5T2IPipeline]]

```python
diffusers.Kandinsky5T2IPipeline(transformer: Kandinsky5Transformer3DModel, vae: AutoencoderKL, text_encoder: Qwen2_5_VLForConditionalGeneration, tokenizer: Qwen2VLProcessor, text_encoder_2: CLIPTextModel, tokenizer_2: CLIPTokenizer, scheduler: FlowMatchEulerDiscreteScheduler)
```

[소스](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/kandinsky5/pipeline_kandinsky_t2i.py#L120)

**매개변수:**

transformer (`Kandinsky5Transformer3DModel`) : 인코딩된 이미지 레이턴트를 디노이즈하기 위한 조건부 Transformer입니다.

vae ([AutoencoderKL](/docs/diffusers/main/ko/api/models/autoencoderkl#diffusers.AutoencoderKL)) : [black-forest-labs/FLUX.1-dev (vae)](https://huggingface.co/black-forest-labs/FLUX.1-dev) 변분 오토인코더 모델로, 비디오를 잠재 표현으로 인코딩 및 디코딩합니다.

text_encoder (`Qwen2_5_VLForConditionalGeneration`) : 고정된 텍스트 인코더 [Qwen2.5-VL](https://huggingface.co/Qwen/Qwen2.5-VL-7B-Instruct).

tokenizer (`AutoProcessor`) : Qwen2.5-VL용 토크나이저

text_encoder_2 (`CLIPTextModel`) : 고정된 [CLIP](https://huggingface.co/docs/transformers/model_doc/clip#transformers.CLIPTextModel), 구체적으로 [clip-vit-large-patch14](https://huggingface.co/openai/clip-vit-large-patch14) 변형입니다.

tokenizer_2 (`CLIPTokenizer`) : CLIP용 토크나이저.

scheduler ([FlowMatchEulerDiscreteScheduler](/docs/diffusers/main/ko/api/schedulers/flow_match_euler_discrete#diffusers.FlowMatchEulerDiscreteScheduler)) : `transformer`와 함께 사용하여 인코딩된 이미지 라텐트를 디노이즈하는 데 사용되는 스케줄러입니다.

Kandinsky 5.0을 사용한 텍스트-이미지 생성을 위한 Pipeline

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

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

```python
__call__(prompt: str | list[str] = None, negative_prompt: str | list[str] | None = None, height: int = 1024, width: int = 1024, num_inference_steps: int = 50, guidance_scale: float = 3.5, num_images_per_prompt: int | None = 1, generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = None, latents: typing.Optional[torch.Tensor] = None, prompt_embeds_qwen: typing.Optional[torch.Tensor] = None, prompt_embeds_clip: typing.Optional[torch.Tensor] = None, negative_prompt_embeds_qwen: typing.Optional[torch.Tensor] = None, negative_prompt_embeds_clip: typing.Optional[torch.Tensor] = None, prompt_cu_seqlens: typing.Optional[torch.Tensor] = None, negative_prompt_cu_seqlens: typing.Optional[torch.Tensor] = None, output_type: str | None = 'pil', return_dict: bool = True, callback_on_step_end: typing.Optional[typing.Callable[[int, int, NoneType], diffusers.callbacks.PipelineCallback | diffusers.callbacks.MultiPipelineCallbacks]] = None, callback_on_step_end_tensor_inputs: list = ['latents'], max_sequence_length: int = 512)
```

[소스](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/kandinsky5/pipeline_kandinsky_t2i.py#L534)

**매개변수:**

prompt (`str` 또는 `list[str]`, *선택 사항*) : 이미지 생성을 안내할 프롬프트입니다. 정의되지 않은 경우 대신 `prompt_embeds`를 전달하세요.

negative_prompt (`str` 또는 `list[str]`, *선택 사항*) : 이미지 생성 과정에서 피해야 할 프롬프트입니다. 정의되지 않은 경우 대신 `negative_prompt_embeds`를 전달하세요. guidance를 사용하지 않을 때(`guidance_scale` < `1`)에는 무시됩니다.

height (`int`, 기본값 `1024`) : 생성된 이미지의 픽셀 단위 높이입니다.

width (`int`, 기본값 `1024`) : 생성된 이미지의 픽셀 단위 너비입니다.

num_inference_steps (`int`, 기본값 `50`) : 디노이징 단계 수.

guidance_scale (`float`, 기본값 `5.0`) : classifier-free guidance에서 정의된 guidance scale입니다.

num_images_per_prompt (`int`, *선택 사항*, 기본값 1) : 프롬프트당 생성할 이미지의 수.

generator (`torch.Generator` 또는 `list[torch.Generator]`, *선택 사항*) : 생성을 결정적으로 만들기 위한 torch 생성기입니다.

latents (`torch.Tensor`, *선택 사항*) : 미리 생성된 노이즈가 포함된 잠재 변수(latents).

prompt_embeds_qwen (`torch.Tensor`, *선택 사항*) : 미리 생성된 Qwen 텍스트 임베딩.

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

negative_prompt_embeds_qwen (`torch.Tensor`, *선택 사항*) : 사전 생성된 Qwen 부정 텍스트 임베딩.

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

prompt_cu_seqlens (`torch.Tensor`, *선택 사항*) : Qwen 긍정 프롬프트에 대한 사전 생성된 누적 시퀀스 길이입니다.

negative_prompt_cu_seqlens (`torch.Tensor`, *선택 사항*) : Qwen negative prompt에 사용할 사전 생성된 누적 시퀀스 길이입니다.

output_type (`str`, *선택 사항*, 기본값 `"pil"`) : 생성된 이미지의 출력 형식입니다.

return_dict (`bool`, *선택 사항*, 기본값 `True`) : `KandinskyImagePipelineOutput`를 반환할지 여부.

callback_on_step_end (`Callable`, `PipelineCallback`, `MultiPipelineCallbacks`, *선택 사항*) : 각 노이즈 제거 단계의 끝에서 호출되는 함수입니다.

callback_on_step_end_tensor_inputs (`List`, *선택 사항*) : `callback_on_step_end` 함수의 텐서 입력 목록입니다.

max_sequence_length (`int`, 기본값 `512`) : 텍스트 인코딩을 위한 최대 시퀀스 길이입니다.

**반환값:** `~KandinskyImagePipelineOutput` 또는 `tuple`

`return_dict`가 `True`인 경우 `KandinskyImagePipelineOutput`가 반환되고, 그렇지 않으면 첫 번째 요소가 생성된 이미지의 목록인 `tuple`이 반환됩니다.

이미지 생성을 위한 pipeline의 call 함수입니다.

예:

```python
>>> import torch
>>> from diffusers import Kandinsky5T2IPipeline

>>> # Available models:
>>> # kandinskylab/Kandinsky-5.0-T2I-Lite-sft-Diffusers
>>> # kandinskylab/Kandinsky-5.0-T2I-Lite-pretrain-Diffusers

>>> model_id = "kandinskylab/Kandinsky-5.0-T2I-Lite-sft-Diffusers"
>>> pipe = Kandinsky5T2IPipeline.from_pretrained(model_id, torch_dtype=torch.bfloat16)
>>> pipe = pipe.to("cuda")

>>> prompt = "A cat and a dog baking a cake together in a kitchen."

>>> output = pipe(
...     prompt=prompt,
...     negative_prompt="",
...     height=1024,
...     width=1024,
...     num_inference_steps=50,
...     guidance_scale=3.5,
... ).frames[0]
```

#### check_inputs[[diffusers.Kandinsky5T2IPipeline.check_inputs]]

```python
check_inputs(prompt, negative_prompt, height, width, prompt_embeds_qwen = None, prompt_embeds_clip = None, negative_prompt_embeds_qwen = None, negative_prompt_embeds_clip = None, prompt_cu_seqlens = None, negative_prompt_cu_seqlens = None, callback_on_step_end_tensor_inputs = None, max_sequence_length = None)
```

[소스](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/kandinsky5/pipeline_kandinsky_t2i.py#L380)

**매개변수:**

prompt : 입력 프롬프트

negative_prompt : 가이던스를 위한 네거티브 프롬프트

height : 이미지 높이

width : 이미지 너비

prompt_embeds_qwen : 사전 계산된 Qwen 프롬프트 임베딩

prompt_embeds_clip : 사전 계산된 CLIP 프롬프트 임베딩

negative_prompt_embeds_qwen : 사전 계산된 Qwen 부정 프롬프트 임베딩

negative_prompt_embeds_clip : 사전 계산된 CLIP 부정 프롬프트 임베딩

prompt_cu_seqlens : Qwen 긍정 프롬프트에 대한 사전 계산된 누적 시퀀스 길이

negative_prompt_cu_seqlens : Qwen negative prompt에 대한 사전 계산된 누적 시퀀스 길이

callback_on_step_end_tensor_inputs : Callback 텐서 입력

**예외:** ``ValueError``

- ``ValueError`` -- 입력이 잘못된 경우

파이프라인의 입력 매개변수를 검증합니다.

#### encode_prompt[[diffusers.Kandinsky5T2IPipeline.encode_prompt]]

```python
encode_prompt(prompt: str | list[str], num_images_per_prompt: int = 1, max_sequence_length: int = 512, device: typing.Optional[torch.device] = None, dtype: typing.Optional[torch.dtype] = None)
```

[소스](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/kandinsky5/pipeline_kandinsky_t2i.py#L289)

**매개변수:**

prompt (`str` 또는 `list[str]`) : 인코딩할 프롬프트.

num_images_per_prompt (`int`, *선택 사항*, 기본값 1) : 프롬프트당 생성할 이미지 수.

max_sequence_length (`int`, *선택 사항*, 기본값 512) : 텍스트 인코딩을 위한 최대 시퀀스 길이. 1024보다 작아야 합니다

device (`torch.device`, *선택 사항*) : Torch 장치.

dtype (`torch.dtype`, *선택 사항*) : Torch dtype.

**반환값:** tuple[torch.Tensor, torch.Tensor, torch.Tensor]

- shape (batch_size * num_images_per_prompt, sequence_length, embedding_dim)인 Qwen 텍스트 임베딩
- shape (batch_size * num_images_per_prompt, clip_embedding_dim)인 CLIP pooled embeddings
- Qwen 임베딩의 누적 시퀀스 길이(`cu_seqlens`), shape (batch_size * num_images_per_prompt + 1,)

단일 프롬프트(양성 또는 음성)를 텍스트 인코더의 히든 상태로 인코딩합니다.

이 메서드는 Qwen2.5-VL과 CLIP 텍스트 인코더의 임베딩을 결합하여 이미지 생성을 위한 포괄적인 텍스트 표현을 생성합니다.

#### prepare_latents[[diffusers.Kandinsky5T2IPipeline.prepare_latents]]

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

[소스](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/kandinsky5/pipeline_kandinsky_t2i.py#L469)

**매개변수:**

batch_size (int) : 생성할 이미지의 수

num_channels_latents (int) : 잠재 공간의 채널 수

height (int) : 생성된 이미지의 높이

width (int) : 생성된 이미지의 너비

dtype (torch.dtype) : latents의 데이터 유형

device (torch.device) : latents를 생성할 Device

generator (torch.Generator) : 난수 생성기

latents (torch.Tensor) : 사용할 기존 latents

**반환값:** `torch.Tensor`

준비된 잠재 텐서

텍스트-이미지 생성을 위한 초기 잠재 변수를 준비합니다.

이 메서드는 랜덤 노이즈 라텐트를 생성합니다

## Kandinsky5I2IPipeline[[diffusers.Kandinsky5I2IPipeline]]

#### diffusers.Kandinsky5I2IPipeline[[diffusers.Kandinsky5I2IPipeline]]

```python
diffusers.Kandinsky5I2IPipeline(transformer: Kandinsky5Transformer3DModel, vae: AutoencoderKL, text_encoder: Qwen2_5_VLForConditionalGeneration, tokenizer: Qwen2VLProcessor, text_encoder_2: CLIPTextModel, tokenizer_2: CLIPTokenizer, scheduler: FlowMatchEulerDiscreteScheduler)
```

[소스](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/kandinsky5/pipeline_kandinsky_i2i.py#L120)

**매개변수:**

transformer (`Kandinsky5Transformer3DModel`) : 인코딩된 이미지 레이턴트를 디노이즈하기 위한 조건부 Transformer입니다.

vae ([AutoencoderKL](/docs/diffusers/main/ko/api/models/autoencoderkl#diffusers.AutoencoderKL)) : [black-forest-labs/FLUX.1-dev (vae)](https://huggingface.co/black-forest-labs/FLUX.1-dev) 변분 오토인코더 모델로, 비디오를 잠재 표현으로 인코딩 및 디코딩합니다.

text_encoder (`Qwen2_5_VLForConditionalGeneration`) : 고정된 텍스트 인코더 [Qwen2.5-VL](https://huggingface.co/Qwen/Qwen2.5-VL-7B-Instruct).

tokenizer (`AutoProcessor`) : Qwen2.5-VL용 토크나이저

text_encoder_2 (`CLIPTextModel`) : 고정된 [CLIP](https://huggingface.co/docs/transformers/model_doc/clip#transformers.CLIPTextModel), 구체적으로 [clip-vit-large-patch14](https://huggingface.co/openai/clip-vit-large-patch14) 변형입니다.

tokenizer_2 (`CLIPTokenizer`) : CLIP용 토크나이저.

scheduler ([FlowMatchEulerDiscreteScheduler](/docs/diffusers/main/ko/api/schedulers/flow_match_euler_discrete#diffusers.FlowMatchEulerDiscreteScheduler)) : `transformer`와 함께 사용하여 인코딩된 이미지 라텐트를 디노이즈하는 데 사용되는 스케줄러입니다.

Kandinsky 5.0을 사용한 이미지-이미지 생성을 위한 Pipeline

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

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

```python
__call__(image: typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor]], prompt: str | list[str] = None, negative_prompt: str | list[str] | None = None, height: int | None = None, width: int | None = None, num_inference_steps: int = 50, guidance_scale: float = 3.5, num_images_per_prompt: int | None = 1, generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = None, latents: typing.Optional[torch.Tensor] = None, prompt_embeds_qwen: typing.Optional[torch.Tensor] = None, prompt_embeds_clip: typing.Optional[torch.Tensor] = None, negative_prompt_embeds_qwen: typing.Optional[torch.Tensor] = None, negative_prompt_embeds_clip: typing.Optional[torch.Tensor] = None, prompt_cu_seqlens: typing.Optional[torch.Tensor] = None, negative_prompt_cu_seqlens: typing.Optional[torch.Tensor] = None, output_type: str | None = 'pil', return_dict: bool = True, callback_on_step_end: typing.Optional[typing.Callable[[int, int, NoneType], diffusers.callbacks.PipelineCallback | diffusers.callbacks.MultiPipelineCallbacks]] = None, callback_on_step_end_tensor_inputs: list = ['latents'], max_sequence_length: int = 1024)
```

[소스](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/kandinsky5/pipeline_kandinsky_i2i.py#L567)

**매개변수:**

image (`PipelineImageInput`) : 생성을 조건화할 입력 이미지. 이미지, 이미지 목록 또는 `torch.Tensor`여야 합니다.

prompt (`str` 또는 `list[str]`, *선택 사항*) : 이미지 생성을 안내할 프롬프트입니다. 정의되지 않은 경우 대신 `prompt_embeds`를 전달하세요.

negative_prompt (`str` 또는 `list[str]`, *선택 사항*) : 이미지 생성 과정에서 피해야 할 프롬프트입니다. 정의되지 않은 경우 대신 `negative_prompt_embeds`를 전달하세요. guidance를 사용하지 않을 때(`guidance_scale` < `1`)에는 무시됩니다.

height (`int`) : 생성된 이미지의 픽셀 단위 높이.

width (`int`) : 생성된 이미지의 픽셀 단위 너비.

num_inference_steps (`int`, 기본값 `50`) : 디노이징 단계 수.

guidance_scale (`float`, 기본값 `5.0`) : classifier-free guidance에서 정의된 guidance scale입니다.

num_images_per_prompt (`int`, *선택 사항*, 기본값 1) : 프롬프트당 생성할 이미지의 수.

generator (`torch.Generator` 또는 `list[torch.Generator]`, *선택 사항*) : 생성을 결정적으로 만들기 위한 torch 생성기입니다.

latents (`torch.Tensor`, *선택 사항*) : 미리 생성된 노이즈가 포함된 잠재 변수(latents).

prompt_embeds_qwen (`torch.Tensor`, *선택 사항*) : 미리 생성된 Qwen 텍스트 임베딩.

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

negative_prompt_embeds_qwen (`torch.Tensor`, *선택 사항*) : 사전 생성된 Qwen 부정 텍스트 임베딩.

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

prompt_cu_seqlens (`torch.Tensor`, *선택 사항*) : Qwen 긍정 프롬프트에 대한 사전 생성된 누적 시퀀스 길이입니다.

negative_prompt_cu_seqlens (`torch.Tensor`, *선택 사항*) : Qwen negative prompt에 사용할 사전 생성된 누적 시퀀스 길이입니다.

output_type (`str`, *선택 사항*, 기본값 `"pil"`) : 생성된 이미지의 출력 형식입니다.

return_dict (`bool`, *선택 사항*, 기본값 `True`) : `KandinskyImagePipelineOutput`를 반환할지 여부.

callback_on_step_end (`Callable`, `PipelineCallback`, `MultiPipelineCallbacks`, *선택 사항*) : 각 노이즈 제거 단계의 끝에서 호출되는 함수입니다.

callback_on_step_end_tensor_inputs (`List`, *선택 사항*) : `callback_on_step_end` 함수의 텐서 입력 목록입니다.

max_sequence_length (`int`, 기본값 `1024`) : 텍스트 및 이미지 qwen 인코딩을 위한 최대 시퀀스 길이. 1024보다 작아야 합니다

**반환값:** `~KandinskyImagePipelineOutput` 또는 `tuple`

`return_dict`가 `True`인 경우 `KandinskyImagePipelineOutput`가 반환되고, 그렇지 않으면 첫 번째 요소가 생성된 이미지의 목록인 `tuple`이 반환됩니다.

이미지-이미지 생성을 위한 pipeline의 호출 함수.

예:

```python
>>> import torch
>>> from diffusers import Kandinsky5I2IPipeline

>>> # Available models:
>>> # kandinskylab/Kandinsky-5.0-I2I-Lite-sft-Diffusers
>>> # kandinskylab/Kandinsky-5.0-I2I-Lite-pretrain-Diffusers

>>> model_id = "kandinskylab/Kandinsky-5.0-I2I-Lite-sft-Diffusers"
>>> pipe = Kandinsky5I2IPipeline.from_pretrained(model_id, torch_dtype=torch.bfloat16)
>>> pipe = pipe.to("cuda")

>>> prompt = "A cat and a dog baking a cake together in a kitchen."

>>> output = pipe(
...     prompt=prompt,
...     negative_prompt="",
...     height=1024,
...     width=1024,
...     num_inference_steps=50,
...     guidance_scale=3.5,
... ).frames[0]
```

#### check_inputs[[diffusers.Kandinsky5I2IPipeline.check_inputs]]

```python
check_inputs(prompt, negative_prompt, image, height, width, prompt_embeds_qwen = None, prompt_embeds_clip = None, negative_prompt_embeds_qwen = None, negative_prompt_embeds_clip = None, prompt_cu_seqlens = None, negative_prompt_cu_seqlens = None, callback_on_step_end_tensor_inputs = None, max_sequence_length = None)
```

[소스](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/kandinsky5/pipeline_kandinsky_i2i.py#L388)

**매개변수:**

prompt : 입력 프롬프트

negative_prompt : 가이던스를 위한 네거티브 프롬프트

image : 조건부 생성을 위한 입력 이미지

height : 이미지 높이

width : 이미지 너비

prompt_embeds_qwen : 사전 계산된 Qwen 프롬프트 임베딩

prompt_embeds_clip : 사전 계산된 CLIP 프롬프트 임베딩

negative_prompt_embeds_qwen : 사전 계산된 Qwen 부정 프롬프트 임베딩

negative_prompt_embeds_clip : 사전 계산된 CLIP 부정 프롬프트 임베딩

prompt_cu_seqlens : Qwen 긍정 프롬프트에 대한 사전 계산된 누적 시퀀스 길이

negative_prompt_cu_seqlens : Qwen negative prompt에 대한 사전 계산된 누적 시퀀스 길이

callback_on_step_end_tensor_inputs : Callback 텐서 입력

**예외:** ``ValueError``

- ``ValueError`` -- 입력이 잘못된 경우

파이프라인의 입력 매개변수를 검증합니다.

#### encode_prompt[[diffusers.Kandinsky5I2IPipeline.encode_prompt]]

```python
encode_prompt(prompt: str | list[str], image: Tensor, num_images_per_prompt: int = 1, 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/kandinsky5/pipeline_kandinsky_i2i.py#L295)

**매개변수:**

prompt (`str` 또는 `list[str]`) : 인코딩할 프롬프트.

num_images_per_prompt (`int`, *선택 사항*, 기본값 1) : 프롬프트당 생성할 이미지 수.

max_sequence_length (`int`, *선택 사항*, 기본값 1024) : 텍스트 인코딩을 위한 최대 시퀀스 길이. 1024보다 작아야 합니다

device (`torch.device`, *선택 사항*) : Torch 장치.

dtype (`torch.dtype`, *선택 사항*) : Torch dtype.

**반환값:** tuple[torch.Tensor, torch.Tensor, torch.Tensor]

- shape (batch_size * num_images_per_prompt, sequence_length, embedding_dim)인 Qwen 텍스트 임베딩
- shape (batch_size * num_images_per_prompt, clip_embedding_dim)인 CLIP pooled embeddings
- Qwen 임베딩의 누적 시퀀스 길이(`cu_seqlens`), shape (batch_size * num_images_per_prompt + 1,)

단일 프롬프트(양성 또는 음성)를 텍스트 인코더의 히든 상태로 인코딩합니다.

이 메서드는 Qwen2.5-VL과 CLIP 텍스트 인코더의 임베딩을 결합하여 이미지 생성을 위한 포괄적인 텍스트 표현을 생성합니다.

#### prepare_latents[[diffusers.Kandinsky5I2IPipeline.prepare_latents]]

```python
prepare_latents(image: typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor]], batch_size: int, num_channels_latents: int = 16, height: int = 1024, width: int = 1024, dtype: typing.Optional[torch.dtype] = None, device: typing.Optional[torch.device] = None, generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = None, latents: typing.Optional[torch.Tensor] = None)
```

[소스](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/kandinsky5/pipeline_kandinsky_i2i.py#L482)

**매개변수:**

image (PipelineImageInput) : 생성을 조건화할 입력 이미지

batch_size (int) : 생성할 이미지의 수

num_channels_latents (int) : 잠재 공간의 채널 수

height (int) : 생성된 이미지의 높이

width (int) : 생성된 이미지의 너비

dtype (torch.dtype) : latents의 데이터 유형

device (torch.device) : latents를 생성할 Device

generator (torch.Generator) : 난수 생성기

latents (torch.Tensor) : 사용할 기존 latents

**반환값:** `torch.Tensor`

인코딩된 이미지의 준비된 잠재 텐서

이미지-이미지 생성을 위한 초기 잠재 변수를 준비합니다.

이 메서드는 인코딩된 이미지와 함께 랜덤 노이즈 라텐트를 생성합니다.

## 인용
```bibtex
@misc{kandinsky2025,
    author = {Alexander Belykh and Alexander Varlamov and Alexey Letunovskiy and Anastasia Aliaskina and Anastasia Maltseva and Anastasiia Kargapoltseva and Andrey Shutkin and Anna Averchenkova and Anna Dmitrienko and Bulat Akhmatov and Denis Dimitrov and Denis Koposov and Denis Parkhomenko and Dmitrii and Ilya Vasiliev and Ivan Kirillov and Julia Agafonova and Kirill Chernyshev and Kormilitsyn Semen and Lev Novitskiy and Maria Kovaleva and Mikhail Mamaev and Mikhailov and Nikita Kiselev and Nikita Osterov and Nikolai Gerasimenko and Nikolai Vaulin and Olga Kim and Olga Vdovchenko and Polina Gavrilova and Polina Mikhailova and Tatiana Nikulina and Viacheslav Vasilev and Vladimir Arkhipkin and Vladimir Korviakov and Vladimir Polovnikov and Yury Kolabushin},
    title = {Kandinsky 5.0: A family of diffusion models for Video & Image generation},
    howpublished = {\url{https://github.com/kandinskylab/Kandinsky-5}},
    year = 2025
}
```

