Skip to content

Görüş modelleri, metin ile birlikte görüntüleri kabul eder, böylece model gördüğü şeyleri tanımlayabilir, sınıflandırabilir ve bu konulardaki soruları yanıtlayabilir.

Hızlı Başlangıç

shell
ollama run gemma4 ./image.png whats in this image?

Ollama API'si ile Kullanım

Bir images dizisi sağlayın. SDK'lar dosya yolları, URL'ler veya ham baytları kabul ederken, REST API'si base64 ile kodlanmış görüntü verisi bekler.

cURL

```shell
# 1. Örnek bir görüntüyü indir
curl -L -o test.jpg "https://upload.wikimedia.org/wikipedia/commons/3/3a/Cat03.jpg"

# 2. Görüntüyü kodla
IMG=$(base64 < test.jpg | tr -d '\n')

# 3. Ollama'ya gönder
curl -X POST http://localhost:11434/api/chat \
-H "Content-Type: application/json" \
-d '{
    "model": "gemma4",
    "messages": [{
    "role": "user",
    "content": "What is in this image?",
    "images": ["'"$IMG"'"]
    }],
    "stream": false
}'
```

Python

```python
from ollama import chat
# from pathlib import Path

# Görüntünün dosya yolunu girin
path = input('Please enter the path to the image: ')

# Ayrıca base64 ile kodlanmış görüntü verisi de gönderebilirsiniz
# img = base64.b64encode(Path(path).read_bytes()).decode()
# veya ham baytları
# img = Path(path).read_bytes()

response = chat(
  model='gemma4',
  messages=[
    {
      'role': 'user',
      'content': 'What is in this image? Be concise.',
      'images': [path],
    }
  ],
)

print(response.message.content)
```

JavaScript

```javascript
import ollama from 'ollama'

const imagePath = '/absolute/path/to/image.jpg'
const response = await ollama.chat({
  model: 'gemma4',
  messages: [
    { role: 'user', content: 'What is in this image?', images: [imagePath] }
  ],
  stream: false,
})

console.log(response.message.content)
```