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

# PixArt

Erzeuge schnell Bilder mit PixArt-Alpha und PixArt-Sigma.

{% hint style="success" %}
Alle Beispiele können auf GPU-Servern ausgeführt werden, die über [CLORE.AI Marketplace](https://clore.ai/marketplace).
{% endhint %}

## Mieten auf CLORE.AI

1. Besuchen Sie [CLORE.AI Marketplace](https://clore.ai/marketplace)
2. Nach GPU-Typ, VRAM und Preis filtern
3. Wählen **On-Demand** (Festpreis) oder **Spot** (Gebotspreis)
4. Konfigurieren Sie Ihre Bestellung:
   * Docker-Image auswählen
   * Ports festlegen (TCP für SSH, HTTP für Web-UIs)
   * Umgebungsvariablen bei Bedarf hinzufügen
   * Startbefehl eingeben
5. Zahlung auswählen: **CLORE**, **BTC**, oder **USDT/USDC**
6. Bestellung erstellen und auf Bereitstellung warten

### Zugriff auf Ihren Server

* Verbindungsdetails finden Sie in **Meine Bestellungen**
* Webschnittstellen: Verwenden Sie die HTTP-Port-URL
* SSH: `ssh -p <port> root@<proxy-address>`

## Was ist PixArt?

PixArt-Modelle bieten:

* 10x schneller als SDXL
* Hochwertige 1024px-Bilder
* Starke Textrendering-Fähigkeiten
* Effiziente Trainingsmethoden

## Modellvarianten

| Modell       | Qualität  | Geschwindigkeit | VRAM |
| ------------ | --------- | --------------- | ---- |
| PixArt-Alpha | Großartig | Schnell         | 8GB  |
| PixArt-Sigma | Am besten | Mittel          | 12GB |

## Schnelle Bereitstellung

**Docker-Image:**

```
pytorch/pytorch:2.5.1-cuda12.4-cudnn9-devel
```

**Ports:**

```
22/tcp
7860/http
```

**Befehl:**

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

## Zugriff auf Ihren Dienst

Nach der Bereitstellung finden Sie Ihre `http_pub` URL in **Meine Bestellungen**:

1. Gehen Sie zur **Meine Bestellungen** Seite
2. Klicken Sie auf Ihre Bestellung
3. Finden Sie die `http_pub` URL (z. B., `abc123.clorecloud.net`)

Verwenden Sie `https://IHRE_HTTP_PUB_URL` anstelle von `localhost` in den Beispielen unten.

## Installation

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

## PixArt-Alpha

### Grundlegende Generierung

```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 = "Ein Katzen-Astronaut, der im Weltraum schwebt, Erde im Hintergrund, fotorealistisch"

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

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

### Generierungsparameter

```python
image = pipe(
    prompt="a beautiful sunset over mountains",
    negative_prompt="verschwommen, niedrige Qualität",
    num_inference_steps=20,      # Qualität (10-50)
    guidance_scale=4.5,          # Prompt-Treue (3-7)
    height=1024,
    width=1024,
    generator=torch.Generator("cuda").manual_seed(42)
).images[0]
```

## PixArt-Sigma

Höherwertige Version:

```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="eine professionelle Fotografie eines roten Sportwagens",
    num_inference_steps=30,
    guidance_scale=4.5
).images[0]

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

## Speicheroptimierung

### Für 8GB VRAM

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

# CPU-Auslagerung
pipe.enable_model_cpu_offload()

# Sequenzielle CPU-Auslagerung (aggressiver)

# pipe.enable_sequential_cpu_offload()
```

### VAE-Slicing aktivieren

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

## Batch-Erzeugung

```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 = [
    "eine Cyberpunk-Stadt bei Nacht",
    "ein friedlicher japanischer Garten",
    "ein Fantasieschloss auf einer Klippe",
    "ein unterwasser Korallenriff"
]

for i, prompt in enumerate(prompts):
    image = pipe(prompt, num_inference_steps=20).images[0]
    image.save(f"output_{i:03d}.png")
    print(f"Generiert: {prompt[:50]}...")
```

## Verschiedene Auflösungen

```python

# Unterstützte Auflösungen
resolutions = [
    (512, 512),
    (768, 768),
    (1024, 1024),
    (1024, 512),   # Querformat
    (512, 1024),   # Hochformat
    (768, 1024),
    (1024, 768),
]

for w, h in resolutions:
    image = pipe(
        prompt="eine schöne Landschaft",
        width=w,
        height=h,
        num_inference_steps=20
    ).images[0]

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

## Textrendering

PixArt ist hervorragend bei Text in Bildern:

```python
prompt = """
Ein Vintage-Filmplakat mit dem Titel "COSMIC ADVENTURE" in fetten Buchstaben,
mit einem Raumschiff und Planeten, Retro-Stil der 1950er Jahre
"""

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

## Gradio-Oberfläche

```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="Negativer Prompt"),
        gr.Slider(10, 50, value=20, step=1, label="Schritte"),
        gr.Slider(1, 10, value=4.5, step=0.5, label="Guidance"),
        gr.Slider(512, 1024, value=1024, step=64, label="Breite"),
        gr.Slider(512, 1024, value=1024, step=64, label="Höhe"),
        gr.Number(value=-1, label="Seed (-1 für zufällig)")
    ],
    outputs=gr.Image(label="Erzeugtes Bild"),
    title="PixArt Bildgenerator"
)

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

