> 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/sdxl-turbo.md).

# SDXL Turbo & LCM

CLORE.AI GPU पर SDXL Turbo और Latent Consistency Models के साथ 1-4 चरणों में छवियां उत्पन्न करें।

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

## SDXL Turbo / LCM क्यों?

* **रीयल-टाइम गति** - 30-50 के बजाय 1-4 चरणों में छवियां उत्पन्न करें
* **उसी गुणवत्ता** - 10x कम चरणों के साथ पूर्ण SDXL के समान
* **इंटरएक्टिव** - रीयल-टाइम अनुप्रयोगों के लिए पर्याप्त तेज़
* **कम VRAM** - कुशल मेमोरी उपयोग
* **LoRA अनुकूल** - मौजूदा SDXL LoRAs के साथ उपयोग करें

## मॉडल वेरिएंट

| मॉडल            | स्टेप्स | स्पीड     | गुणवत्ता   | VRAM |
| --------------- | ------- | --------- | ---------- | ---- |
| SDXL टर्बो      | 1-4     | सबसे तेज  | अच्छा      | 8GB  |
| SDXL लाइटनिंग   | 2-8     | बहुत तेज़ | बहुत अच्छा | 8GB  |
| LCM-SDXL        | 4-8     | तेज़      | बहुत अच्छा | 8GB  |
| LCM-LoRA + SDXL | 4-8     | तेज़      | उत्कृष्ट   | 10GB |
| SD Turbo (1.5)  | 1-4     | सबसे तेज  | अच्छा      | 4GB  |

## CLORE.AI पर त्वरित डिप्लॉय

**Docker इमेज:**

```
pytorch/pytorch:2.5.1-cuda12.4-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(
    'stabilityai/sdxl-turbo',
    torch_dtype=torch.float16,
    variant='fp16'
).to('cuda')

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

gr.Interface(
    fn=generate,
    inputs=[
        gr.Textbox(label='Prompt'),
        gr.Slider(1, 4, value=1, step=1, label='Steps'),
        gr.Number(value=-1, label='Seed')
    ],
    outputs=gr.Image(),
    title='SDXL Turbo - रीयल-टाइम जनरेशन'
).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` नीचे दिए उदाहरणों में।

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

| मॉडल          | न्यूनतम GPU   | अनुशंसित |
| ------------- | ------------- | -------- |
| SD Turbo      | RTX 3060 8GB  | RTX 3070 |
| SDXL टर्बो    | RTX 3070 8GB  | RTX 3080 |
| SDXL लाइटनिंग | RTX 3070 8GB  | RTX 3090 |
| LCM-SDXL      | RTX 3080 10GB | RTX 4090 |

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

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

## SDXL टर्बो

### मूल उपयोग

```python
import torch
from diffusers import AutoPipelineForText2Image

pipe = AutoPipelineForText2Image.from_pretrained(
    "stabilityai/sdxl-turbo",
    torch_dtype=torch.float16,
    variant="fp16"
)
pipe.to("cuda")

# 1 चरण में उत्पन्न करें!
image = pipe(
    prompt="एक सिनेमैटिक शॉट जिसमें एक बच्चे रैकून ने जटिल इतालवी पुजारी की जाकेट पहनी है",
    num_inference_steps=1,
    guidance_scale=0.0  # Turbo CFG का उपयोग नहीं करता
).images[0]

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

### बेहतरीन सेटिंग्स

```python
# 1 चरण - सबसे तेज़, अच्छी गुणवत्ता
image = pipe(prompt, num_inference_steps=1, guidance_scale=0.0).images[0]

# 2 चरण - बेहतर विवरण
image = pipe(prompt, num_inference_steps=2, guidance_scale=0.0).images[0]

# 4 चरण - टर्बो के लिए सर्वश्रेष्ठ गुणवत्ता
image = pipe(prompt, num_inference_steps=4, guidance_scale=0.0).images[0]
```

## SDXL लाइटनिंग

### 2-चरण जनरेशन

```python
import torch
from diffusers import StableDiffusionXLPipeline, EulerDiscreteScheduler
from huggingface_hub import hf_hub_download

base = "stabilityai/stable-diffusion-xl-base-1.0"
repo = "ByteDance/SDXL-Lightning"
ckpt = "sdxl_lightning_2step_unet.safetensors"

# बेस मॉडल लोड करें
pipe = StableDiffusionXLPipeline.from_pretrained(
    base,
    torch_dtype=torch.float16,
    variant="fp16"
).to("cuda")

# लाइटनिंग यूनिट लोड करें
pipe.unet.load_state_dict(
    torch.load(hf_hub_download(repo, ckpt), map_location="cuda")
)

