You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
def analyze_image(image_path):
# Encode image to base64
with open(image_path, "rb") as image_file:
base64_image = base64.b64encode(image_file.read()).decode("utf-8")
# Send request to GPT-4 Vision
response = client.chat.completions.create(
model="gpt-4o",
messages=[
{
"role": "user",
"content": [
{"type": "text", "text": "Analyze this image and describe it in Markdown format."},
{
"type": "image_url",
"image_url": f"data:image/jpeg;base64,{base64_image}",
},
],
}
],
max_tokens=1000,
)
return response.choices[0].message.content
Example usage
result = analyze_image("example.jpg")
print(result)
When run the code in the sample to convert an image to Markdown, an error occurs.
I submitted a related PR;
#861
I would appreciate it if you could respond.
The text was updated successfully, but these errors were encountered: