> 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

Verwende Bilder als Prompts für Stable Diffusion mit 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 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 IP-Adapter?

IP-Adapter ermöglicht Bild-Prompting:

* Verwenden Sie Referenzbilder, um die Generierung zu steuern
* Mit Text-Prompts kombinieren
* Stilübertragung und Inhaltsübertragung
* Funktioniert mit SD 1.5 und SDXL

## Adapter-Typen

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

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

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

## Stilübertragung

```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. ein Van-Gogh-Gemälde)
style_image = load_image("van_gogh_starry_night.jpg")

# Neuen Inhalt in diesem Stil generieren
image = pipe(
    prompt="eine moderne Skyline einer Stadt",
    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 gesichtsorientierte 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")

# Gesichts-spezifischen 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 erzeugen
image = pipe(
    prompt="Porträtgemälde, Öl auf Leinwand, Museumsqualität",
    ip_adapter_image=face_image,
    num_inference_steps=30
).images[0]

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

## Mehrere Bilder kombinieren

```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 Stile mischen generieren
image = pipe(
    prompt="Landschaftsgemälde",
    ip_adapter_image=images,
    num_inference_steps=30
).images[0]
```

## Skalierungssteuerung

```python

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

# Niedrige Skala = stärkere Wirkung des Text-Prompts

# Hohe Skala = stärkere Wirkung des Bild-Prompts

# Skalierung pro Bild 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="Generiertes 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 über dem Ozean",
    "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 Sneaker 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 Brand-Styleguide
style = load_image("brand_style.jpg")

prompts = [
    "Hero-Banner für die Website",
    "Social-Media-Post",
    "Kopfzeile des E-Mail-Newsletters"
]

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 | \~5 s  |
| SDXL + IP-Adapter      | RTX 3090 | \~12 s |
| SDXL + IP-Adapter      | RTX 4090 | \~8s   |
| SDXL + IP-Adapter-Plus | RTX 4090 | \~10 s |

## Fehlerbehebung

### Stil nicht angewendet

* ip\_adapter\_scale erhöhen
* Ein klareres Referenzbild verwenden
* Sicherstellen, dass der Adapter korrekt geladen ist

### Zu starke Referenzeinflussnahme

* ip\_adapter\_scale verringern
* Spezifischere Text-Prompt
* guidance\_scale erhöhen

### Speicherprobleme

* CPU-Offload aktivieren
* SD 1.5 anstelle von SDXL verwenden
* 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

* [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, and the optional `goal` query parameter:

```
GET https://docs.clore.ai/guides/guides_v2-de/gesicht-and-identitat/ip-adapter.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.