## API-Server

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

# Ausführen: uvicorn server:app --host 0.0.0.0 --port 8000
```

## Leistungsvergleich

| Modell       | GPU      | 1024x1024 Zeit |
| ------------ | -------- | -------------- |
| PixArt-Alpha | RTX 3090 | \~3s           |
| PixArt-Sigma | RTX 3090 | \~5s           |
| SDXL         | RTX 3090 | \~15s          |
| PixArt-Alpha | RTX 4090 | \~2s           |
| PixArt-Sigma | RTX 4090 | \~3s           |

## Qualitätseinstellungen

| Einsatzgebiet | Schritte | Guidance |
| ------------- | -------- | -------- |
| Vorschau      | 10-15    | 4.0      |
| Standard      | 20       | 4.5      |
| Hohe Qualität | 30-40    | 5.0      |

## Fehlerbehebung

### Kein Speicher mehr

```python

# Offloading aktivieren
pipe.enable_model_cpu_offload()

# Oder kleinere Auflösung verwenden
width, height = 768, 768
```

### Schlechte Qualität

* Schritte erhöhen (25-40)
* Guidance-Skala anpassen
* Detailliertere Prompts

### Langsame Generierung

* Verwende PixArt-Alpha (schneller)
* Reduziere die Schritte
* Niedrigere Auflösung

## Kostenabschätzung

Typische CLORE.AI-Marktplatztarife (Stand 2024):

| GPU       | Stundensatz | Tagessatz | 4-Stunden-Sitzung |
| --------- | ----------- | --------- | ----------------- |
| 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           |

*Preise variieren je nach Anbieter und Nachfrage. Prüfen Sie* [*CLORE.AI Marketplace*](https://clore.ai/marketplace) *auf aktuelle Preise.*

**Geld sparen:**

* Verwenden Sie **Spot** Markt für flexible Workloads (oft 30–50% günstiger)
* Bezahlen mit **CLORE** Token
* Preise bei verschiedenen Anbietern vergleichen

## Nächste Schritte

* FLUX-Generierung - Beste Qualität
* Stable Diffusion WebUI - Mehr Funktionen
* [ControlNet Anleitung](/guides/guides_v2-de/bildverarbeitung/controlnet-advanced.md) - Kontrolle hinzufügen


---

# 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:

```
GET https://docs.clore.ai/guides/guides_v2-de/bildgenerierung/pixart-image-gen.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
