> For the complete documentation index, see [llms.txt](https://docs.clore.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.clore.ai/guides/guides_v2-hi/other-workloads/kandinsky.md).

# कैंडिंस्की

Clore.ai पर कैंडिंस्की के बहुभाषी मॉडल से चित्र जनरेट करें

शक्तिशाली बहुभाषी पाठ समझ के साथ छवियाँ जनरेट करें।

{% hint style="success" %}
सभी उदाहरण GPU सर्वरों पर चलाए जा सकते हैं, जिन्हें किराए पर लिया गया है [CLORE.AI मार्केटप्लेस](https://clore.ai/marketplace).
{% endhint %}

## Kandinsky क्या है?

Kandinsky एक छवि निर्माण मॉडल है जिसे Sber AI ने विकसित किया है:

* मजबूत बहुभाषी पाठ समझ
* उच्च-गुणवत्ता छवि निर्माण
* छवि मिश्रण और अंतःप्रक्षेपण
* इनपेंटिंग और आउटपेंटिंग समर्थन
* ओपन-सोर्स वेट्स

## संसाधन

* **GitHub:** [ai-forever/Kandinsky-3](https://github.com/ai-forever/Kandinsky-3)
* **HuggingFace:** [kandinsky-community](https://huggingface.co/kandinsky-community)
* **पेपर:** [Kandinsky पेपर](https://arxiv.org/abs/2310.03502)

## मॉडल संस्करण

| संस्करण       | रिज़ॉल्यूशन | गुणवत्ता  | गति   |
| ------------- | ----------- | --------- | ----- |
| Kandinsky 2.1 | 768x768     | अच्छा     | तेज़  |
| Kandinsky 2.2 | 1024x1024   | बेहतर     | मध्यम |
| Kandinsky 3   | 1024x1024   | सर्वोत्तम | धीमा  |

## हार्डवेयर आवश्यकताएँ

| मॉडल                           | VRAM | अनुशंसित GPU |
| ------------------------------ | ---- | ------------ |
| Kandinsky 2.2                  | 8GB  | RTX 3070     |
| Kandinsky 3                    | 12GB | RTX 3090     |
| Kandinsky 3 (उच्च रिज़ॉल्यूशन) | 16GB | RTX 4090     |

## त्वरित डिप्लॉय

**Docker इमेज:**

```
pytorch/pytorch:2.11.0-cuda12.8-cudnn9-devel
```

**पोर्ट:**

```
22/tcp
7860/http
```

**कमांड:**

```bash
pip install diffusers transformers accelerate gradio && \
python -c "
import gradio as gr
import torch
from diffusers import AutoPipelineForText2Image

pipe = AutoPipelineForText2Image.from_pretrained(
    'kandinsky-community/kandinsky-3',
    variant='fp16',
    torch_dtype=torch.float16
).to('cuda')

def generate(prompt, negative, steps, guidance, seed):
    generator = torch.Generator('cuda').manual_seed(seed) if seed > 0 else None
    image = pipe(
        prompt=prompt,
        negative_prompt=negative,
        num_inference_steps=steps,
        guidance_scale=guidance,
        generator=generator
    ).images[0]
    return image

gr.Interface(
    fn=generate,
    inputs=[
        gr.Textbox(label='प्रॉम्प्ट'),
        gr.Textbox(label='नकारात्मक प्रॉम्प्ट', value='कम गुणवत्ता, धुंधला'),
        gr.Slider(10, 100, value=50, label='चरण'),
        gr.Slider(1, 20, value=4, label='मार्गदर्शन'),
        gr.Number(value=-1, label='सीड')
    ],
    outputs=gr.Image(),
    title='Kandinsky 3'
).launch(server_name='0.0.0.0', server_port=7860)
"
```

## अपनी सेवा तक पहुँचना

डिप्लॉयमेंट के बाद, अपना `http_pub` URL यहाँ **मेरे ऑर्डर**:

1. पर जाएँ **मेरे ऑर्डर** पेज
2. अपने ऑर्डर पर क्लिक करें
3. खोजें `http_pub` URL (उदा., `abc123.clorecloud.net`)

उपयोग करें `https://YOUR_HTTP_PUB_URL` की बजाय `localhost` नीचे दिए गए उदाहरणों में।

## इंस्टॉलेशन

```bash
pip install diffusers transformers accelerate torch
```

## मूल उपयोग

### Kandinsky 3

```python
import torch
from diffusers import AutoPipelineForText2Image

pipe = AutoPipelineForText2Image.from_pretrained(
    "kandinsky-community/kandinsky-3",
    variant="fp16",
    torch_dtype=torch.float16
)
pipe.to("cuda")

image = pipe(
    prompt="अंतरिक्ष में तैरता एक बिल्ली अंतरिक्ष यात्री, डिजिटल आर्ट, जीवंत रंग",
    num_inference_steps=50,
    guidance_scale=4.0
).images[0]

image.save("cat_astronaut.png")
```

### Kandinsky 2.2

```python
import torch
from diffusers import KandinskyV22Pipeline, KandinskyV22PriorPipeline

# प्रायर लोड करें (टेक्स्ट एन्कोडर)
prior = KandinskyV22PriorPipeline.from_pretrained(
    "kandinsky-community/kandinsky-2-2-prior",
    torch_dtype=torch.float16
).to("cuda")

# डिकोडर लोड करें
decoder = KandinskyV22Pipeline.from_pretrained(
    "kandinsky-community/kandinsky-2-2-decoder",
    torch_dtype=torch.float16
).to("cuda")

# छवि एंबेडिंग्स जनरेट करें
prompt = "पहाड़ों के ऊपर एक सुंदर सूर्यास्त, तेल चित्रकला शैली"
image_embeds, negative_embeds = prior(
    prompt=prompt,
    guidance_scale=1.0
).to_tuple()

# छवि जनरेट करें
image = decoder(
    image_embeds=image_embeds,
    negative_image_embeds=negative_embeds,
    height=768,
    width=768,
    num_inference_steps=50
).images[0]

image.save("sunset.png")
```

## बहुभाषी प्रॉम्प्ट

Kandinsky कई भाषाओं का समर्थन करता है:

```python
import torch
from diffusers import AutoPipelineForText2Image

pipe = AutoPipelineForText2Image.from_pretrained(
    "kandinsky-community/kandinsky-3",
    variant="fp16",
    torch_dtype=torch.float16
).to("cuda")

# अंग्रेज़ी
image_en = pipe("बर्फीले जंगल में एक लाल लोमड़ी").images[0]

# रूसी
image_ru = pipe("Красная лиса в снежном лесу").images[0]

# चीनी
image_zh = pipe("雪林中的红狐狸").images[0]

# जर्मन
image_de = pipe("Ein roter Fuchs im verschneiten Wald").images[0]

# सभी समान छवियाँ बनाते हैं!
```

## छवि मिश्रण

```python
import torch
from diffusers import KandinskyV22PriorPipeline, KandinskyV22Pipeline
from diffusers.utils import load_image

prior = KandinskyV22PriorPipeline.from_pretrained(
    "kandinsky-community/kandinsky-2-2-prior",
    torch_dtype=torch.float16
).to("cuda")

decoder = KandinskyV22Pipeline.from_pretrained(
    "kandinsky-community/kandinsky-2-2-decoder",
    torch_dtype=torch.float16
).to("cuda")

# मिलाने के लिए दो प्रॉम्प्ट
prompt1 = "एक बिल्ली"
prompt2 = "एक कुत्ता"

# दोनों के लिए एंबेडिंग्स प्राप्त करें
embeds1, neg1 = prior(prompt1).to_tuple()
embeds2, neg2 = prior(prompt2).to_tuple()

# एंबेडिंग्स मिलाएँ (50% प्रत्येक)
mixed_embeds = 0.5 * embeds1 + 0.5 * embeds2
mixed_neg = 0.5 * neg1 + 0.5 * neg2

# मिश्रित छवि जनरेट करें
image = decoder(
    image_embeds=mixed_embeds,
    negative_image_embeds=mixed_neg,
    height=768,
    width=768
).images[0]

image.save("cat_dog_mix.png")
```

## इनपेंटिंग

```python
import torch
from diffusers import AutoPipelineForInpainting
from diffusers.utils import load_image

pipe = AutoPipelineForInpainting.from_pretrained(
    "kandinsky-community/kandinsky-2-2-decoder-inpaint",
    torch_dtype=torch.float16
).to("cuda")

# छवि और मास्क लोड करें
image = load_image("photo.png")
mask = load_image("mask.png")

# इनपेंट करें
result = pipe(
    prompt="एक सुनहरा मुकुट",
    image=image,
    mask_image=mask,
    num_inference_steps=50
).images[0]

result.save("inpainted.png")
```

## छवि-से-छवि

```python
import torch
from diffusers import AutoPipelineForImage2Image
from diffusers.utils import load_image

pipe = AutoPipelineForImage2Image.from_pretrained(
    "kandinsky-community/kandinsky-3",
    variant="fp16",
    torch_dtype=torch.float16
).to("cuda")

init_image = load_image("sketch.png")

image = pipe(
    prompt="एक महल की विस्तृत डिजिटल पेंटिंग, फैंटेसी कला",
    image=init_image,
    strength=0.75,
    num_inference_steps=50
).images[0]

image.save("castle.png")
```

## बैच जनरेशन

```python
import torch
from diffusers import AutoPipelineForText2Image
import os

pipe = AutoPipelineForText2Image.from_pretrained(
    "kandinsky-community/kandinsky-3",
    variant="fp16",
    torch_dtype=torch.float16
).to("cuda")

prompts = [
    "एक शांत जापानी बगीचा जिसमें चेरी के फूल हों",
    "नियॉन रोशनी वाली रात की एक साइबरपंक नगरी",
    "जादुई पुस्तकों से भरा एक प्राचीन पुस्तकालय",
    "सर्दियों में पहाड़ों में एक आरामदायक केबिन"
]

os.makedirs("outputs", exist_ok=True)

for i, prompt in enumerate(prompts):
    image = pipe(
        prompt=prompt,
        num_inference_steps=50,
        guidance_scale=4.0
    ).images[0]

    image.save(f"outputs/image_{i}.png")
    print(f"उत्पन्न: {prompt[:30]}...")

    torch.cuda.empty_cache()
```

## Gradio इंटरफ़ेस

```python
import gradio as gr
import torch
from diffusers import AutoPipelineForText2Image

pipe = AutoPipelineForText2Image.from_pretrained(
    "kandinsky-community/kandinsky-3",
    variant="fp16",
    torch_dtype=torch.float16
).to("cuda")

def generate(prompt, negative_prompt, steps, guidance, width, height, seed):
    generator = torch.Generator("cuda").manual_seed(seed) if seed > 0 else None

    image = pipe(
        prompt=prompt,
        negative_prompt=negative_prompt,
        num_inference_steps=steps,
        guidance_scale=guidance,
        width=width,
        height=height,
        generator=generator
    ).images[0]

    return image

demo = gr.Interface(
    fn=generate,
    inputs=[
        gr.Textbox(label="प्रॉम्प्ट", placeholder="अपनी छवि का वर्णन करें..."),
        gr.Textbox(label="नकारात्मक प्रॉम्प्ट", value="कम गुणवत्ता, धुंधला, विकृत"),
        gr.Slider(10, 100, value=50, step=5, label="चरण"),
        gr.Slider(1, 20, value=4, step=0.5, label="मार्गदर्शन स्केल"),
        gr.Slider(512, 1024, value=1024, step=64, label="चौड़ाई"),
        gr.Slider(512, 1024, value=1024, step=64, label="ऊँचाई"),
        gr.Number(value=-1, label="Seed (-1 for random)")
    ],
    outputs=gr.Image(label="जनरेट की गई छवि"),
    title="Kandinsky 3 - छवि निर्माण",
    description="बहुभाषी प्रॉम्प्ट के साथ छवियाँ जनरेट करें। CLORE.AI पर चल रहा है।"
)

demo.launch(server_name="0.0.0.0", server_port=7860)
```

## मेमोरी अनुकूलन

```python
import torch
from diffusers import AutoPipelineForText2Image

pipe = AutoPipelineForText2Image.from_pretrained(
    "kandinsky-community/kandinsky-3",
    variant="fp16",
    torch_dtype=torch.float16
)

# मेमोरी अनुकूलन सक्षम करें
pipe.enable_model_cpu_offload()

# या बहुत कम VRAM के लिए
pipe.enable_sequential_cpu_offload()

# attention slicing सक्षम करें
pipe.enable_attention_slicing()

image = pipe(
    prompt="एक सुंदर प्राकृतिक दृश्य",
    num_inference_steps=50
).images[0]
```

## प्रदर्शन

| मॉडल          | रिज़ॉल्यूशन | GPU      | समय     |
| ------------- | ----------- | -------- | ------- |
| Kandinsky 3   | 1024x1024   | RTX 3090 | 15सेकंड |
| Kandinsky 3   | 1024x1024   | RTX 4090 | 10s     |
| Kandinsky 2.2 | 768x768     | RTX 3090 | 8s      |
| Kandinsky 2.2 | 768x768     | RTX 4090 | 5s      |

## समस्या निवारण

### मेमोरी समाप्त

**समस्या:** जनरेट करते समय CUDA OOM

**समाधान:**

* CPU ऑफ़लोडिंग सक्षम करें
* रिज़ॉल्यूशन कम करें
* 3 के बजाय Kandinsky 2.2 का उपयोग करें
* अटेंशन स्लाइसिंग सक्षम करें

```python
pipe.enable_model_cpu_offload()
pipe.enable_attention_slicing()
```

### खराब टेक्स्ट रेंडरिंग

**समस्या:** छवियों में टेक्स्ट गलत दिखता है

**समाधान:**

* Kandinsky को टेक्स्ट रेंडरिंग में कठिनाई होती है (जैसे अधिकांश diffusion मॉडल)
* पोस्ट-प्रोसेसिंग में टेक्स्ट जोड़ें
* ऐसे प्रॉम्प्ट का उपयोग करें जिनमें टेक्स्ट न हो

### रंग गलत दिखते हैं

**समस्या:** छवि के रंग फीके पड़ गए हैं या अत्यधिक संतृप्त हैं

**समाधान:**

* गाइडेंस स्केल समायोजित करें (3-6 सीमा आज़माएँ)
* प्रॉम्प्ट में रंग की प्राथमिकताएँ निर्दिष्ट करें
* रंग सुधार के साथ पोस्ट-प्रोसेस करें

### धीमी जनरेशन

**समस्या:** जनरेट करने में बहुत समय लगता है

**समाधान:**

* इन्फ़रेंस चरण कम करें (अक्सर 30 पर्याप्त होता है)
* fp16 प्रिसीजन का उपयोग करें
* तेज़ परिणामों के लिए Kandinsky 2.2 का उपयोग करें
* पूर्वावलोकन के लिए रिज़ॉल्यूशन कम करें

## अन्य मॉडलों के साथ तुलना

| विशेषता      | Kandinsky 3 | SDXL      | FLUX     |
| ------------ | ----------- | --------- | -------- |
| बहुभाषी      | उत्कृष्ट    | सीमित     | सीमित    |
| छवि गुणवत्ता | उच्च        | बहुत उच्च | सर्वाधिक |
| गति          | मध्यम       | मध्यम     | धीमा     |
| VRAM         | 12GB        | 12GB      | 24GB     |
| इनपेंटिंग    | हाँ         | हाँ       | सीमित    |

## लागत का अनुमान

CLORE.AI मार्केटप्लेस की सामान्य दरें (2024 तक):

| GPU       | प्रति घंटा दर | प्रति दिन दर | 4-घंटे का सत्र |
| --------- | ------------- | ------------ | -------------- |
| RTX 3060  | \~$0.03       | \~$0.70      | \~$0.12        |
| RTX 3090  | \~$0.06       | \~$1.50      | \~$0.25        |
| RTX 4090  | \~$0.10       | \~$2.30      | \~$0.40        |
| A100 40GB | \~$0.17       | \~$4.00      | \~$0.70        |
| A100 80GB | \~$0.25       | \~$6.00      | \~$1.00        |

*कीमतें प्रदाता के अनुसार बदलती हैं। देखें* [*CLORE.AI मार्केटप्लेस*](https://clore.ai/marketplace) *वर्तमान दरों के लिए।*

## अगले चरण

* FLUX जनरेशन - सर्वोच्च गुणवत्ता वाली छवियाँ
* Stable Diffusion - सबसे लोकप्रिय विकल्प
* [PixArt](/guides/guides_v2-hi/image-generation/pixart-image-gen.md) - तेज़ जनरेशन
* ComfyUI - उन्नत वर्कफ़्लोज़


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.clore.ai/guides/guides_v2-hi/other-workloads/kandinsky.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
