ollama-python/examples/multimodal-chat.py
Parth Sareen fe91357d4b
Some checks failed
test / test (push) Has been cancelled
test / lint (push) Has been cancelled
examples: update to use gemma3 (#543)
2025-07-22 16:27:16 -07:00

25 lines
500 B
Python

from ollama import chat
# from pathlib import Path
# Pass in the path to the image
path = input('Please enter the path to the image: ')
# You can also pass in base64 encoded image data
# img = base64.b64encode(Path(path).read_bytes()).decode()
# or the raw bytes
# img = Path(path).read_bytes()
response = chat(
model='gemma3',
messages=[
{
'role': 'user',
'content': 'What is in this image? Be concise.',
'images': [path],
}
],
)
print(response.message.content)