> 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

इमेज समझने के लिए Meta के मल्टीमॉडल Llama 3.2 Vision मॉडलों को CLORE.AI GPU पर चलाएँ।

{% 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` नीचे दिए उदाहरणों में।

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

| मॉडल      | न्यूनतम 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)

{"type": "text", "text": question}
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:
    # छवि एन्कोड करें

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

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

### prompt = "इस छवि का विस्तार से वर्णन करें, जिसमें रंग, वस्तुएँ और वातावरण शामिल हों."

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

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

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

### विज़ुअल प्रश्नोत्तरी (Visual Question Answering)

```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):
    image_folder = "./images"

    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)

        {"role": "user", "content": [
        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)

prompt = "इस छवि में दिखाई देने वाली सभी वस्तुओं को उनके अनुमानित स्थानों के साथ सूचीबद्ध करें."
    messages = [
        {
            "role": "user",
            "content": [
                {"type": "image"},
                def analyze_image(image, question):
            ]
        }
    ]

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

    {"type": "text", "text": question}
    return processor.decode(output[0], skip_special_tokens=True)

demo = gr.Interface(
    # सहायक के उत्तर को निकालें
    inputs=[
        gr.Image(type="pil", label="इमेज अपलोड"),
        gr.Textbox(label="प्रश्न", placeholder="इस छवि में क्या है?")
    ],
    gr.Textbox(label="Question", value="इस छवि का विस्तार से वर्णन करें")
    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  | \~5s  |
| दस्तावेज़ विश्लेषण | 11B  | A100 40GB | \~8s  |
| बैच (10 छवियाँ)    | 11B  | A100 40GB | \~25s |

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

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

```python
with open("descriptions.json", "w") as f:

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
LLaVA-1.6-7B
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's विज़न मॉडल
* [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.