# शेड्यूलर कॉन्फ़िगर करें
pipe.scheduler = EulerDiscreteScheduler.from_config(
    pipe.scheduler.config,
    timestep_spacing="trailing"
)

# 2 चरणों में उत्पन्न करें
image = pipe(
    "एक बगीचे में मुस्कुराती हुई एक लड़की",
    num_inference_steps=2,
    guidance_scale=0.0
).images[0]

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

### 4-चरण (उच्चतर गुणवत्ता)

```python
ckpt = "sdxl_lightning_4step_unet.safetensors"
# ... वही सेटअप ...

image = pipe(
    prompt,
    num_inference_steps=4,
    guidance_scale=0.0
).images[0]
```

## LCM-LoRA

तेज़ जनरेशन के लिए किसी भी SDXL मॉडल के साथ उपयोग करें:

```python
import torch
from diffusers import DiffusionPipeline, LCMScheduler

pipe = DiffusionPipeline.from_pretrained(
    "stabilityai/stable-diffusion-xl-base-1.0",
    torch_dtype=torch.float16,
    variant="fp16"
)
pipe.to("cuda")

# LCM-LoRA लोड करें
pipe.load_lora_weights("latent-consistency/lcm-lora-sdxl")

# LCM शेड्यूलर सेट करें
pipe.scheduler = LCMScheduler.from_config(pipe.scheduler.config)

# 4 चरणों में उत्पन्न करें
image = pipe(
    "जंगल में एक अंतरिक्ष यात्री, ठंडे रंग पैलेट, म्यूट रंग, विस्तृत, 8k",
    num_inference_steps=4,
    guidance_scale=1.0  # LCM कम CFG का उपयोग करता है
).images[0]

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

### कस्टम LoRAs के साथ

```python
# बेस + LCM-LoRA + स्टाइल LoRA लोड करें
pipe.load_lora_weights("latent-consistency/lcm-lora-sdxl", adapter_name="lcm")
pipe.load_lora_weights("your-style-lora", adapter_name="style")

# एडाप्टर्स को संयोजित करें
pipe.set_adapters(["lcm", "style"], adapter_weights=[1.0, 0.8])

image = pipe(prompt, num_inference_steps=4, guidance_scale=1.5).images[0]
```

## SD Turbo (SD 1.5)

कम VRAM आवश्यकताओं के लिए:

```python
import torch
from diffusers import AutoPipelineForText2Image

pipe = AutoPipelineForText2Image.from_pretrained(
    "stabilityai/sd-turbo",
    torch_dtype=torch.float16,
    variant="fp16"
)
pipe.to("cuda")

image = pipe(
    "एक बिल्ली की फोटो",
    num_inference_steps=1,
    guidance_scale=0.0
).images[0]
```

## इमेज-टू-इमेज

### SDXL Turbo Img2Img

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

pipe = AutoPipelineForImage2Image.from_pretrained(
    "stabilityai/sdxl-turbo",
    torch_dtype=torch.float16,
    variant="fp16"
)
pipe.to("cuda")

init_image = load_image("input.jpg").resize((512, 512))

image = pipe(
    prompt="बिल्ली जादूगर, गैन्डाल्फ, लॉर्ड ऑफ द रिंग्स, विस्तृत, फैंटेसी",
    image=init_image,
    num_inference_steps=2,
    strength=0.5,
    guidance_scale=0.0
).images[0]
```

## बैच जनरेशन

```python
import torch
from diffusers import AutoPipelineForText2Image

pipe = AutoPipelineForText2Image.from_pretrained(
    "stabilityai/sdxl-turbo",
    torch_dtype=torch.float16
).to("cuda")

prompts = [
    "पहाड़ों पर एक सूर्यास्त",
    "रात में एक भविष्यवादी शहर",
    "एक बगीचे में एक प्यारा रोबोट",
    "कुहासे में एक प्राचीन मंदिर"
]

# बैच जनरेट करें
images = pipe(
    prompts,
    num_inference_steps=1,
    guidance_scale=0.0
).images

for i, img in enumerate(images):
    img.save(f"batch_{i}.png")
```

## रीयल-टाइम स्ट्रीमिंग

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

pipe = AutoPipelineForText2Image.from_pretrained(
    "stabilityai/sdxl-turbo",
    torch_dtype=torch.float16
).to("cuda")

def generate_realtime(prompt):
    if not prompt:
        return None
    image = pipe(
        prompt,
        num_inference_steps=1,
        guidance_scale=0.0,
        width=512,
        height=512
    ).images[0]
    return image

demo = gr.Interface(
    fn=generate_realtime,
    inputs=gr.Textbox(label="Prompt"),
    outputs=gr.Image(label="Generated"),
    live=True,  # टाइप करते समय अपडेट करें
    title="रीयल-टाइम SDXL Turbo"
)

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

