> 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/computer-vision-modelle/llama-vision.md).

# Llama 3.2 Vision

Führe Metas Llama 3.2 Vision für Bildverständnis auf Clore.ai aus

Führen Sie Metas multimodale Llama-3.2-Vision-Modelle für das Bildverständnis auf CLORE.AI-GPUs aus.

{% 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 %}

## Warum Llama 3.2 Vision?

* **Multimodal** - Versteht sowohl Text als auch Bilder
* **Mehrere Größen** - 11B- und 90B-Parameterversionen
* **Vielseitig** - OCR, visuelle Fragenbeantwortung, Bildbeschreibung, Dokumentenanalyse
* **Offene Gewichte** - Vollständig Open Source von Meta
* **Llama-Ökosystem** - Kompatibel mit Ollama, vLLM, Transformers

## Modellvarianten

| Modell                        | Parameter | VRAM (FP16) | Kontext | Am besten geeignet für            |
| ----------------------------- | --------- | ----------- | ------- | --------------------------------- |
| Llama-3.2-11B-Vision          | 11B       | 24 GB       | 128K    | Allgemeiner Einsatz, einzelne GPU |
| Llama-3.2-90B-Vision          | 90B       | 180GB       | 128K    | Maximale Qualität                 |
| Llama-3.2-11B-Vision-Instruct | 11B       | 24 GB       | 128K    | Chat/Assistent                    |
| Llama-3.2-90B-Vision-Instruct | 90B       | 180GB       | 128K    | Produktion                        |

## Schnellbereitstellung auf CLORE.AI

**Docker-Image:**

```
vllm/vllm-openai:latest
```

**Ports:**

```
22/tcp
8000/http
```

**Befehl:**

```bash
python -m vllm.entrypoints.openai.api_server \
    --model meta-llama/Llama-3.2-11B-Vision-Instruct \\
    --host 0.0.0.0 \
    --port 8000 \\
    --max-model-len 8192
```

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

## Hardware-Anforderungen

