Spaces:
Sleeping
Sleeping
File size: 1,000 Bytes
f559cc0 | 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 33 34 35 36 37 | import requests, io, json
from PIL import Image
img = Image.new('RGB', (400, 300), color=(200, 160, 140))
buf = io.BytesIO()
img.save(buf, format='JPEG')
buf.seek(0)
symptoms = json.dumps({
"fatigue": True,
"pale_skin": True,
"dizziness": False,
"shortness_of_breath": False,
"heavy_menstrual_bleeding": None,
"poor_diet_low_iron": False
})
r = requests.post(
'http://localhost:8000/api/analyze',
files={'image': ('test.jpg', buf, 'image/jpeg')},
data={'symptoms': symptoms},
timeout=30
)
print('Status:', r.status_code)
if r.status_code == 200:
d = r.json()
pred = d.get('prediction') or {}
triage = d.get('triage') or {}
print('Hb:', pred.get('predicted_hemoglobin'))
print('Risk:', pred.get('anemia_risk'))
print('Label:', pred.get('screening_label'))
print('Model:', pred.get('model_source'))
print('Triage band:', triage.get('band'))
print('Blocked:', d.get('blocked'))
else:
print('Error body:', r.text[:1000])
|