## प्रदर्शन तुलना

| मॉडल          | स्टेप्स | रिज़ॉल्यूशन | RTX 3090 | RTX 4090 | A100  |
| ------------- | ------- | ----------- | -------- | -------- | ----- |
| SDXL (बेस)    | 30      | 1024x1024   | 8s       | 5s       | 4s    |
| SDXL टर्बो    | 1       | 512x512     | 0.3s     | 0.2s     | 0.15s |
| SDXL टर्बो    | 4       | 512x512     | 0.8s     | 0.5s     | 0.4s  |
| SDXL लाइटनिंग | 2       | 1024x1024   | 0.8s     | 0.5s     | 0.4s  |
| SDXL लाइटनिंग | 4       | 1024x1024   | 1.2s     | 0.8s     | 0.6s  |
| LCM-SDXL      | 4       | 1024x1024   | 1.5s     | 1.0s     | 0.7s  |

## गुणवत्ता तुलना

| पहलू             | SDXL 30 चरण | Turbo 4 चरण | लाइटनिंग 4 चरण |
| ---------------- | ----------- | ----------- | -------------- |
| विवरण            | उत्कृष्ट    | अच्छा       | बहुत अच्छा     |
| टेक्स्ट रेंडरिंग | अच्छा       | खराब        | खराब           |
| चेहरे            | बहुत अच्छा  | अच्छा       | अच्छा          |
| संगति            | उत्कृष्ट    | अच्छा       | बहुत अच्छा     |
| शैली विविधता     | उत्कृष्ट    | अच्छा       | बहुत अच्छा     |

## कब क्या उपयोग करें

| उपयोग का मामला        | अनुशंसित      | स्टेप्स |
| --------------------- | ------------- | ------- |
| रीयल-टाइम प्रीव्यू    | SDXL टर्बो    | 1       |
| इंटरएक्टिव ऐप्स       | SDXL टर्बो    | 1-2     |
| त्वरित पुनरावृत्तियाँ | SDXL लाइटनिंग | 2-4     |
| कस्टम LoRAs के साथ    | LCM-LoRA      | 4-8     |
| अधिकतम गुणवत्ता       | SDXL लाइटनिंग | 8       |
| कम VRAM               | SD Turbo      | 1-2     |

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

सामान्य CLORE.AI मार्केटप्लेस दरें:

| GPU           | घंटात्मक दर | छवियां/घंटा (1-चरण) |
| ------------- | ----------- | ------------------- |
| RTX 3060 12GB | \~$0.03     | \~3,000             |
| RTX 3090 24GB | \~$0.06     | \~8,000             |
| RTX 4090 24GB | \~$0.10     | \~12,000            |
| A100 40GB     | \~$0.17     | \~15,000            |

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

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

### धुंधले परिणाम

* SDXL Turbo स्वाभाविक रूप से 512x512 आउटपुट देता है
* 1024x1024 के लिए SDXL Lightning का उपयोग करें
* पोस्ट-प्रोसेस में अपस्केलिंग जोड़ें

### guidance\_scale त्रुटि

```python
# SDXL Turbo: हमेशा 0.0 का उपयोग करें
image = pipe(prompt, guidance_scale=0.0).images[0]

# LCM: 1.0-2.0 का उपयोग करें
image = pipe(prompt, guidance_scale=1.5).images[0]

# लाइटनिंग: 0.0 का उपयोग करें
image = pipe(prompt, guidance_scale=0.0).images[0]
```

### LoRA काम नहीं कर रहा

```python
# LCM-LoRA के लिए, LCMScheduler का उपयोग करना आवश्यक है
from diffusers import LCMScheduler

pipe.scheduler = LCMScheduler.from_config(pipe.scheduler.config)
pipe.load_lora_weights("latent-consistency/lcm-lora-sdxl")
```

### आउट ऑफ़ मेमोरी

```python
# मेमोरी ऑप्टिमाइज़ेशन सक्षम करें
pipe.enable_model_cpu_offload()
pipe.enable_vae_slicing()

# या छोटे मॉडल का उपयोग करें
# SDXL Turbo के बजाय SD Turbo
```

## अगले कदम

* [FLUX.1](/guides/guides_v2-hi/image-generation/flux.md) - उच्चतम गुणवत्ता जनरेशन
* [Stable Diffusion WebUI](/guides/guides_v2-hi/image-generation/stable-diffusion-webui.md) - पूर्ण UI
* [ComfyUI](/guides/guides_v2-hi/image-generation/comfyui.md) - नोड-आधारित वर्कफ़्लो
* [Real-ESRGAN](/guides/guides_v2-hi/image-processing/real-esrgan-upscaling.md) - परिणामों को अपस्केल करें


---

# 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/sdxl-turbo.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.
