> 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 के साथ जल्दी से इमेज बनाएं।

{% 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)
   * यदि आवश्यक हो तो एनवायरनमेंट वेरिएबल जोड़ें
   * स्टार्टअप कमांड दर्ज करें
5. भुगतान चुनें: **CLORE**, **BTC**, या **USDT/USDC**
6. ऑर्डर बनाएं और डिप्लॉयमेंट का इंतज़ार करें

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

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

## PixArt क्या है?

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

* SDXL से 10x तेज़
* उच्च-गुणवत्ता 1024px इमेजेस
* मजबूत टेक्स्ट रेंडरिंग
* प्रभावी प्रशिक्षण विधियाँ

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

| मॉडल         | गुणवत्ता   | स्पीड | VRAM |
| ------------ | ---------- | ----- | ---- |
| PixArt-Alpha | बहुत अच्छा | तेज़  | 8GB  |
| PixArt-Sigma | सर्वोत्तम  | मध्यम | 12GB |

## त्वरित तैनाती

**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
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 = "A cat astronaut floating in space, Earth in background, photorealistic"

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

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

### जनरेशन पैरामीटर

```python
image = pipe(
    prompt="a beautiful sunset over mountains",
    negative_prompt="blurry, low quality",
    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="a professional photograph of a red sports car",
    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 स्लाइसिंग सक्षम करें

```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 = [
    "a cyberpunk city at night",
    "a peaceful japanese garden",
    "a fantasy castle on a cliff",
    "an underwater coral reef"
]

for i, prompt in enumerate(prompts):
    image = pipe(prompt, num_inference_steps=20).images[0]
    image.save(f"output_{i:03d}.png")
    print(f"Generated: {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="a beautiful landscape",
        width=w,
        height=h,
        num_inference_steps=20
    ).images[0]

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

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

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

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

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="Prompt", lines=3),
        gr.Textbox(label="Negative Prompt"),
        gr.Slider(10, 50, value=20, step=1, label="Steps"),
        gr.Slider(1, 10, value=4.5, step=0.5, label="Guidance"),
        gr.Slider(512, 1024, value=1024, step=64, label="Width"),
        gr.Slider(512, 1024, value=1024, step=64, label="Height"),
        gr.Number(value=-1, label="Seed (-1 for random)")
    ],
    outputs=gr.Image(label="Generated Image"),
    title="PixArt Image Generator"
)

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

## API सर्वर

```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 | \~5s          |
| SDXL         | RTX 3090 | \~15s         |
| 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) *वर्तमान दरों के लिए।*

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

* उपयोग करें **स्पॉट** लचीले वर्कलोड के लिए मार्केट (अक्सर 30-50% सस्ता)
* भुगतान करें **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.
