Skip to content

Instantly share code, notes, and snippets.

@jondurbin
Created March 25, 2025 10:13
Show Gist options
  • Save jondurbin/3a9ffe9ae613be2918ca5e1afaacc47a to your computer and use it in GitHub Desktop.
Save jondurbin/3a9ffe9ae613be2918ca5e1afaacc47a to your computer and use it in GitHub Desktop.
Qwen2.5-VL-32b-Instruct inference example
import os
import base64
import openai
import glob
client = openai.Client(base_url="https://llm.chutes.ai/v1", api_key=os.environ["CHUTES_API_KEY"])
image_base64s = []
for path in glob.glob("/home/jdurbin/Downloads/logo*.png")[:8]:
with open(path, "rb") as infile:
image_base64s.append(base64.b64encode(infile.read()).decode())
result = client.chat.completions.create(
model="Qwen/Qwen2.5-VL-32B-Instruct",
messages=[
{
"role": "user",
"content": [
{"type": "text", "text": "Describe each of the images."},
] + [
{
"type": "image_url",
"image_url": {"url": f"data:image/png;base64,{image_base64}"},
}
for image_base64 in image_base64s
],
}
],
temperature=0.0,
)
print(result.choices[0].message.content)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment