> 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 पर SDXL Turbo और LCM के साथ 1-4 चरणों में छवियाँ जनरेट करें

CLORE.AI GPUs पर 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 Turbo      | 1-4     | सबसे तेज़ | अच्छा    | 8GB  |
| SDXL Lightning  | 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.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(
    '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='प्रॉम्प्ट'),
        gr.Slider(1, 4, value=1, step=1, label='स्टेप्स'),
        gr.Number(value=-1, label='सीड')
    ],
    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 Turbo     | RTX 3070 8GB  | RTX 3080 |
| SDXL Lightning | RTX 3070 8GB  | RTX 3090 |
| LCM-SDXL       | RTX 3080 10GB | RTX 4090 |

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

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

## SDXL Turbo

### मूल उपयोग

```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 स्टेप - Turbo के लिए सर्वोत्तम गुणवत्ता
image = pipe(prompt, num_inference_steps=4, guidance_scale=0.0).images[0]
```

## SDXL Lightning

### 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")

# Lightning UNet लोड करें
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="प्रॉम्प्ट"),
    outputs=gr.Image(label="जनरेटेड"),
    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       | 4 सेकंड |
| SDXL Turbo     | 1       | 512x512     | 0.3s     | 0.2s     | 0.15s   |
| SDXL Turbo     | 4       | 512x512     | 0.8s     | 0.5s     | 0.4s    |
| SDXL Lightning | 2       | 1024x1024   | 0.8s     | 0.5s     | 0.4s    |
| SDXL Lightning | 4       | 1024x1024   | 1.2s     | 0.8s     | 0.6s    |
| LCM-SDXL       | 4       | 1024x1024   | 1.5s     | 1.0s     | 0.7s    |

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

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

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

| उपयोग-प्रकरण          | अनुशंसित       | स्टेप्स |
| --------------------- | -------------- | ------- |
| रीयल-टाइम प्रीव्यू    | SDXL Turbo     | 1       |
| इंटरैक्टिव ऐप्स       | SDXL Turbo     | 1-2     |
| त्वरित पुनरावृत्तियाँ | SDXL Lightning | 2-4     |
| कस्टम LoRAs के साथ    | LCM-LoRA       | 4-8     |
| अधिकतम गुणवत्ता       | SDXL Lightning | 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]

# Lightning: 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) - सर्वोच्च गुणवत्ता वाली जनरेशन
* [स्टेबल डिफ्यूजन वेबयूआई](/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.
