Diffusers documentation

Kandinsky 5.0 이미지

You are viewing main version, which requires installation from source. If you'd like regular pip install, checkout the latest stable version (v0.42.1).
Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

Kandinsky 5.0 이미지

Kandinsky 5.0은 비디오 및 이미지 생성을 위한 확산 모델 계열입니다.

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

이 모델은 몇 가지 주요 혁신을 도입합니다:

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

원본 코드베이스는 kandinskylab/Kandinsky-5에서 찾을 수 있습니다.

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

사용 가능한 모델

Kandinsky 5.0 Image Lite:

model_id설명사용 사례
kandinskylab/Kandinsky-5.0-T2I-Lite-sft-Diffusers6B 이미지 Supervised Fine-Tuned 모델가장 높은 생성 품질
kandinskylab/Kandinsky-5.0-I2I-Lite-sft-Diffusers6B 이미지 편집 SFT 모델가장 높은 생성 품질
kandinskylab/Kandinsky-5.0-T2I-Lite-pretrain-Diffusers6B 이미지 Base 사전 학습 모델연구 및 미세 조정
kandinskylab/Kandinsky-5.0-I2I-Lite-pretrain-Diffusers6B 이미지 편집 Base 사전 학습 모델연구 및 미세 조정

사용 예시

기본 텍스트-이미지 생성

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]

기본 이미지-이미지 생성

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

class diffusers.Kandinsky5T2IPipeline

< >

( transformer: Kandinsky5Transformer3DModelvae: AutoencoderKLtext_encoder: Qwen2_5_VLForConditionalGenerationtokenizer: Qwen2VLProcessortext_encoder_2: CLIPTextModeltokenizer_2: CLIPTokenizerscheduler: FlowMatchEulerDiscreteScheduler )

매개변수

  • transformer (Kandinsky5Transformer3DModel) — 인코딩된 이미지 latents의 노이즈를 제거하기 위한 조건부 Transformer입니다.
  • vae (AutoencoderKL) — latent 표현으로 비디오를 인코딩 및 디코딩하기 위한 Variational Auto-Encoder 모델 black-forest-labs/FLUX.1-dev (vae).
  • text_encoder (Qwen2_5_VLForConditionalGeneration) — 동결된 텍스트 인코더 Qwen2.5-VL.
  • tokenizer (AutoProcessor) — Qwen2.5-VL용 토크나이저.
  • text_encoder_2 (CLIPTextModel) — 동결된 CLIP, 구체적으로 clip-vit-large-patch14 변형입니다.
  • tokenizer_2 (CLIPTokenizer) — CLIP용 토크나이저입니다.
  • scheduler (FlowMatchEulerDiscreteScheduler) — transformer와 함께 사용하여 인코딩된 이미지 latents의 노이즈를 제거하는 데 사용되는 스케줄러.

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

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

__call__

< >

( prompt: str | list[str] = Nonenegative_prompt: str | list[str] | None = Noneheight: int = 1024width: int = 1024num_inference_steps: int = 50guidance_scale: float = 3.5num_images_per_prompt: int | None = 1generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = Nonelatents: typing.Optional[torch.Tensor] = Noneprompt_embeds_qwen: typing.Optional[torch.Tensor] = Noneprompt_embeds_clip: typing.Optional[torch.Tensor] = Nonenegative_prompt_embeds_qwen: typing.Optional[torch.Tensor] = Nonenegative_prompt_embeds_clip: typing.Optional[torch.Tensor] = Noneprompt_cu_seqlens: typing.Optional[torch.Tensor] = Nonenegative_prompt_cu_seqlens: typing.Optional[torch.Tensor] = Noneoutput_type: str | None = 'pil'return_dict: bool = Truecallback_on_step_end: typing.Optional[typing.Callable[[int, int, NoneType], diffusers.callbacks.PipelineCallback | diffusers.callbacks.MultiPipelineCallbacks]] = Nonecallback_on_step_end_tensor_inputs: list = ['latents']max_sequence_length: int = 512 ) → ~KandinskyImagePipelineOutput or tuple

매개변수

  • 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 positive prompt에 대한 사전 생성된 누적 시퀀스 길이입니다.
  • 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 함수입니다.

예:

>>> 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

< >

( promptnegative_promptheightwidthprompt_embeds_qwen = Noneprompt_embeds_clip = Nonenegative_prompt_embeds_qwen = Nonenegative_prompt_embeds_clip = Noneprompt_cu_seqlens = Nonenegative_prompt_cu_seqlens = Nonecallback_on_step_end_tensor_inputs = Nonemax_sequence_length = None )

매개변수

  • prompt — 입력 프롬프트
  • negative_prompt — 가이던스를 위한 네거티브 프롬프트
  • height — 이미지 높이
  • width — 이미지 너비
  • prompt_embeds_qwen — 사전 계산된 Qwen 프롬프트 임베딩
  • prompt_embeds_clip — 사전 계산된 CLIP 프롬프트 임베딩
  • negative_prompt_embeds_qwen — 사전 계산된 Qwen negative prompt 임베딩
  • negative_prompt_embeds_clip — 사전 계산된 CLIP negative prompt 임베딩
  • prompt_cu_seqlens — Qwen positive prompt에 대한 사전 계산된 누적 시퀀스 길이
  • negative_prompt_cu_seqlens — Qwen negative prompt에 대한 사전 계산된 누적 시퀀스 길이
  • callback_on_step_end_tensor_inputs — Callback 텐서 입력

발생

ValueError

  • ValueError — 입력이 잘못된 경우

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

encode_prompt

< >

