> 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-hi/vision-models/llama-vision.md).

# Llama 3.2 Vision

Clore.ai पर इमेज समझने के लिए Meta का Llama 3.2 Vision चलाएँ

छवि समझ के लिए CLORE.AI GPUs पर Meta के मल्टीमोडल Llama 3.2 Vision मॉडल चलाएँ।

{% hint style="success" %}
सभी उदाहरण GPU सर्वरों पर चलाए जा सकते हैं, जिन्हें किराए पर लिया गया है [CLORE.AI मार्केटप्लेस](https://clore.ai/marketplace).
{% endhint %}

## Llama 3.2 Vision क्यों?

* **मल्टीमोडल** - टेक्स्ट और छवियों दोनों को समझता है
* **कई आकार** - 11B और 90B पैरामीटर संस्करण
* **बहुउपयोगी** - OCR, विज़ुअल QA, छवि कैप्शनिंग, दस्तावेज़ विश्लेषण
* **ओपन वेट्स** - Meta का पूर्णतः ओपन सोर्स
* **Llama इकोसिस्टम** - Ollama, vLLM, transformers के साथ संगत

## मॉडल वेरिएंट

| मॉडल                          | पैरामीटर | VRAM (FP16) | संदर्भ | किसके लिए सर्वोत्तम    |
| ----------------------------- | -------- | ----------- | ------ | ---------------------- |
| Llama-3.2-11B-Vision          | 11B      | 24GB        | 128K   | सामान्य उपयोग, एकल GPU |
| Llama-3.2-90B-Vision          | 90B      | 180GB       | 128K   | अधिकतम गुणवत्ता        |
| Llama-3.2-11B-Vision-Instruct | 11B      | 24GB        | 128K   | चैट/सहायक              |
| Llama-3.2-90B-Vision-Instruct | 90B      | 180GB       | 128K   | प्रोडक्शन              |

## CLORE.AI पर त्वरित परिनियोजन

**Docker इमेज:**

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

**पोर्ट:**

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

**कमांड:**

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

## अपनी सेवा तक पहुँचना

डिप्लॉयमेंट के बाद, अपना `http_pub` URL यहाँ **मेरे ऑर्डर**:

1. पर जाएँ **मेरे ऑर्डर** पेज
2. अपने ऑर्डर पर क्लिक करें
3. खोजें `http_pub` URL (उदा., `abc123.clorecloud.net`)

उपयोग करें `https://YOUR_HTTP_PUB_URL` की बजाय `localhost` नीचे दिए गए उदाहरणों में।

## हार्डवेयर आवश्यकताएँ

{% hint style="warning" %}
**Clore.ai marketplace पर multi-GPU 80GB-class rigs सूचीबद्ध नहीं हैं।** आज सूचीबद्ध सबसे बड़े boxes 4× RTX PRO 6000 Blackwell (प्रत्येक 96GB, कुल 380GB) और 8–11× RTX 5090 (प्रत्येक 32GB) हैं। A100 / H200 / B200 क्षमता [bare metal](https://clore.ai/bare-metal) के रूप में अनुरोध पर बेची जाती है। देखें [GPU मूल्य और उपलब्धता](/guides/guides_v2-hi/getting-started/pricing.md) किसी deployment का आकार तय करने से पहले।
{% endhint %}

| मॉडल      | न्यूनतम GPU   | अनुशंसित     | इष्टतम    |
| --------- | ------------- | ------------ | --------- |
| 11B विज़न | RTX 4090 24GB | A100 40GB    | A100 80GB |
| 90B विज़न | 4x A100 40GB  | 4x A100 80GB | 8x H100   |

## इंस्टॉलेशन

### Ollama का उपयोग करके (सबसे आसान)

```bash
# मॉडल डाउनलोड करें
ollama pull llama3.2-vision:11b

# इंटरैक्टिव रूप से चलाएँ
ollama run llama3.2-vision:11b
```

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

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

## मूल उपयोग

### छवि समझ

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

# छवि लोड करें
url = "https://example.com/image.jpg"
image = Image.open(requests.get(url, stream=True).raw)

# प्रॉम्प्ट बनाएँ
messages = [
    {
        "role": "user",
        "content": [
            {"type": "image"},
            {"type": "text", "text": "इस छवि में क्या है? विस्तार से वर्णन करें."}
        ]
    }
]

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

### Ollama के साथ

```bash
# छवि का वर्णन करें
ollama run llama3.2-vision:11b "इस छवि का वर्णन करें: /path/to/image.jpg"

# या API का उपयोग करें
curl http://localhost:11434/api/generate -d '{
  "model": "llama3.2-vision:11b",
  "prompt": "इस छवि में क्या है?",
  "images": ["base64_encoded_image_here"]
}'
```

### vLLM API के साथ

```python
from openai import OpenAI
import base64

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

# छवि को base64 में एन्कोड करें
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": "इस छवि में क्या है?"},
                {
                    "type": "image_url",
                    "image_url": {"url": f"data:image/jpeg;base64,{image_base64}"}
                }
            ]
        }
    ],
    max_tokens=500
)

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

## उपयोग के मामले

### OCR / पाठ निष्कर्षण

```python
messages = [
    {
        "role": "user",
        "content": [
            {"type": "image"},
            {"type": "text", "text": "इस छवि से सभी पाठ निकालें। Markdown के रूप में स्वरूपित करें."}
        ]
    }
]
```

### दस्तावेज़ विश्लेषण

```python
messages = [
    {
        "role": "user",
        "content": [
            {"type": "image"},
            {"type": "text", "text": "इस दस्तावेज़ का विश्लेषण करें। मुख्य बिंदुओं का सारांश दें."}
        ]
    }
]
```

### विज़ुअल प्रश्नोत्तर

```python
messages = [
    {
        "role": "user",
        "content": [
            {"type": "image"},
            {"type": "text", "text": "इस फोटो में कितने लोग हैं? वे क्या कर रहे हैं?"}
        ]
    }
]
```

### छवि कैप्शनिंग

```python
messages = [
    {
        "role": "user",
        "content": [
            {"type": "image"},
            {"type": "text", "text": "इस छवि के लिए सोशल मीडिया हेतु उपयुक्त एक विस्तृत कैप्शन लिखें."}
        ]
    }
]
```

### स्क्रीनशॉट से कोड

```python
messages = [
    {
        "role": "user",
        "content": [
            {"type": "image"},
            {"type": "text", "text": "इस UI स्क्रीनशॉट को HTML/CSS कोड में बदलें."}
        ]
    }
]
```

## एकाधिक छवियाँ

```python
messages = [
    {
        "role": "user",
        "content": [
            {"type": "image"},
            {"type": "image"},
            {"type": "text", "text": "इन दो छवियों की तुलना करें। अंतर क्या हैं?"}
        ]
    }
]

# एकाधिक छवियों के साथ प्रक्रिया करें
inputs = processor(
    images=[image1, image2],
    text=input_text,
    return_tensors="pt"
).to(model.device)
```

## बैच प्रोसेसिंग

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

        # छवियों के बीच कैश साफ़ करें
        torch.cuda.empty_cache()

    return results

# फ़ोल्डर संसाधित करें
images = [f"./images/{f}" for f in os.listdir("./images") if f.endswith(('.jpg', '.png'))]
results = process_images(images, "इस छवि का एक पैराग्राफ में वर्णन करें.")
```

## Gradio इंटरफ़ेस

```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="छवि अपलोड करें"),
        gr.Textbox(label="प्रश्न", placeholder="इस छवि में क्या है?")
    ],
    outputs=gr.Textbox(label="प्रतिक्रिया"),
    title="Llama 3.2 Vision - छवि विश्लेषण",
    description="एक छवि अपलोड करें और उसके बारे में प्रश्न पूछें। CLORE.AI पर चल रहा है."
)

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

## प्रदर्शन

| कार्य              | मॉडल | GPU       | समय        |
| ------------------ | ---- | --------- | ---------- |
| एकल छवि विवरण      | 11B  | RTX 4090  | \~3s       |
| एकल छवि विवरण      | 11B  | A100 40GB | \~2s       |
| OCR (1 पृष्ठ)      | 11B  | RTX 4090  | \~5 सेकंड  |
| दस्तावेज़ विश्लेषण | 11B  | A100 40GB | \~8s       |
| बैच (10 छवियाँ)    | 11B  | A100 40GB | \~25 सेकंड |

## क्वांटाइज़ेशन

### bitsandbytes के साथ 4-बिट

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

### Ollama के साथ GGUF

```bash
# 4-बिट क्वांटाइज़्ड (8GB VRAM में फिट होता है)
ollama pull llama3.2-vision:11b-q4_K_M

# 8-बिट क्वांटाइज़्ड
ollama pull llama3.2-vision:11b-q8_0
```

## लागत का अनुमान

CLORE.AI मार्केटप्लेस की सामान्य दरें:

| GPU           | प्रति घंटा दर | किसके लिए सर्वोत्तम    |
| ------------- | ------------- | ---------------------- |
| RTX 4090 24GB | \~$0.10       | 11B मॉडल               |
| A100 40GB     | \~$0.17       | लंबे संदर्भ के साथ 11B |
| A100 80GB     | \~$0.25       | 11B सर्वोत्तम          |
| 4x A100 80GB  | \~$1.00       | 90B मॉडल               |

*कीमतें अलग-अलग होती हैं। देखें* [*CLORE.AI मार्केटप्लेस*](https://clore.ai/marketplace) *वर्तमान दरों के लिए।*

**पैसे बचाएँ:**

* उपयोग करें **स्पॉट** बैच प्रोसेसिंग के लिए आदेश
* से भुगतान करें **CLORE** टोकन
* विकास के लिए क्वांटाइज़्ड मॉडल (4-बिट) का उपयोग करें

## समस्या निवारण

### मेमोरी समाप्त

```python
# 4-बिट क्वांटाइज़ेशन का उपयोग करें
model = MllamaForConditionalGeneration.from_pretrained(
    model_id,
    load_in_4bit=True,
    device_map="auto"
)

# या max_new_tokens कम करें
output = model.generate(**inputs, max_new_tokens=256)
```

### धीमी जनरेशन

* सुनिश्चित करें कि GPU का उपयोग हो रहा है (जांचें `nvidia-smi`)
* float32 के बजाय bfloat16 का उपयोग करें
* प्रसंस्करण से पहले छवि का रिज़ॉल्यूशन कम करें
* बेहतर थ्रूपुट के लिए vLLM का उपयोग करें

### छवि लोड नहीं हो रही

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

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

# फ़ाइल से
image = Image.open("path/to/image.jpg").convert("RGB")

# यदि बहुत बड़ी हो तो आकार बदलें
max_size = 1024
if max(image.size) > max_size:
    image.thumbnail((max_size, max_size))
```

### HuggingFace टोकन आवश्यक

```bash
# सीमित पहुँच वाले मॉडलों के लिए टोकन सेट करें
export HUGGING_FACE_HUB_TOKEN=hf_xxxxx

# या लॉगिन करें
huggingface-cli login
```

## Llama Vision बनाम अन्य

| विशेषता      | Llama 3.2 Vision | LLaVA 1.6  | GPT-4V        |
| ------------ | ---------------- | ---------- | ------------- |
| पैरामीटर     | 11B / 90B        | 7B / 34B   | अज्ञात        |
| ओपन सोर्स    | हाँ              | हाँ        | नहीं          |
| OCR गुणवत्ता | उत्कृष्ट         | अच्छा      | उत्कृष्ट      |
| संदर्भ       | 128K             | 32K        | 128K          |
| बहु-छवि      | हाँ              | सीमित      | हाँ           |
| लाइसेंस      | Llama 3.2        | Apache 2.0 | स्वामित्वाधीन |

**Llama 3.2 Vision का उपयोग करें जब:**

* ओपन-सोर्स मल्टीमोडल की आवश्यकता हो
* OCR और दस्तावेज़ विश्लेषण
* Llama इकोसिस्टम के साथ एकीकरण
* लंबे संदर्भ की समझ

## अगले चरण

* [LLaVA](/guides/guides_v2-hi/vision-models/llava-vision-language.md) - वैकल्पिक विज़न मॉडल
* [Florence-2](/guides/guides_v2-hi/vision-models/florence2.md) - Microsoft का विज़न मॉडल
* [Ollama](/guides/guides_v2-hi/language-models/ollama.md) - आसान परिनियोजन
* [vLLM](/guides/guides_v2-hi/language-models/vllm.md) - उत्पादन सर्विंग


---

# 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-hi/vision-models/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.
