> 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/gesicht-and-identitat/ip-adapter.md).

# IP-Adapter

Verwenden Sie Bilder als Eingabeaufforderungen für die Stable Diffusion-Generierung.

{% 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 IP-Adapter?

IP-Adapter ermöglicht Bild-Prompting:

* Verwenden Sie Referenzbilder zur Steuerung der Generierung
* Kombinieren Sie mit Text-Prompts
* Stilübertragung und Inhaltsübertragung
* Funktioniert mit SD 1.5 und SDXL

## Adaptertypen

| Adapter              | Einsatzgebiet                      | VRAM |
| -------------------- | ---------------------------------- | ---- |
| IP-Adapter           | Allgemeines Bild-Prompting         | 8GB  |
| IP-Adapter-Plus      | Höhere Qualität                    | 10GB |
| IP-Adapter-Face      | Gesichtsfokus                      | 10GB |
| IP-Adapter-Full-Face | Vollständige Gesichtsdetaillierung | 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 && \
python ip_adapter_app.py
```

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

## Grundlegendes Bild-Prompting

```python
from diffusers import AutoPipelineForText2Image
from diffusers.utils import load_image
import torch

pipe = AutoPipelineForText2Image.from_pretrained(
    "stabilityai/stable-diffusion-xl-base-1.0",
    torch_dtype=torch.float16
).to("cuda")

# IP-Adapter laden
pipe.load_ip_adapter(
    "h94/IP-Adapter",
    subfolder="sdxl_models",
    weight_name="ip-adapter_sdxl.bin"
)

# Referenzbild laden
ip_image = load_image("reference.jpg")

# Mit Bild-Prompt generieren
image = pipe(
    prompt="eine Katze im gleichen Stil",
    ip_adapter_image=ip_image,
    num_inference_steps=30
).images[0]

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

## Stiltransfer

```python
from diffusers import AutoPipelineForText2Image
from diffusers.utils import load_image
import torch

pipe = AutoPipelineForText2Image.from_pretrained(
    "runwayml/stable-diffusion-v1-5",
    torch_dtype=torch.float16
).to("cuda")

pipe.load_ip_adapter(
    "h94/IP-Adapter",
    subfolder="models",
    weight_name="ip-adapter_sd15.bin"
)

# Stilreferenz (z. B. Van-Gogh-Gemälde)
style_image = load_image("van_gogh_starry_night.jpg")

# Neue Inhalte in diesem Stil generieren
image = pipe(
    prompt="eine moderne Stadtsilhouette",
    ip_adapter_image=style_image,
    num_inference_steps=30,
    guidance_scale=7.5
).images[0]

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

## Gesichts-Adapter

Für gesichtsfokussierte Generierung:

```python
from diffusers import AutoPipelineForText2Image
from diffusers.utils import load_image
import torch

pipe = AutoPipelineForText2Image.from_pretrained(
    "stabilityai/stable-diffusion-xl-base-1.0",
    torch_dtype=torch.float16
).to("cuda")

# Gesichtspezifischen Adapter laden
pipe.load_ip_adapter(
    "h94/IP-Adapter",
    subfolder="sdxl_models",
    weight_name="ip-adapter-plus-face_sdxl_vit-h.bin"
)

# Referenzgesicht
face_image = load_image("face_reference.jpg")

# Porträt generieren
image = pipe(
    prompt="Porträtmalerei, Öl auf Leinwand, Museumsqualität",
    ip_adapter_image=face_image,
    num_inference_steps=30
).images[0]

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

## Kombinieren mehrerer Bilder

```python
from diffusers import AutoPipelineForText2Image
from diffusers.utils import load_image
import torch

pipe = AutoPipelineForText2Image.from_pretrained(
    "stabilityai/stable-diffusion-xl-base-1.0",
    torch_dtype=torch.float16
).to("cuda")

pipe.load_ip_adapter(
    "h94/IP-Adapter",
    subfolder="sdxl_models",
    weight_name="ip-adapter_sdxl.bin"
)

# Mehrere Referenzbilder
images = [
    load_image("style1.jpg"),
    load_image("style2.jpg")
]

# Beide zum Mischen verwenden
image = pipe(
    prompt="Landschaftsgemälde",
    ip_adapter_image=images,
    num_inference_steps=30
).images[0]
```

## Skalierungssteuerung

```python

# Adapterstärke einstellen
pipe.set_ip_adapter_scale(0.6)  # 0.0 bis 1.0

# Niedrige Skalierung = mehr Einfluss des Text-Prompts

# Hohe Skalierung = mehr Einfluss des Bild-Prompts

# Pro-Bild-Skalierung bei mehreren Bildern
pipe.set_ip_adapter_scale([0.7, 0.3])
```

## Mit ControlNet

```python
from diffusers import (
    AutoPipelineForText2Image,
    ControlNetModel
)
from diffusers.utils import load_image
import torch

# ControlNet laden
controlnet = ControlNetModel.from_pretrained(
    "lllyasviel/control_v11p_sd15_canny",
    torch_dtype=torch.float16
)

pipe = AutoPipelineForText2Image.from_pretrained(
    "runwayml/stable-diffusion-v1-5",
    controlnet=controlnet,
    torch_dtype=torch.float16
).to("cuda")

# IP-Adapter laden
pipe.load_ip_adapter(
    "h94/IP-Adapter",
    subfolder="models",
    weight_name="ip-adapter_sd15.bin"
)

# Stilbild
style_image = load_image("style.jpg")

# Kontrollbild (Kantenkarte)
control_image = load_image("edges.png")

image = pipe(
    prompt="detaillierte Illustration",
    image=control_image,
    ip_adapter_image=style_image,
    num_inference_steps=30
).images[0]
```

## Gradio-Oberfläche

```python
import gradio as gr
import torch
from diffusers import AutoPipelineForText2Image
from diffusers.utils import load_image

pipe = AutoPipelineForText2Image.from_pretrained(
    "stabilityai/stable-diffusion-xl-base-1.0",
    torch_dtype=torch.float16
).to("cuda")

pipe.load_ip_adapter(
    "h94/IP-Adapter",
    subfolder="sdxl_models",
    weight_name="ip-adapter_sdxl.bin"
)

def generate(reference_image, prompt, negative_prompt, scale, steps):
    pipe.set_ip_adapter_scale(scale)

    image = pipe(
        prompt=prompt,
        negative_prompt=negative_prompt,
        ip_adapter_image=reference_image,
        num_inference_steps=steps
    ).images[0]

    return image

demo = gr.Interface(
    fn=generate,
    inputs=[
        gr.Image(type="pil", label="Referenzbild"),
        gr.Textbox(label="Prompt", value="hohe Qualität"),
        gr.Textbox(label="Negativer Prompt", value="hässlich, verschwommen"),
        gr.Slider(0.0, 1.0, value=0.6, label="IP-Adapter-Skala"),
        gr.Slider(10, 50, value=30, step=1, label="Schritte")
    ],
    outputs=gr.Image(label="Erzeugtes Bild"),
    title="IP-Adapter Bild-Prompting"
)

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

## Batch-Stilübertragung

```python
from diffusers import AutoPipelineForText2Image
from diffusers.utils import load_image
import torch
import os

pipe = AutoPipelineForText2Image.from_pretrained(
    "stabilityai/stable-diffusion-xl-base-1.0",
    torch_dtype=torch.float16
).to("cuda")

pipe.load_ip_adapter(
    "h94/IP-Adapter",
    subfolder="sdxl_models",
    weight_name="ip-adapter_sdxl.bin"
)

# Stilreferenz
style_image = load_image("art_style.jpg")

# Zu generierende Motive
subjects = [
    "eine Berglandschaft",
    "eine Stadt bei Nacht",
    "ein Wald im Herbst",
    "ein Sonnenuntergang am Meer",
    "ein verschneites Dorf"
]

output_dir = "./styled_outputs"
os.makedirs(output_dir, exist_ok=True)

for i, subject in enumerate(subjects):
    print(f"Generiere {i+1}/{len(subjects)}: {subject}")

    image = pipe(
        prompt=subject,
        ip_adapter_image=style_image,
        num_inference_steps=30
    ).images[0]

    image.save(f"{output_dir}/styled_{i:03d}.png")
```

## Anwendungsfälle

### Produktfotografie-Stil

```python

# Referenz: professionelles Produktfoto
style = load_image("product_photo_reference.jpg")

image = pipe(
    prompt="rote Turnschuhe auf weißem Hintergrund",
    ip_adapter_image=style,
    num_inference_steps=30
).images[0]
```

### Künstlerische Stilübertragung

```python

# Referenz: berühmtes Gemälde
style = load_image("monet_painting.jpg")

image = pipe(
    prompt="Porträt einer Frau in einem Garten",
    ip_adapter_image=style,
    num_inference_steps=30
).images[0]
```

### Markenkonsistenz

```python

# Referenz: Bild aus dem Markenstil-Guide
style = load_image("brand_style.jpg")

prompts = [
    "Website-Hero-Banner",
    "Social-Media-Beitrag",
    "E-Mail-Newsletter-Kopfzeile"
]

for prompt in prompts:
    image = pipe(prompt=prompt, ip_adapter_image=style).images[0]
```

## Speicheroptimierung

```python
pipe.enable_model_cpu_offload()
pipe.enable_vae_slicing()

# Für sehr begrenzten VRAM
pipe.enable_sequential_cpu_offload()
```

## Leistung

| Modell                 | GPU      | Zeit  |
| ---------------------- | -------- | ----- |
| SD 1.5 + IP-Adapter    | RTX 3090 | \~5s  |
| SDXL + IP-Adapter      | RTX 3090 | \~12s |
| SDXL + IP-Adapter      | RTX 4090 | \~8s  |
| SDXL + IP-Adapter-Plus | RTX 4090 | \~10s |

## Fehlerbehebung

### Stil nicht angewendet

* Erhöhen Sie ip\_adapter\_scale
* Verwenden Sie ein klareres Referenzbild
* Stellen Sie sicher, dass der Adapter korrekt geladen ist

### Zu starker Einfluss der Referenz

* Verringern Sie ip\_adapter\_scale
* Spezifischeres Text-Prompt
* Erhöhe guidance\_scale

### Speicherprobleme

* CPU-Offload aktivieren
* Verwenden Sie SD 1.5 statt SDXL
* 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

* [InstantID](/guides/guides_v2-de/gesicht-and-identitat/instantid.md) - Gesichtsidentität
* [ControlNet](/guides/guides_v2-de/bildverarbeitung/controlnet-advanced.md) - Strukturkontrolle
* Stable Diffusion WebUI - IP-Adapter Erweiterung


---

# 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/gesicht-and-identitat/ip-adapter.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.