( prompt: str | list[str]num_images_per_prompt: int = 1max_sequence_length: int = 512device: typing.Optional[torch.device] = Nonedtype: typing.Optional[torch.dtype] = None ) → tuple[torch.Tensor, torch.Tensor, torch.Tensor]

매개변수

  • 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)로, 형태는 (batch_size * num_images_per_prompt + 1,)입니다

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

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

prepare_latents

< >

( batch_size: intnum_channels_latents: int = 16height: int = 1024width: int = 1024dtype: typing.Optional[torch.dtype] = Nonedevice: typing.Optional[torch.device] = Nonegenerator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = Nonelatents: typing.Optional[torch.Tensor] = None ) → torch.Tensor

매개변수

  • 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

class diffusers.Kandinsky5I2IPipeline

< >

( transformer: Kandinsky5Transformer3DModelvae: AutoencoderKLtext_encoder: Qwen2_5_VLForConditionalGenerationtokenizer: Qwen2VLProcessortext_encoder_2: CLIPTextModeltokenizer_2: CLIPTokenizerscheduler: FlowMatchEulerDiscreteScheduler )

매개변수

  • transformer (Kandinsky5Transformer3DModel) — 인코딩된 이미지 latents의 노이즈를 제거하기 위한 조건부 Transformer입니다.
  • vae (AutoencoderKL) — latent 표현으로 비디오를 인코딩 및 디코딩하기 위한 Variational Auto-Encoder 모델 black-forest-labs/FLUX.1-dev (vae).
  • text_encoder (Qwen2_5_VLForConditionalGeneration) — 동결된 텍스트 인코더 Qwen2.5-VL.
  • tokenizer (AutoProcessor) — Qwen2.5-VL용 토크나이저.
  • text_encoder_2 (CLIPTextModel) — 동결된 CLIP, 구체적으로 clip-vit-large-patch14 변형입니다.
  • tokenizer_2 (CLIPTokenizer) — CLIP용 토크나이저입니다.
  • scheduler (FlowMatchEulerDiscreteScheduler) — transformer와 함께 사용하여 인코딩된 이미지 latents의 노이즈를 제거하는 데 사용되는 스케줄러.

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

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

__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] = Nonenegative_prompt: str | list[str] | None = Noneheight: int | None = Nonewidth: int | None = Nonenum_inference_steps: int = 50guidance_scale: float = 3.5num_images_per_prompt: int | None = 1generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = Nonelatents: typing.Optional[torch.Tensor] = Noneprompt_embeds_qwen: typing.Optional[torch.Tensor] = Noneprompt_embeds_clip: typing.Optional[torch.Tensor] = Nonenegative_prompt_embeds_qwen: typing.Optional[torch.Tensor] = Nonenegative_prompt_embeds_clip: typing.Optional[torch.Tensor] = Noneprompt_cu_seqlens: typing.Optional[torch.Tensor] = Nonenegative_prompt_cu_seqlens: typing.Optional[torch.Tensor] = Noneoutput_type: str | None = 'pil'return_dict: bool = Truecallback_on_step_end: typing.Optional[typing.Callable[[int, int, NoneType], diffusers.callbacks.PipelineCallback | diffusers.callbacks.MultiPipelineCallbacks]] = Nonecallback_on_step_end_tensor_inputs: list = ['latents']max_sequence_length: int = 1024 ) → ~KandinskyImagePipelineOutput or tuple

매개변수

  • 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 positive prompt에 대한 사전 생성된 누적 시퀀스 길이입니다.
  • 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의 호출 함수.

예:

>>> 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

< >

( promptnegative_promptimageheightwidthprompt_embeds_qwen = Noneprompt_embeds_clip = Nonenegative_prompt_embeds_qwen = Nonenegative_prompt_embeds_clip = Noneprompt_cu_seqlens = Nonenegative_prompt_cu_seqlens = Nonecallback_on_step_end_tensor_inputs = Nonemax_sequence_length = None )

매개변수

  • prompt — 입력 프롬프트
  • negative_prompt — 가이던스를 위한 네거티브 프롬프트
  • image — 조건부 생성을 위한 입력 이미지
  • height — 이미지 높이
  • width — 이미지 너비
  • prompt_embeds_qwen — 사전 계산된 Qwen 프롬프트 임베딩
  • prompt_embeds_clip — 사전 계산된 CLIP 프롬프트 임베딩
  • negative_prompt_embeds_qwen — 사전 계산된 Qwen negative prompt 임베딩
  • negative_prompt_embeds_clip — 사전 계산된 CLIP negative prompt 임베딩
  • prompt_cu_seqlens — Qwen positive prompt에 대한 사전 계산된 누적 시퀀스 길이
  • negative_prompt_cu_seqlens — Qwen negative prompt에 대한 사전 계산된 누적 시퀀스 길이
  • callback_on_step_end_tensor_inputs — Callback 텐서 입력

발생

ValueError

  • ValueError — 입력이 잘못된 경우

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

encode_prompt

< >

( prompt: str | list[str]image: Tensornum_images_per_prompt: int = 1max_sequence_length: int = 1024device: typing.Optional[torch.device] = Nonedtype: typing.Optional[torch.dtype] = None ) → tuple[torch.Tensor, torch.Tensor, torch.Tensor]

매개변수

  • 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)로, 형태는 (batch_size * num_images_per_prompt + 1,)입니다

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

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

prepare_latents

< >

( image: typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor]]batch_size: intnum_channels_latents: int = 16height: int = 1024width: int = 1024dtype: typing.Optional[torch.dtype] = Nonedevice: typing.Optional[torch.device] = Nonegenerator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = Nonelatents: typing.Optional[torch.Tensor] = None ) → torch.Tensor

매개변수

  • 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

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

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

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

인용

@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
}
Update on GitHub