Buckets:
| # Kandinsky 5.0 Gambar | |
| [Kandinsky 5.0](https://arxiv.org/abs/2511.14993) adalah keluarga model difusi untuk generasi Video & Gambar. | |
| Kandinsky 5.0 Image Lite adalah model generasi gambar ringan (6B parameter). | |
| Model ini memperkenalkan beberapa inovasi utama: | |
| - **Pipeline difusi laten** dengan **Flow Matching** untuk stabilitas pelatihan yang lebih baik | |
| - **Diffusion Transformer (DiT)** sebagai tulang punggung generatif utama dengan cross-attention ke embedding teks | |
| - Pengkodean teks ganda menggunakan **Qwen2.5-VL** dan **CLIP** untuk pemahaman teks yang komprehensif | |
| - **Flux VAE** untuk pengkodean dan penguraian gambar yang efisien | |
| Kodebase asli dapat ditemukan di [kandinskylab/Kandinsky-5](https://github.com/kandinskylab/Kandinsky-5). | |
| > [!TIP] | |
| > Lihat organisasi [Kandinsky Lab](https://huggingface.co/kandinskylab) di Hub untuk checkpoint model resmi untuk generasi teks-ke-video, termasuk varian pretrained, SFT, no-CFG, dan distilled. | |
| ## Model yang Tersedia | |
| Kandinsky 5.0 Image Lite: | |
| | model_id | Deskripsi | Kasus Penggunaan | | |
| |------------|-------------|-----------| | |
| | [**kandinskylab/Kandinsky-5.0-T2I-Lite-sft-Diffusers**](https://huggingface.co/kandinskylab/Kandinsky-5.0-T2I-Lite-sft-Diffusers) | Model Supervised Fine-Tuned gambar 6B | Kualitas generasi tertinggi | | |
| | [**kandinskylab/Kandinsky-5.0-I2I-Lite-sft-Diffusers**](https://huggingface.co/kandinskylab/Kandinsky-5.0-I2I-Lite-sft-Diffusers) | Model Supervised Fine-Tuned untuk pengeditan gambar 6B | Kualitas generasi tertinggi | | |
| | [**kandinskylab/Kandinsky-5.0-T2I-Lite-pretrain-Diffusers**](https://huggingface.co/kandinskylab/Kandinsky-5.0-T2I-Lite-pretrain-Diffusers) | Model pra-terlatih dasar gambar 6B | Penelitian dan penyesuaian halus | | |
| | [**kandinskylab/Kandinsky-5.0-I2I-Lite-pretrain-Diffusers**](https://huggingface.co/kandinskylab/Kandinsky-5.0-I2I-Lite-pretrain-Diffusers) | Model pralatih dasar pengeditan gambar 6B | Penelitian dan penyesuaian halus | | |
| ## Contoh Penggunaan | |
| ### Generasi Teks-ke-Gambar Dasar | |
| ```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] | |
| ``` | |
| ### Generasi Gambar-dari-Gambar Dasar | |
| ```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) | |
| ``` | |
| [Sumber](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/kandinsky5/pipeline_kandinsky_t2i.py#L120) | |
| **Parameter:** | |
| transformer (`Kandinsky5Transformer3DModel`) : Transformer bersyarat untuk mendenoise latens gambar yang telah dikodekan. | |
| vae ([AutoencoderKL](/docs/diffusers/main/id/api/models/autoencoderkl#diffusers.AutoencoderKL)) : Model Variational Auto-Encoder [black-forest-labs/FLUX.1-dev (vae)](https://huggingface.co/black-forest-labs/FLUX.1-dev) untuk mengodekan dan mendekodekan video ke dan dari representasi laten. | |
| text_encoder (`Qwen2_5_VLForConditionalGeneration`) : text-encoder beku [Qwen2.5-VL](https://huggingface.co/Qwen/Qwen2.5-VL-7B-Instruct). | |
| tokenizer (`AutoProcessor`) : Tokenizer untuk Qwen2.5-VL. | |
| text_encoder_2 (`CLIPTextModel`) : [CLIP](https://huggingface.co/docs/transformers/model_doc/clip#transformers.CLIPTextModel) yang dibekukan, khususnya varian [clip-vit-large-patch14](https://huggingface.co/openai/clip-vit-large-patch14). | |
| tokenizer_2 (`CLIPTokenizer`) : Tokenizer untuk CLIP. | |
| scheduler ([FlowMatchEulerDiscreteScheduler](/docs/diffusers/main/id/api/schedulers/flow_match_euler_discrete#diffusers.FlowMatchEulerDiscreteScheduler)) : Penjadwal yang digunakan bersama `transformer` untuk menghilangkan noise pada latens gambar yang telah dikodekan. | |
| Pipeline untuk generasi teks-ke-gambar menggunakan Kandinsky 5.0. | |
| Model ini mewarisi dari [DiffusionPipeline](/docs/diffusers/main/id/api/pipelines/overview#diffusers.DiffusionPipeline). Periksa dokumentasi kelas induk untuk metode generik yang diimplementasikan untuk semua pipeline (mengunduh, menyimpan, menjalankan pada perangkat tertentu, dll.). | |
| #### __call__[[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[str] = ['latents'], max_sequence_length: int = 512) | |
| ``` | |
| [Sumber](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/kandinsky5/pipeline_kandinsky_t2i.py#L534) | |
| **Parameter:** | |
| prompt (`str` atau `list[str]`, *opsional*) : Prompt atau prompt-prompt untuk mengarahkan generasi gambar. Jika tidak didefinisikan, gunakan `prompt_embeds` sebagai gantinya. | |
| negative_prompt (`str` atau `list[str]`, *opsional*) : Prompt atau prompt-prompt yang harus dihindari selama pembuatan gambar. Jika tidak didefinisikan, gunakan `negative_prompt_embeds` sebagai gantinya. Diabaikan jika tidak menggunakan guidance (`guidance_scale` < `1`). | |
| height (`int`, defaultnya `1024`) : Tinggi gambar yang dihasilkan dalam piksel. | |
| width (`int`, defaultnya `1024`) : Lebar gambar yang dihasilkan dalam piksel. | |
| num_inference_steps (`int`, defaultnya `50`) : Jumlah langkah denoising. | |
| guidance_scale (`float`, defaultnya `5.0`) : Skala panduan seperti yang didefinisikan dalam classifier-free guidance. | |
| num_images_per_prompt (`int`, *opsional*, default 1) : Jumlah gambar yang akan dihasilkan per prompt. | |
| generator (`torch.Generator` atau `list[torch.Generator]`, *opsional*) : Generator torch untuk membuat proses generasi menjadi deterministik. | |
| latents (`torch.Tensor`, *opsional*) : Laten berisik yang telah dibuat sebelumnya. | |
| prompt_embeds_qwen (`torch.Tensor`, *opsional*) : Embedding teks Qwen yang telah dibuat sebelumnya. | |
| prompt_embeds_clip (`torch.Tensor`, *opsional*) : Embedding teks CLIP yang telah dibuat sebelumnya. | |
| negative_prompt_embeds_qwen (`torch.Tensor`, *opsional*) : Embedding teks negatif Qwen yang telah dibuat sebelumnya. | |
| negative_prompt_embeds_clip (`torch.Tensor`, *opsional*) : Embedding teks negatif CLIP yang telah dibuat sebelumnya. | |
| prompt_cu_seqlens (`torch.Tensor`, *opsional*) : Panjang kumulatif urutan yang telah dibuat sebelumnya untuk prompt positif Qwen. | |
| negative_prompt_cu_seqlens (`torch.Tensor`, *opsional*) : Panjang kumulatif urutan yang telah dibuat sebelumnya untuk prompt negatif Qwen. | |
| output_type (`str`, *opsional*, defaultnya `"pil"`) : Format output dari gambar yang dihasilkan. | |
| return_dict (`bool`, *opsional*, defaultnya `True`) : Apakah akan mengembalikan `KandinskyImagePipelineOutput` atau tidak. | |
| callback_on_step_end (`Callable`, `PipelineCallback`, `MultiPipelineCallbacks`, *opsional*) : Fungsi yang dipanggil di akhir setiap langkah denoising. | |
| callback_on_step_end_tensor_inputs (`List`, *opsional*) : Daftar input tensor untuk fungsi `callback_on_step_end`. | |
| max_sequence_length (`int`, defaultnya `512`) : Panjang maksimum sekuens untuk pengkodean teks. | |
| **Mengembalikan:** `~KandinskyImagePipelineOutput` atau `tuple` | |
| Jika `return_dict` adalah `True`, maka `KandinskyImagePipelineOutput` yang dikembalikan, selain itu sebuah `tuple` yang dikembalikan di mana elemen pertama adalah daftar berisi gambar yang dihasilkan. | |
| Fungsi panggilan untuk pipeline pada generasi teks-ke-gambar. | |
| Contoh: | |
| ```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) | |
| ``` | |
| [Sumber](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/kandinsky5/pipeline_kandinsky_t2i.py#L380) | |
| **Parameter:** | |
| prompt : Prompt input | |
| negative_prompt : Prompt negatif untuk panduan | |
| height : Tinggi gambar | |
| width : Lebar gambar | |
| prompt_embeds_qwen : Embedding prompt Qwen yang telah dihitung sebelumnya | |
| prompt_embeds_clip : Embedding prompt CLIP yang telah dihitung sebelumnya | |
| negative_prompt_embeds_qwen : Embedding prompt negatif Qwen yang telah dihitung sebelumnya | |
| negative_prompt_embeds_clip : Embedding prompt negatif CLIP yang telah dihitung sebelumnya | |
| prompt_cu_seqlens : Panjang kumulatif urutan yang sudah dihitung sebelumnya untuk prompt positif Qwen | |
| negative_prompt_cu_seqlens : Panjang kumulatif urutan yang sudah dihitung sebelumnya untuk prompt negatif Qwen | |
| callback_on_step_end_tensor_inputs : Input tensor callback | |
| **Mengangkat:** ``ValueError`` | |
| - ``ValueError`` -- Jika input tidak valid | |
| Validasi parameter input untuk pipeline. | |
| #### 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) | |
| ``` | |
| [Sumber](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/kandinsky5/pipeline_kandinsky_t2i.py#L289) | |
| **Parameter:** | |
| prompt (`str` atau `list[str]`) : Prompt yang akan dienkod. | |
| num_images_per_prompt (`int`, *opsional*, default 1) : Jumlah gambar yang akan dihasilkan per prompt. | |
| max_sequence_length (`int`, *opsional*, default 512) : Panjang maksimum urutan untuk pengkodean teks. Harus kurang dari 1024 | |
| device (`torch.device`, *opsional*) : Perangkat Torch. | |
| dtype (`torch.dtype`, *opsional*) : dtype Torch. | |
| **Mengembalikan:** tuple[torch.Tensor, torch.Tensor, torch.Tensor] | |
| - Qwen text embeddings dengan bentuk (batch_size * num_images_per_prompt, sequence_length, embedding_dim) | |
| - CLIP pooled embeddings dengan bentuk (batch_size * num_images_per_prompt, clip_embedding_dim) | |
| - Panjang sekuens kumulatif (`cu_seqlens`) untuk Qwen embeddings dengan bentuk (batch_size * num_images_per_prompt + 1,) | |
| Mengkodekan satu prompt (positif atau negatif) ke dalam hidden states text encoder. | |
| Metode ini menggabungkan embedding dari kedua encoder teks Qwen2.5-VL dan CLIP untuk membuat representasi teks yang komprehensif untuk generasi gambar. | |
| #### 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) | |
| ``` | |
| [Sumber](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/kandinsky5/pipeline_kandinsky_t2i.py#L469) | |
| **Parameter:** | |
| batch_size (int) : Jumlah gambar yang akan dibuat | |
| num_channels_latents (int) : Jumlah saluran di ruang laten | |
| height (int) : Tinggi gambar yang dihasilkan | |
| width (int) : Lebar gambar yang dihasilkan | |
| dtype (torch.dtype) : Tipe data untuk latents | |
| device (torch.device) : Perangkat untuk membuat latents | |
| generator (torch.Generator) : Generator bilangan acak | |
| latents (torch.Tensor) : Laten yang sudah ada untuk digunakan | |
| **Mengembalikan:** `torch.Tensor` | |
| Tensor laten yang disiapkan | |
| Siapkan variabel laten awal untuk generasi teks-ke-gambar. | |
| Metode ini membuat latens noise acak | |
| ## 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) | |
| ``` | |
| [Sumber](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/kandinsky5/pipeline_kandinsky_i2i.py#L120) | |
| **Parameter:** | |
| transformer (`Kandinsky5Transformer3DModel`) : Transformer bersyarat untuk mendenoise latens gambar yang telah dikodekan. | |
| vae ([AutoencoderKL](/docs/diffusers/main/id/api/models/autoencoderkl#diffusers.AutoencoderKL)) : Model Variational Auto-Encoder [black-forest-labs/FLUX.1-dev (vae)](https://huggingface.co/black-forest-labs/FLUX.1-dev) untuk mengodekan dan mendekodekan video ke dan dari representasi laten. | |
| text_encoder (`Qwen2_5_VLForConditionalGeneration`) : text-encoder beku [Qwen2.5-VL](https://huggingface.co/Qwen/Qwen2.5-VL-7B-Instruct). | |
| tokenizer (`AutoProcessor`) : Tokenizer untuk Qwen2.5-VL. | |
| text_encoder_2 (`CLIPTextModel`) : [CLIP](https://huggingface.co/docs/transformers/model_doc/clip#transformers.CLIPTextModel) yang dibekukan, khususnya varian [clip-vit-large-patch14](https://huggingface.co/openai/clip-vit-large-patch14). | |
| tokenizer_2 (`CLIPTokenizer`) : Tokenizer untuk CLIP. | |
| scheduler ([FlowMatchEulerDiscreteScheduler](/docs/diffusers/main/id/api/schedulers/flow_match_euler_discrete#diffusers.FlowMatchEulerDiscreteScheduler)) : Penjadwal yang digunakan bersama `transformer` untuk menghilangkan noise pada latens gambar yang telah dikodekan. | |
| Pipeline untuk generasi gambar-ke-gambar menggunakan Kandinsky 5.0. | |
| Model ini mewarisi dari [DiffusionPipeline](/docs/diffusers/main/id/api/pipelines/overview#diffusers.DiffusionPipeline). Periksa dokumentasi kelas induk untuk metode generik yang diimplementasikan untuk semua pipeline (mengunduh, menyimpan, menjalankan pada perangkat tertentu, dll.). | |
| #### __call__[[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[str] = ['latents'], max_sequence_length: int = 1024) | |
| ``` | |
| [Sumber](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/kandinsky5/pipeline_kandinsky_i2i.py#L567) | |
| **Parameter:** | |
| image (`PipelineImageInput`) : Gambar input untuk mengondisikan generasi. Harus berupa gambar, daftar gambar, atau `torch.Tensor`. | |
| prompt (`str` atau `list[str]`, *opsional*) : Prompt atau prompt-prompt untuk mengarahkan generasi gambar. Jika tidak didefinisikan, gunakan `prompt_embeds` sebagai gantinya. | |
| negative_prompt (`str` atau `list[str]`, *opsional*) : Prompt atau prompt-prompt yang harus dihindari selama pembuatan gambar. Jika tidak didefinisikan, gunakan `negative_prompt_embeds` sebagai gantinya. Diabaikan jika tidak menggunakan guidance (`guidance_scale` < `1`). | |
| height (`int`) : Tinggi gambar yang dihasilkan dalam piksel. | |
| width (`int`) : Lebar gambar yang dihasilkan dalam piksel. | |
| num_inference_steps (`int`, defaultnya `50`) : Jumlah langkah denoising. | |
| guidance_scale (`float`, defaultnya `5.0`) : Skala panduan seperti yang didefinisikan dalam classifier-free guidance. | |
| num_images_per_prompt (`int`, *opsional*, default 1) : Jumlah gambar yang akan dihasilkan per prompt. | |
| generator (`torch.Generator` atau `list[torch.Generator]`, *opsional*) : Generator torch untuk membuat proses generasi menjadi deterministik. | |
| latents (`torch.Tensor`, *opsional*) : Laten berisik yang telah dibuat sebelumnya. | |
| prompt_embeds_qwen (`torch.Tensor`, *opsional*) : Embedding teks Qwen yang telah dibuat sebelumnya. | |
| prompt_embeds_clip (`torch.Tensor`, *opsional*) : Embedding teks CLIP yang telah dibuat sebelumnya. | |
| negative_prompt_embeds_qwen (`torch.Tensor`, *opsional*) : Embedding teks negatif Qwen yang telah dibuat sebelumnya. | |
| negative_prompt_embeds_clip (`torch.Tensor`, *opsional*) : Embedding teks negatif CLIP yang telah dibuat sebelumnya. | |
| prompt_cu_seqlens (`torch.Tensor`, *opsional*) : Panjang kumulatif urutan yang telah dibuat sebelumnya untuk prompt positif Qwen. | |
| negative_prompt_cu_seqlens (`torch.Tensor`, *opsional*) : Panjang kumulatif urutan yang telah dibuat sebelumnya untuk prompt negatif Qwen. | |
| output_type (`str`, *opsional*, defaultnya `"pil"`) : Format output dari gambar yang dihasilkan. | |
| return_dict (`bool`, *opsional*, defaultnya `True`) : Apakah akan mengembalikan `KandinskyImagePipelineOutput` atau tidak. | |
| callback_on_step_end (`Callable`, `PipelineCallback`, `MultiPipelineCallbacks`, *opsional*) : Fungsi yang dipanggil di akhir setiap langkah denoising. | |
| callback_on_step_end_tensor_inputs (`List`, *opsional*) : Daftar input tensor untuk fungsi `callback_on_step_end`. | |
| max_sequence_length (`int`, defaultnya `1024`) : Panjang maksimum sekuens untuk pengkodean teks dan gambar qwen. Harus kurang dari 1024 | |
| **Mengembalikan:** `~KandinskyImagePipelineOutput` atau `tuple` | |
| Jika `return_dict` adalah `True`, maka `KandinskyImagePipelineOutput` yang dikembalikan, selain itu sebuah `tuple` yang dikembalikan di mana elemen pertama adalah daftar berisi gambar yang dihasilkan. | |
| Fungsi panggilan untuk pipeline pada generasi gambar-ke-gambar. | |
| Contoh: | |
| ```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) | |
| ``` | |
| [Sumber](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/kandinsky5/pipeline_kandinsky_i2i.py#L388) | |
| **Parameter:** | |
| prompt : Prompt input | |
| negative_prompt : Prompt negatif untuk panduan | |
| image : Gambar input untuk kondisioning | |
| height : Tinggi gambar | |
| width : Lebar gambar | |
| prompt_embeds_qwen : Embedding prompt Qwen yang telah dihitung sebelumnya | |
| prompt_embeds_clip : Embedding prompt CLIP yang telah dihitung sebelumnya | |
| negative_prompt_embeds_qwen : Embedding prompt negatif Qwen yang telah dihitung sebelumnya | |
| negative_prompt_embeds_clip : Embedding prompt negatif CLIP yang telah dihitung sebelumnya | |
| prompt_cu_seqlens : Panjang kumulatif urutan yang sudah dihitung sebelumnya untuk prompt positif Qwen | |
| negative_prompt_cu_seqlens : Panjang kumulatif urutan yang sudah dihitung sebelumnya untuk prompt negatif Qwen | |
| callback_on_step_end_tensor_inputs : Input tensor callback | |
| **Mengangkat:** ``ValueError`` | |
| - ``ValueError`` -- Jika input tidak valid | |
| Validasi parameter input untuk pipeline. | |
| #### 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) | |
| ``` | |
| [Sumber](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/kandinsky5/pipeline_kandinsky_i2i.py#L295) | |
| **Parameter:** | |
| prompt (`str` atau `list[str]`) : Prompt yang akan dienkod. | |
| num_images_per_prompt (`int`, *opsional*, default 1) : Jumlah gambar yang akan dihasilkan per prompt. | |
| max_sequence_length (`int`, *opsional*, default 1024) : Panjang maksimum urutan untuk pengkodean teks. Harus kurang dari 1024 | |
| device (`torch.device`, *opsional*) : Perangkat Torch. | |
| dtype (`torch.dtype`, *opsional*) : dtype Torch. | |
| **Mengembalikan:** tuple[torch.Tensor, torch.Tensor, torch.Tensor] | |
| - Qwen text embeddings dengan bentuk (batch_size * num_images_per_prompt, sequence_length, embedding_dim) | |
| - CLIP pooled embeddings dengan bentuk (batch_size * num_images_per_prompt, clip_embedding_dim) | |
| - Panjang sekuens kumulatif (`cu_seqlens`) untuk Qwen embeddings dengan bentuk (batch_size * num_images_per_prompt + 1,) | |
| Mengkodekan satu prompt (positif atau negatif) ke dalam hidden states text encoder. | |
| Metode ini menggabungkan embedding dari kedua encoder teks Qwen2.5-VL dan CLIP untuk membuat representasi teks yang komprehensif untuk generasi gambar. | |
| #### 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) | |
| ``` | |
| [Sumber](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/kandinsky5/pipeline_kandinsky_i2i.py#L482) | |
| **Parameter:** | |
| image (PipelineImageInput) : Gambar input untuk mengondisikan generasi | |
| batch_size (int) : Jumlah gambar yang akan dibuat | |
| num_channels_latents (int) : Jumlah saluran di ruang laten | |
| height (int) : Tinggi gambar yang dihasilkan | |
| width (int) : Lebar gambar yang dihasilkan | |
| dtype (torch.dtype) : Tipe data untuk latents | |
| device (torch.device) : Perangkat untuk membuat latents | |
| generator (torch.Generator) : Generator bilangan acak | |
| latents (torch.Tensor) : Laten yang sudah ada untuk digunakan | |
| **Mengembalikan:** `torch.Tensor` | |
| Tensor laten yang disiapkan dengan gambar yang dikodekan | |
| Siapkan variabel laten awal untuk generasi gambar-ke-gambar. | |
| Metode ini membuat latens noise acak dengan gambar yang telah dikodekan, | |
| ## Sitasi | |
| ```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 | |
| } | |
| ``` | |
Xet Storage Details
- Size:
- 27.3 kB
- Xet hash:
- 42b88eaad669fb110ee47bcf1fc225cda657a0681b91cf16bd2c1149898a0120
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.