> 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

Schnelle Bilderzeugung mit PixArt-Alpha und PixArt-Sigma

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

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

## Mieten auf CLORE.AI

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

### Greife auf deinen Server zu

* Verbindungsdetails finden in **Meine Bestellungen**
* Web-Oberflächen: Verwende die HTTP-Port-URL
* SSH: `ssh -p <port> root@<proxy-address>`

## Was ist PixArt?

PixArt-Modelle bieten:

* 10x schneller als SDXL
* Hochwertige 1024-Pixel-Bilder
* Starke Textdarstellung
* Effiziente Trainingsmethoden

## Modellvarianten

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

## Schnell bereitstellen

**Docker-Image:**

```
pytorch/pytorch:2.11.0-cuda12.8-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)
"
```

## Auf deinen Dienst zugreifen

Nach der Bereitstellung findest du deine `http_pub` URL in **Meine Bestellungen**:

1. Gehe zu **Meine Bestellungen** Seite
2. Klicke auf deine Bestellung
3. Finde die `http_pub` URL (z. B. `abc123.clorecloud.net`)

Verwende `https://YOUR_HTTP_PUB_URL` anstelle von `localhost` in den folgenden Beispielen.

## 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 Katzenastronaut schwebt im Weltraum, die 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="ein wunderschöner Sonnenuntergang über Bergen",
    negative_prompt="unscharf, 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="ein professionelles Foto eines roten Sportwagens",
    num_inference_steps=30,
    guidance_scale=4.5
).images[0]

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

## Speicheroptimierung

### Für 8 GB VRAM

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

# CPU-Auslagerung
pipe.enable_model_cpu_offload()

# Sequentielle CPU-Auslagerung (aggressiver)

# pipe.enable_sequential_cpu_offload()
```

### VAE-Slicing aktivieren

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

## Batch-Generierung

```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 Fantasy-Schloss 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]}...")
```

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

## Textdarstellung

PixArt glänzt bei Text in Bildern:

```python
prompt = """
Ein Vintage-Filmposter mit dem Titel "COSMIC ADVENTURE" in fetten Buchstaben,
mit einem Raumschiff und Planeten, im 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="Leitwert"),
        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="Generiertes 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      | Zeit für 1024x1024 |
| ------------ | -------- | ------------------ |
| PixArt-Alpha | RTX 3090 | \~3s               |
| PixArt-Sigma | RTX 3090 | \~5 s              |
| SDXL         | RTX 3090 | \~15s              |
| PixArt-Alpha | RTX 4090 | \~2s               |
| PixArt-Sigma | RTX 4090 | \~3s               |

## Qualitätseinstellungen

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

## Fehlerbehebung

### Speicher erschöpft

```python

# Auslagerung aktivieren
pipe.enable_model_cpu_offload()

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

### Schlechte Qualität

* Erhöhe die Schritte (25-40)
* Passe die Guidance-Skala an
* Detailliertere Prompts

### Langsame Generierung

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

## Kostenschätzung

Übliche CLORE.AI-Marktplatzpreise (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           |

*Die Preise variieren je nach Anbieter und Nachfrage. Prüfen Sie* [*CLORE.AI-Marktplatz*](https://clore.ai/marketplace) *für aktuelle Preise.*

**Geld sparen:**

* Nutzen Sie den **Spot** Markt für unterbrechbare Arbeit — etwa ein Drittel der Server bietet Spot-Preise unter dem On-Demand-Preis (Median ca. 13 % Rabatt), der Rest ist gleichauf
* Bezahlen Sie mit **CLORE** Tokens
* Vergleichen Sie Preise zwischen verschiedenen Anbietern

## Nächste Schritte

* FLUX-Generierung - Beste Qualität
* Stable Diffusion WebUI - Mehr Funktionen
* [ControlNet-Anleitung](/guides/guides_v2-de/bildverarbeitung/controlnet-advanced.md) - Steuerung 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, and the optional `goal` query parameter:

```
GET https://docs.clore.ai/guides/guides_v2-de/bildgenerierung/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.
