mirror of
https://github.com/ollama/ollama-python.git
synced 2026-01-14 06:07:17 +08:00
* Examples and README updates --------- Co-authored-by: fujitatomoya <tomoya.fujita825@gmail.com> Co-authored-by: Michael Yang <mxyng@pm.me>
24 lines
508 B
Python
24 lines
508 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='llama3.2-vision',
|
|
messages=[
|
|
{
|
|
'role': 'user',
|
|
'content': 'What is in this image? Be concise.',
|
|
'images': [path],
|
|
}
|
|
],
|
|
)
|
|
|
|
print(response.message.content)
|