> 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/pixart-image-gen.md).

# PixArt

PixArt-Alpha और PixArt-Sigma के साथ तेज़ इमेज जनरेशन

PixArt-Alpha और PixArt-Sigma के साथ तेज़ी से चित्र बनाएं।

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

## CLORE.AI पर किराए पर लेना

1. विज़िट करें [CLORE.AI मार्केटप्लेस](https://clore.ai/marketplace)
2. GPU प्रकार, VRAM और कीमत के अनुसार फ़िल्टर करें
3. चुनें **ऑन-डिमांड** (स्थिर दर) या **स्पॉट** (बोली मूल्य)
4. अपना ऑर्डर कॉन्फ़िगर करें:
   * Docker इमेज चुनें
   * पोर्ट सेट करें (SSH के लिए TCP, वेब UI के लिए HTTP)
   * यदि आवश्यक हो तो environment variables जोड़ें
   * स्टार्टअप कमांड दर्ज करें
5. भुगतान चुनें: **CLORE**, **BTC**या **USDT/USDC**
6. ऑर्डर बनाएं और डिप्लॉयमेंट की प्रतीक्षा करें

### अपने सर्वर तक पहुँचें

* कनेक्शन विवरण यहाँ खोजें **मेरे ऑर्डर**
* वेब इंटरफ़ेस: HTTP पोर्ट URL का उपयोग करें
* SSH: `ssh -p <port> root@<proxy-address>`

## PixArt क्या है?

PixArt मॉडल प्रदान करते हैं:

* SDXL से 10 गुना तेज़
* उच्च-गुणवत्ता वाली 1024px छवियाँ
* बेहतर टेक्स्ट रेंडरिंग
* कुशल प्रशिक्षण विधियाँ

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

| मॉडल         | गुणवत्ता  | गति   | VRAM |
| ------------ | --------- | ----- | ---- |
| PixArt-Alpha | उत्कृष्ट  | तेज़  | 8GB  |
| PixArt-Sigma | सर्वोत्तम | मध्यम | 12GB |

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

**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
from diffusers import PixArtAlphaPipeline
import torch

pipe = PixArtAlphaPipeline.from_pretrained('PixArt-alpha/PixArt-XL-2-1024-MS', torch_dtype=torch.float16)
pipe.to('cuda')

def generate(prompt, steps):
    image = pipe(prompt, num_inference_steps=steps).images[0]
    return image

demo = gr.Interface(fn=generate, inputs=[gr.Textbox(), gr.Slider(10, 50, 20)], outputs=gr.Image(), title='PixArt')
demo.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
```

## PixArt-Alpha

### मूल जनरेशन

```python
from diffusers import PixArtAlphaPipeline
import torch

pipe = PixArtAlphaPipeline.from_pretrained(
    "PixArt-alpha/PixArt-XL-2-1024-MS",
    torch_dtype=torch.float16
)
pipe.to("cuda")

prompt = "एक बिल्ली-अंतरिक्ष यात्री अंतरिक्ष में तैरता हुआ, पृष्ठभूमि में पृथ्वी, फोटोरियलिस्टिक"

image = pipe(
    prompt=prompt,
    num_inference_steps=20,
    guidance_scale=4.5
).images[0]

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

### निर्माण पैरामीटर

```python
image = pipe(
    prompt="पहाड़ों के ऊपर एक सुंदर सूर्यास्त",
    negative_prompt="धुंधला, निम्न गुणवत्ता",
    num_inference_steps=20,      # गुणवत्ता (10-50)
    guidance_scale=4.5,          # प्रॉम्प्ट अनुपालन (3-7)
    height=1024,
    width=1024,
    generator=torch.Generator("cuda").manual_seed(42)
).images[0]
```

## PixArt-Sigma

उच्च गुणवत्ता वाला संस्करण:

```python
from diffusers import PixArtSigmaPipeline
import torch

pipe = PixArtSigmaPipeline.from_pretrained(
    "PixArt-alpha/PixArt-Sigma-XL-2-1024-MS",
    torch_dtype=torch.float16
)
pipe.to("cuda")
pipe.enable_model_cpu_offload()

image = pipe(
    prompt="एक लाल स्पोर्ट्स कार की पेशेवर फ़ोटो",
    num_inference_steps=30,
    guidance_scale=4.5
).images[0]

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

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

### 8GB VRAM के लिए

```python
pipe = PixArtAlphaPipeline.from_pretrained(
    "PixArt-alpha/PixArt-XL-2-1024-MS",
    torch_dtype=torch.float16
)

# CPU ऑफ़लोड
pipe.enable_model_cpu_offload()

# अनुक्रमिक CPU ऑफ़लोड (अधिक आक्रामक)

# pipe.enable_sequential_cpu_offload()
```

### VAE slicing सक्षम करें

```python
pipe.enable_vae_slicing()
pipe.enable_vae_tiling()
```

## बैच जनरेशन

```python
from diffusers import PixArtAlphaPipeline
import torch

pipe = PixArtAlphaPipeline.from_pretrained(
    "PixArt-alpha/PixArt-XL-2-1024-MS",
    torch_dtype=torch.float16
).to("cuda")

prompts = [
    "रात में एक साइबरपंक शहर",
    "एक शांत जापानी उद्यान",
    "एक चट्टान पर बना काल्पनिक किला",
    "समुद्र के नीचे की प्रवाल भित्ति"
]

for i, prompt in enumerate(prompts):
    image = pipe(prompt, num_inference_steps=20).images[0]
    image.save(f"output_{i:03d}.png")
    print(f"जनरेट किया गया: {prompt[:50]}...")
```

## विभिन्न रिज़ॉल्यूशन

```python

# समर्थित रिज़ॉल्यूशन
resolutions = [
    (512, 512),
    (768, 768),
    (1024, 1024),
    (1024, 512),   # लैंडस्केप
    (512, 1024),   # पोर्ट्रेट
    (768, 1024),
    (1024, 768),
]

for w, h in resolutions:
    image = pipe(
        prompt="एक सुंदर परिदृश्य",
        width=w,
        height=h,
        num_inference_steps=20
    ).images[0]

    image.save(f"output_{w}x{h}.png")
```

## टेक्स्ट रेंडरिंग

PixArt छवियों में टेक्स्ट के लिए उत्कृष्ट है:

```python
prompt = """
एक विंटेज मूवी पोस्टर, जिसमें "COSMIC ADVENTURE" शीर्षक मोटे अक्षरों में हो,
जिसमें एक अंतरिक्ष यान और ग्रह हों, 1950 के दशक की रेट्रो शैली
"""

image = pipe(
    prompt=prompt,
    num_inference_steps=30,
    guidance_scale=5.0
).images[0]
```

## Gradio इंटरफ़ेस

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

pipe = PixArtAlphaPipeline.from_pretrained(
    "PixArt-alpha/PixArt-XL-2-1024-MS",
    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="प्रॉम्प्ट", lines=3),
        gr.Textbox(label="नकारात्मक प्रॉम्प्ट"),
        gr.Slider(10, 50, value=20, step=1, label="स्टेप्स"),
        gr.Slider(1, 10, value=4.5, 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="PixArt इमेज जनरेटर"
)

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

## एपीआई सर्वर

```python
from fastapi import FastAPI
from fastapi.responses import Response
from diffusers import PixArtAlphaPipeline
import torch
import io

app = FastAPI()

pipe = PixArtAlphaPipeline.from_pretrained(
    "PixArt-alpha/PixArt-XL-2-1024-MS",
    torch_dtype=torch.float16
).to("cuda")

@app.post("/generate")
async def generate(
    prompt: str,
    negative_prompt: str = "",
    steps: int = 20,
    guidance: float = 4.5,
    width: int = 1024,
    height: int = 1024
):
    image = pipe(
        prompt=prompt,
        negative_prompt=negative_prompt,
        num_inference_steps=steps,
        guidance_scale=guidance,
        width=width,
        height=height
    ).images[0]

    buffer = io.BytesIO()
    image.save(buffer, format="PNG")
    return Response(content=buffer.getvalue(), media_type="image/png")

# चलाएँ: uvicorn server:app --host 0.0.0.0 --port 8000
```

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

| मॉडल         | GPU      | 1024x1024 समय |
| ------------ | -------- | ------------- |
| PixArt-Alpha | RTX 3090 | \~3s          |
| PixArt-Sigma | RTX 3090 | \~5 सेकंड     |
| SDXL         | RTX 3090 | \~15 सेकंड    |
| PixArt-Alpha | RTX 4090 | \~2s          |
| PixArt-Sigma | RTX 4090 | \~3s          |

## गुणवत्ता सेटिंग्स

| उपयोग-प्रकरण  | स्टेप्स | गाइडेंस |
| ------------- | ------- | ------- |
| पूर्वावलोकन   | 10-15   | 4.0     |
| मानक          | 20      | 4.5     |
| उच्च गुणवत्ता | 30-40   | 5.0     |

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

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

```python

# ऑफ़लोडिंग सक्षम करें
pipe.enable_model_cpu_offload()

# या छोटा रिज़ॉल्यूशन उपयोग करें
width, height = 768, 768
```

### खराब गुणवत्ता

* स्टेप्स बढ़ाएँ (25-40)
* गाइडेंस स्केल समायोजित करें
* अधिक विस्तृत प्रॉम्प्ट

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

* PixArt-Alpha का उपयोग करें (तेज़)
* स्टेप्स कम करें
* रिज़ॉल्यूशन कम करें

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

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) *वर्तमान दरों के लिए।*

**पैसे बचाएँ:**

* का उपयोग करें **स्पॉट** बाधित किए जा सकने वाले कार्य के लिए मार्केट — लगभग एक-तिहाई सर्वरों की स्पॉट कीमत ऑन-डिमांड से कम होती है (मध्य \~13% छूट), बाकी उससे मेल खाते हैं
* से भुगतान करें **CLORE** टोकन
* विभिन्न प्रदाताओं के बीच कीमतों की तुलना करें

## अगले चरण

* FLUX जनरेशन - सर्वोत्तम गुणवत्ता
* Stable Diffusion WebUI - अधिक सुविधाएँ
* [ControlNet मार्गदर्शिका](/guides/guides_v2-hi/image-processing/controlnet-advanced.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/pixart-image-gen.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.
