> 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/image-generation/stable-diffusion-3-5.md).

# Stable Diffusion 3.5

Stability AI का Stable Diffusion 3.5 एक मल्टीमोडल डिफ्यूजन ट्रांसफॉर्मर (MMDiT) है जो ओपन-वेट इमेज जनरेशन के लिए नया मानक स्थापित करता है। यह तीन वेरिएंट में आता है: **लार्ज** (8B पैरामीटर), **मध्यम** (2.5B पैरामीटर), और **लार्ज टर्बो** (8B, 4-स्टेप इन्फरेंस के लिए डिस्टिल्ड)। इसका प्रमुख फीचर इसका सटीक टेक्स्ट रेंडरिंग है — SD 3.5 विश्वसनीय रूप से जनरेट की गई छवियों के भीतर पठनीय टेक्स्ट रख सकता है, जो अधिकतर पहले के मॉडलों के लिए चुनौतीपूर्ण था।

पर [Clore.ai](https://clore.ai/) आप SD 3.5 को चलाने के लिए आवश्यक GPU पावर को केवल $0.30/दिन जैसी कम दर पर किराए पर ले सकते हैं और प्रति घंटे सैकड़ों इमेजेज़ जनरेट कर सकते हैं।

## प्रमुख विशेषताएँ

* **तीन वेरिएंट** — लार्ज (8B, उच्चतम गुणवत्ता), मीडियम (2.5B, तेज़ और हल्का), लार्ज टर्बो (8B, 4-स्टेप डिस्टिल्ड)।
* **सटीक टेक्स्ट रेंडरिंग** — छवियों के भीतर पठनीय टेक्स्ट, साइन, लेबल और टाइपोग्राफी जनरेट करता है।
* **MMDiT आर्किटेक्चर** — बेहतर प्रॉम्प्ट अनुपालन के लिए संयुक्त इमेज-टेक्स्ट अटेंशन।
* **1024×1024 नेटिव रेज़ोल्यूशन** — अपस्केलिंग ट्रिक्स के बिना साफ आउटपुट।
* **लचीले आस्पेक्ट रेशियो** — गैर-वर्गाकार आउटपुट्स (768×1344, 1344×768, आदि) को बिना गुणवत्ता हानि के संभालता है।
* **नेटिव diffusers समर्थन** — `StableDiffusion3Pipeline` में `diffusers >= 0.30`.
* **ओपन वेट्स** — Stability AI Community License; अधिकांश वाणिज्यिक उपयोग के लिए मुफ़्त।

## आवश्यकताएँ

| घटक        | न्यूनतम        | अनुशंसित              |
| ---------- | -------------- | --------------------- |
| GPU VRAM   | 12 GB (मीडियम) | 24 GB (लार्ज / टर्बो) |
| सिस्टम RAM | 16 GB          | 32 GB                 |
| डिस्क      | 20 GB          | 40 GB                 |
| Python     | 3.10+          | 3.11                  |
| CUDA       | 12.1+          | 12.4                  |
| diffusers  | 0.30+          | नवीनतम                |

**Clore.ai GPU सिफारिश:** एक **RTX 4090** (24 GB, लगभग $0.5–2/दिन) सभी तीन वेरिएंट्स को पूर्ण गति पर चलाता है। मीडियम मॉडल के लिए, **RTX 3090** (24 GB, लगभग $0.3–1/दिन) या यहां तक कि 16 GB कार्ड पर्याप्त और सस्ता है।

## त्वरित प्रारम्भ

```bash
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu124
pip install diffusers transformers accelerate sentencepiece protobuf

python -c "import torch; print(torch.cuda.get_device_name(0))"
```

## उपयोग के उदाहरण

### SD 3.5 लार्ज — अधिकतम गुणवत्ता

```python
import torch
from diffusers import StableDiffusion3Pipeline

pipe = StableDiffusion3Pipeline.from_pretrained(
    "stabilityai/stable-diffusion-3.5-large",
    torch_dtype=torch.bfloat16,
)
pipe.to("cuda")

image = pipe(
    prompt=(
        "एक पुराना लकड़ी का साइन जिस पर 'OPEN 24 HOURS' लिखा है और वह लटका हुआ है "
        "एक जंग लगे चेन से बाहर एक नीयन-लाइटेड डाइनर के पास, बारिश भरी रात, परावर्तन "
        "गीले डामर पर, सिनेमैटिक फोटोग्राफी"
    ),
    negative_prompt="धुंधला, विकृत टेक्स्ट, कम गुणवत्ता",
    guidance_scale=3.5,
    num_inference_steps=28,
    width=1024,
    height=1024,
    generator=torch.Generator("cuda").manual_seed(42),
).images[0]

image.save("diner_sign.png")
print("Saved diner_sign.png")
```

### SD 3.5 लार्ज टर्बो — 4-स्टेप तेज़ जनरेशन

```python
import torch
from diffusers import StableDiffusion3Pipeline

pipe = StableDiffusion3Pipeline.from_pretrained(
    "stabilityai/stable-diffusion-3.5-large-turbo",
    torch_dtype=torch.bfloat16,
).to("cuda")

# टर्बो वेरिएंट: केवल 4 स्टेप्स की आवश्यकता, guidance_scale=0 (डिस्टिल्ड)
image = pipe(
    prompt="एक मैकेनिकल वॉच मूवमेंट का मैक्रो फोटो, जटिल गियर्स, सुनहरा प्रकाश",
    guidance_scale=0.0,
    num_inference_steps=4,
    width=1024,
    height=1024,
).images[0]

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

### SD 3.5 मीडियम — हल्का विकल्प

```python
import torch
from diffusers import StableDiffusion3Pipeline

pipe = StableDiffusion3Pipeline.from_pretrained(
    "stabilityai/stable-diffusion-3.5-medium",
    torch_dtype=torch.float16,
).to("cuda")

image = pipe(
    prompt="एक आरामदायक कॉफी शॉप के इंटीरियर का आइसोमेट्रिक दृश्य, पिक्सेल आर्ट स्टाइल, गर्म रोशनी",
    guidance_scale=4.0,
    num_inference_steps=28,
    width=1024,
    height=1024,
).images[0]

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

### विभिन्न आस्पेक्ट रेशियो के साथ बैच जनरेशन

```python
import torch
from diffusers import StableDiffusion3Pipeline

pipe = StableDiffusion3Pipeline.from_pretrained(
    "stabilityai/stable-diffusion-3.5-large",
    torch_dtype=torch.bfloat16,
).to("cuda")

jobs = [
    {"prompt": "सूरजमुखी के खेत में एक अंतरिक्ष यात्री का पोर्ट्रेट", "w": 768, "h": 1344},
    {"prompt": "आइसलैंडिक हाइलैंड्स का पैनोरमिक नज़ारा, उदास मौसम",
 "w": 1344, "h": 768},
    {"prompt": "एक संगमरमर सतह पर एक परफ्यूम बोतल का प्रोडक्ट फोटो", "w": 1024, "h": 1024},
]

for i, job in enumerate(jobs):
    img = pipe(
        prompt=job["prompt"],
        guidance_scale=3.5,
        num_inference_steps=28,
        width=job["w"],
        height=job["h"],
    ).images[0]
    img.save(f"batch_{i:03d}.png")
    print(f"[{i+1}/{len(jobs)}] {job['w']}x{job['h']} हो गया")
```

## Clore.ai उपयोगकर्ताओं के लिए सुझाव

1. **इटरेशन के लिए टर्बो, अंतिम के लिए लार्ज** — आइडिया जल्दी एक्सप्लोर करने के लिए 4-स्टेप टर्बो वेरिएंट का उपयोग करें, फिर अंतिम रेंडर के लिए लार्ज (28 स्टेप्स) पर स्विच करें।
2. **guidance\_scale=3.5** — SD 3.5 लार्ज पुराने Stable Diffusion मॉडलों की तुलना में कम CFG पर बेहतर काम करता है। 5.0 से ऊपर जाना अक्सर ओवर्सेचुरेशन का कारण बनता है।
3. **टर्बो को guidance\_scale=0 चाहिए** — डिस्टिल्ड मॉडल में पहले से ही गाइडेंस समाहित होता है; और जोड़ने से आउटपुट खराब होता है।
4. **छवियों में टेक्स्ट** — SD 3.5 की टेक्स्ट रेंडरिंग मजबूत है लेकिन परिपूर्ण नहीं है। जिस सटीक टेक्स्ट को आप चाहते हैं उसके चारों ओर उद्धरण चिन्हों का उपयोग करें: `'OPEN 24 HOURS'`. इसे छोटा रखें (अधिकतम 3–5 शब्द)।
5. **वेट्स को कैश करें** — सेट करें `HF_HOME=/workspace/hf_cache` स्थायी स्टोरेज पर। लार्ज डिस्क पर लगभग \~16 GB है।
6. **लार्ज के लिए bf16, मीडियम के लिए fp16** — 8B मॉडलों को bf16 में प्रशिक्षण दिया गया था; 2.5B मीडियम fp16 में ठीक चलता है।
7. **बॅच को कुशल बनाएं** — SD 3.5 लार्ज एक RTX 4090 पर \~3 सेकंड में एक 1024×1024 इमेज जनरेट करता है। बड़े पैमाने पर जनरेशन के लिए रात भर बैच करें।
8. **HF लाइसेंस स्वीकार करें** — डाउनलोड से पहले HuggingFace मॉडल पेज पर आपको मॉडल लाइसेंस स्वीकार करना होगा। इसमें लॉग इन करें `huggingface-cli login`.

## समस्याओं का निवारण

| समस्या                           | समाधान                                                                                                                   |
| -------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
| `OutOfMemoryError` लार्ज के साथ  | उपयोग करें `pipe.enable_model_cpu_offload()`; या मीडियम वेरिएंट पर स्विच करें                                            |
| छवि में खराब टेक्स्ट             | टेक्स्ट को छोटा रखें (3–5 शब्द); प्रॉम्प्ट में इसे उद्धरणों में रखें; बढ़ाएँ `num_inference_steps` को 35                 |
| ओवरसैचुरेटेड रंग                 | कम करें `guidance_scale` — लार्ज के लिए 2.5–3.5 आज़माएं; टर्बो के लिए 0.0 का उपयोग करें                                  |
| मॉडल डाउनलोड करते समय 403 त्रुटि | लाइसेंस स्वीकार करें पर `https://huggingface.co/stabilityai/stable-diffusion-3.5-large` और चलाएं `huggingface-cli login` |
| पहली बार धीमा                    | लार्ज के लिए प्रारंभिक डाउनलोड \~16 GB है; बाद की बारें कैश का उपयोग करती हैं                                            |
| `KeyError: 'text_encoder_3'`     | diffusers अपडेट करें: `pip install -U diffusers transformers`                                                            |
| काली छवि आउटपुट                  | सुनिश्चित करें `torch_dtype=torch.bfloat16` लार्ज/टर्बो के लिए; कुछ कार्ड पर fp32 से मौन विफलताएं हो सकती हैं            |


---

# 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/image-generation/stable-diffusion-3-5.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.
