Views
No views yet
from_pretrained()1from transformers import AutoProcessor, AutoModelForImageTextToText
2import torch
3
4processor = AutoProcessor.from_pretrained("Prarabdha/pixtral-12b-240910-hf")
5model = AutoModelForImageTextToText.from_pretrained("Prarabdha/pixtral-12b-240910-hf", torch_dtype=torch.float16, device_map="auto")1from PIL import Image
2import requests
3
4# Load an image
5url = "https://example.com/sample-image.jpg"
6image = Image.open(requests.get(url, stream=True).raw)
7
8# Prepare conversation
9conversation = [
10 {
11 "role": "user",
12 "content": [
13 {"type": "image"},
14 {"type": "text", "text": "What is shown in this image?"},
15 ],
16 }
17]
18
19# Process and generate
20prompt = processor.apply_chat_template(conversation, add_generation_prompt=True)
21inputs = processor(images=[image], text=prompt, return_tensors="pt")
22generate_ids = model.generate(**inputs, max_new_tokens=30)
23response = processor.batch_decode(generate_ids, skip_special_tokens=True)| Benchmark | Pixtral 12B | Qwen2 7B VL | LLaVA-OV 7B | Phi-3 Vision |
|---|---|---|---|---|
| MMMU (CoT) | 52.5 | 47.6 | 45.1 | 40.3 |
| Mathvista (CoT) | 58.0 | 54.4 | 36.1 | 36.4 |
| ChartQA (CoT) | 81.8 | 38.6 | 67.1 | 72.0 |