Spaces:
Sleeping
Sleeping
| 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 | |