Spaces:
Sleeping
Sleeping
File size: 999 Bytes
f0ba130 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
import base64
from groq import Groq
model = "meta-llama/llama-4-scout-17b-16e-instruct"
query = "What is the diagnosis of this image?"
# query = "What is the diagnosis of this image? Please provide a detailed explanation of the findings and any relevant differential diagnoses."
def encode_image_to_base64(image_path):
with open(image_path, "rb") as image_file:
return base64.b64encode(image_file.read()).decode("utf-8")
def analyze_image_with_query(query, model, encoded_image):
client = Groq()
messages = [
{
"role": "user",
"content": [
{"type": "text", "text": query},
{
"type": "image_url",
"image_url": {"url": f"data:image/jpeg;base64,{encoded_image}"}
},
],
}
]
chat_completion = client.chat.completions.create(
messages=messages,
model=model
)
return chat_completion.choices[0].message.content
|