{% hint style="warning" %}
**Multi-GPU-Rigs der 80GB-Klasse sind auf dem Clore.ai-Marktplatz nicht gelistet.** Die größten heute gelisteten Systeme sind 4× RTX PRO 6000 Blackwell (je 96 GB, 380 GB gesamt) und 8–11× RTX 5090 (je 32 GB). Kapazitäten für A100 / H200 / B200 werden als [Bare Metal](https://clore.ai/bare-metal) auf Anfrage verkauft. Prüfe [GPU-Preise & Verfügbarkeit](/guides/guides_v2-de/erste-schritte/pricing.md) bevor du eine Bereitstellung dimensionierst.
{% endhint %}

| Modell     | Minimale GPU  | Empfohlen     | Optimal   |
| ---------- | ------------- | ------------- | --------- |
| 11B Vision | RTX 4090 24GB | A100 40GB     | A100 80GB |
| 90B Vision | 4x A100 40 GB | 4x A100 80 GB | 8x H100   |

## Installation

### Mit Ollama (am einfachsten)

```bash
# Modell abrufen
ollama pull llama3.2-vision:11b

# Interaktiv ausführen
ollama run llama3.2-vision:11b
```

### Mit vLLM

```bash
pip install vllm

python -m vllm.entrypoints.openai.api_server \
    --model meta-llama/Llama-3.2-11B-Vision-Instruct \\
    --host 0.0.0.0 \
    --port 8000
```

### Mit Transformers

```python
import torch
from transformers import MllamaForConditionalGeneration, AutoProcessor

model_id = "meta-llama/Llama-3.2-11B-Vision-Instruct"

model = MllamaForConditionalGeneration.from_pretrained(
    model_id,
    torch_dtype=torch.bfloat16,
    device_map="auto"
)
processor = AutoProcessor.from_pretrained(model_id)
```

## Grundlegende Verwendung

### Bildverständnis

```python
import torch
from transformers import MllamaForConditionalGeneration, AutoProcessor
from PIL import Image
import requests

model_id = "meta-llama/Llama-3.2-11B-Vision-Instruct"

model = MllamaForConditionalGeneration.from_pretrained(
    model_id,
    torch_dtype=torch.bfloat16,
    device_map="auto"
)
processor = AutoProcessor.from_pretrained(model_id)

# Bild laden
url = "https://example.com/image.jpg"
image = Image.open(requests.get(url, stream=True).raw)

# Prompt erstellen
messages = [
    {
        "role": "user",
        "content": [
            {"type": "image"},
            {"type": "text", "text": "Was ist auf diesem Bild? Beschreibe es ausführlich."}
        ]
    }
]

input_text = processor.apply_chat_template(messages, add_generation_prompt=True)
inputs = processor(image, input_text, return_tensors="pt").to(model.device)

output = model.generate(**inputs, max_new_tokens=500)
print(processor.decode(output[0], skip_special_tokens=True))
```

### Mit Ollama

```bash
# Bild beschreiben
ollama run llama3.2-vision:11b "Beschreibe dieses Bild: /path/to/image.jpg"

# Oder die API verwenden
curl http://localhost:11434/api/generate -d '{
  "model": "llama3.2-vision:11b",
  "prompt": "Was ist auf diesem Bild?",
  "images": ["base64_encoded_image_here"]
}'
```

### Mit vLLM-API

```python
from openai import OpenAI
import base64

client = OpenAI(
    base_url="http://localhost:8000/v1",
    api_key="not-needed"
)

# Bild in Base64 kodieren
with open("image.jpg", "rb") as f:
    image_base64 = base64.b64encode(f.read()).decode()

response = client.chat.completions.create(
    model="meta-llama/Llama-3.2-11B-Vision-Instruct",
    messages=[
        {
            "role": "user",
            "content": [
                {"type": "text", "text": "Was ist auf diesem Bild?"},
                {
                    "type": "image_url",
                    "image_url": {"url": f"data:image/jpeg;base64,{image_base64}"}
                }
            ]
        }
    ],
    max_tokens=500
)

print(response.choices[0].message.content)
```

## Anwendungsfälle

### OCR / Textextraktion

```python
messages = [
    {
        "role": "user",
        "content": [
            {"type": "image"},
            {"type": "text", "text": "Extrahiere den gesamten Text aus diesem Bild. Formatiere als Markdown."}
        ]
    }
]
```

### Dokumentenanalyse

```python
messages = [
    {
        "role": "user",
        "content": [
            {"type": "image"},
            {"type": "text", "text": "Analysiere dieses Dokument. Fasse die wichtigsten Punkte zusammen."}
        ]
    }
]
```

### Visuelle Fragenbeantwortung

```python
messages = [
    {
        "role": "user",
        "content": [
            {"type": "image"},
            {"type": "text", "text": "Wie viele Personen sind auf diesem Foto? Was machen sie?"}
        ]
    }
]
```

### Bildbeschriftung

```python
messages = [
    {
        "role": "user",
        "content": [
            {"type": "image"},
            {"type": "text", "text": "Schreibe eine detaillierte Bildunterschrift für dieses Bild, geeignet für soziale Medien."}
        ]
    }
]
```

### Code aus Screenshots

```python
messages = [
    {
        "role": "user",
        "content": [
            {"type": "image"},
            {"type": "text", "text": "Konvertiere diesen UI-Screenshot in HTML/CSS-Code."}
        ]
    }
]
```

## Mehrere Bilder

```python
messages = [
    {
        "role": "user",
        "content": [
            {"type": "image"},
            {"type": "image"},
            {"type": "text", "text": "Vergleiche diese beiden Bilder. Was sind die Unterschiede?"}
        ]
    }
]

# Mehrere Bilder verarbeiten
inputs = processor(
    images=[image1, image2],
    text=input_text,
    return_tensors="pt"
).to(model.device)
```

## Batch-Verarbeitung

```python
import os
from PIL import Image

def process_images(image_paths, prompt):
    results = []

    for path in image_paths:
        image = Image.open(path)

        messages = [
            {
                "role": "user",
                "content": [
                    {"type": "image"},
                    {"type": "text", "text": prompt}
                ]
            }
        ]

        input_text = processor.apply_chat_template(messages, add_generation_prompt=True)
        inputs = processor(image, input_text, return_tensors="pt").to(model.device)

        output = model.generate(**inputs, max_new_tokens=300)
        result = processor.decode(output[0], skip_special_tokens=True)

        results.append({"file": path, "description": result})

        # Cache zwischen Bildern leeren
        torch.cuda.empty_cache()

    return results

# Ordner verarbeiten
images = [f"./images/{f}" for f in os.listdir("./images") if f.endswith(('.jpg', '.png'))]
results = process_images(images, "Beschreibe dieses Bild in einem Absatz.")
```

## Gradio-Oberfläche

```python
import gradio as gr
import torch
from transformers import MllamaForConditionalGeneration, AutoProcessor
from PIL import Image

model_id = "meta-llama/Llama-3.2-11B-Vision-Instruct"
model = MllamaForConditionalGeneration.from_pretrained(
    model_id, torch_dtype=torch.bfloat16, device_map="auto"
)
processor = AutoProcessor.from_pretrained(model_id)

def analyze_image(image, question):
    messages = [
        {
            "role": "user",
            "content": [
                {"type": "image"},
                {"type": "text", "text": question}
            ]
        }
    ]

    input_text = processor.apply_chat_template(messages, add_generation_prompt=True)
    inputs = processor(image, input_text, return_tensors="pt").to(model.device)

    output = model.generate(**inputs, max_new_tokens=500)
    return processor.decode(output[0], skip_special_tokens=True)

demo = gr.Interface(
    fn=analyze_image,
    inputs=[
        gr.Image(type="pil", label="Bild hochladen"),
        gr.Textbox(label="Frage", placeholder="Was ist auf diesem Bild?")
    ],
    outputs=gr.Textbox(label="Antwort"),
    title="Llama 3.2 Vision - Bildanalyse",
    description="Laden Sie ein Bild hoch und stellen Sie Fragen dazu. Läuft auf CLORE.AI."
)

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

## Leistung

| Aufgabe                             | Modell | GPU       | Zeit   |
| ----------------------------------- | ------ | --------- | ------ |
| Beschreibung eines einzelnen Bildes | 11B    | RTX 4090  | \~3s   |
| Beschreibung eines einzelnen Bildes | 11B    | A100 40GB | \~2s   |
| OCR (1 Seite)                       | 11B    | RTX 4090  | \~5 s  |
| Dokumentenanalyse                   | 11B    | A100 40GB | \~8s   |
| Batch (10 Bilder)                   | 11B    | A100 40GB | \~25 s |

## Quantisierung

### 4-Bit mit bitsandbytes

```python
from transformers import BitsAndBytesConfig

quantization_config = BitsAndBytesConfig(
    load_in_4bit=True,
    bnb_4bit_compute_dtype=torch.bfloat16
)

model = MllamaForConditionalGeneration.from_pretrained(
    model_id,
    quantization_config=quantization_config,
    device_map="auto"
)
```

### GGUF mit Ollama

```bash
# 4-Bit-quantisiert (passt in 8 GB VRAM)
ollama pull llama3.2-vision:11b-q4_K_M

# 8-Bit-quantisiert
ollama pull llama3.2-vision:11b-q8_0
```

## Kostenschätzung

Übliche CLORE.AI-Marktplatzpreise:

| GPU           | Stundensatz | Am besten geeignet für |
| ------------- | ----------- | ---------------------- |
| RTX 4090 24GB | \~$0.10     | 11B-Modell             |
| A100 40GB     | \~$0.17     | 11B mit langem Kontext |
| A100 80GB     | \~$0.25     | 11B optimal            |
| 4x A100 80 GB | \~$1.00     | 90B-Modell             |

*Preise variieren. Prüfe* [*CLORE.AI-Marktplatz*](https://clore.ai/marketplace) *für aktuelle Preise.*

**Geld sparen:**

* Verwende **Spot** Aufträge für die Batch-Verarbeitung
* Bezahlen Sie mit **CLORE** Tokens
* Verwenden Sie quantisierte Modelle (4-Bit) für die Entwicklung

## Fehlerbehebung

### Speicher erschöpft

```python
# 4-Bit-Quantisierung verwenden
model = MllamaForConditionalGeneration.from_pretrained(
    model_id,
    load_in_4bit=True,
    device_map="auto"
)

# Oder max_new_tokens reduzieren
output = model.generate(**inputs, max_new_tokens=256)
```

### Langsame Generierung

* Stellen Sie sicher, dass die GPU verwendet wird (prüfen `nvidia-smi`)
* Verwenden Sie bfloat16 statt float32
* Reduzieren Sie die Bildauflösung vor der Verarbeitung
* Verwenden Sie vLLM für besseren Durchsatz

### Bild wird nicht geladen

```python
from PIL import Image
import requests
from io import BytesIO

# Von URL
response = requests.get(url)
image = Image.open(BytesIO(response.content)).convert("RGB")

# Aus Datei
image = Image.open("path/to/image.jpg").convert("RGB")

# Falls zu groß, skalieren
max_size = 1024
if max(image.size) > max_size:
    image.thumbnail((max_size, max_size))
```

### HuggingFace-Token erforderlich

```bash
# Token für gesperrte Modelle festlegen
export HUGGING_FACE_HUB_TOKEN=hf_xxxxx

# Oder anmelden
huggingface-cli login
```

## Llama Vision vs. andere

| Funktion       | Llama 3.2 Vision | LLaVA 1.6  | GPT-4V       |
| -------------- | ---------------- | ---------- | ------------ |
| Parameter      | 11B / 90B        | 7B / 34B   | Unbekannt    |
| Open Source    | Ja               | Ja         | Nein         |
| OCR-Qualität   | Hervorragend     | Gut        | Hervorragend |
| Kontext        | 128K             | 32K        | 128K         |
| Mehrere Bilder | Ja               | Begrenzt   | Ja           |
| Lizenz         | Llama 3.2        | Apache 2.0 | Proprietär   |

**Verwenden Sie Llama 3.2 Vision, wenn:**

* Open-Source-Multimodalität benötigt
* OCR und Dokumentenanalyse
* Integration mit dem Llama-Ökosystem
* Verständnis langer Kontexte

## Nächste Schritte

* [LLaVA](/guides/guides_v2-de/computer-vision-modelle/llava-vision-language.md) - Alternatives Vision-Modell
* [Florence-2](/guides/guides_v2-de/computer-vision-modelle/florence2.md) - Microsofts Vision-Modell
* [Ollama](/guides/guides_v2-de/sprachmodelle/ollama.md) - Einfache Bereitstellung
* [vLLM](/guides/guides_v2-de/sprachmodelle/vllm.md) - Bereitstellung in der Produktion


---

# 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/computer-vision-modelle/llama-vision.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.
