vimal-yuvabe commited on
Commit
9ed1c3d
·
1 Parent(s): d3b130f

added bounding box

Browse files
Files changed (1) hide show
  1. app.py +4 -1
app.py CHANGED
@@ -20,13 +20,16 @@ def predict(image_url:str = Query(..., description="URL to a chest X-ray image")
20
  img = transform(img)
21
  img = torch.from_numpy(img)
22
  outputs = model(img[None,...])
 
23
  prediction = dict(zip(model.pathologies,outputs[0].detach().numpy().tolist()))
 
 
24
  pred_output = {}
25
  for k,v in prediction.items():
26
  pred_output.update({k:round(v,2)})
27
 
28
 
29
- return {"prediction_result":pred_output}
30
  except Exception as e:
31
  print(e)
32
  raise HTTPException(status_code=400, detail=f"Failed to fetch/process image: {str(e)}")
 
20
  img = transform(img)
21
  img = torch.from_numpy(img)
22
  outputs = model(img[None,...])
23
+
24
  prediction = dict(zip(model.pathologies,outputs[0].detach().numpy().tolist()))
25
+ pred_class=outputs[0].argmax().item()
26
+ pred_label = model.pathologies[pred_class]
27
  pred_output = {}
28
  for k,v in prediction.items():
29
  pred_output.update({k:round(v,2)})
30
 
31
 
32
+ return {"prediction_result":pred_output,"bounding_box":{pred_label:((139,61),(224,132))}}
33
  except Exception as e:
34
  print(e)
35
  raise HTTPException(status_code=400, detail=f"Failed to fetch/process image: {str(e)}")