Giddycrypt commited on
Commit
51ee15b
·
verified ·
1 Parent(s): 20083da

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -7
app.py CHANGED
@@ -91,14 +91,9 @@ async def predict_age_gender(file: UploadFile = File(...)):
91
  if img is None:
92
  raise HTTPException(status_code=400, detail="Invalid or unreadable image file.")
93
 
94
- # Write to temp file so MiVOLO can read it from disk
95
- with tempfile.NamedTemporaryFile(suffix=".jpg", delete=False) as tmp:
96
- tmp_path = tmp.name
97
- cv2.imwrite(tmp_path, img)
98
-
99
- # Run MiVOLO prediction
100
  pred = get_predictor()
101
- detected_objects, _ = pred.recognize(tmp_path)
102
 
103
  if detected_objects is None or not detected_objects.ages:
104
  raise HTTPException(
 
91
  if img is None:
92
  raise HTTPException(status_code=400, detail="Invalid or unreadable image file.")
93
 
94
+ # Run MiVOLO prediction directly on the numpy image array
 
 
 
 
 
95
  pred = get_predictor()
96
+ detected_objects, _ = pred.recognize(img)
97
 
98
  if detected_objects is None or not detected_objects.ages:
99
  raise HTTPException(