Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -11,7 +11,7 @@ def analyze_image_with_maira(image):
|
|
11 |
"""Analyzes the image using the Maira-2 model via the Hugging Face Inference API.
|
12 |
"""
|
13 |
try:
|
14 |
-
# Prepare image data -
|
15 |
image_bytes = io.BytesIO()
|
16 |
if image.mode == "RGBA": # Handle RGBA images (if any)
|
17 |
image = image.convert("RGB")
|
@@ -19,11 +19,15 @@ def analyze_image_with_maira(image):
|
|
19 |
image_bytes = image_bytes.getvalue() # Get the bytes
|
20 |
|
21 |
client = InferenceClient() # No token needed inside the Space
|
22 |
-
result = client.
|
23 |
-
|
24 |
-
|
25 |
-
|
|
|
|
|
|
|
26 |
)
|
|
|
27 |
return result
|
28 |
|
29 |
except Exception as e:
|
|
|
11 |
"""Analyzes the image using the Maira-2 model via the Hugging Face Inference API.
|
12 |
"""
|
13 |
try:
|
14 |
+
# Prepare image data - send as bytes directly to 'inputs'
|
15 |
image_bytes = io.BytesIO()
|
16 |
if image.mode == "RGBA": # Handle RGBA images (if any)
|
17 |
image = image.convert("RGB")
|
|
|
19 |
image_bytes = image_bytes.getvalue() # Get the bytes
|
20 |
|
21 |
client = InferenceClient() # No token needed inside the Space
|
22 |
+
result = client.run(
|
23 |
+
task="visual-question-answering", # Explicitly specify the task
|
24 |
+
model="microsoft/maira-2", # Specify the model
|
25 |
+
inputs={
|
26 |
+
"image": image_bytes,
|
27 |
+
"question": "Analyze this chest X-ray image and provide detailed findings. Include any abnormalities, their locations, and potential diagnoses. Be as specific as possible.",
|
28 |
+
}
|
29 |
)
|
30 |
+
|
31 |
return result
|
32 |
|
33 |
except Exception as e:
|