gatesla commited on
Commit
b3b8437
·
1 Parent(s): 791042b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -87,11 +87,16 @@ def detect_objects(model_name,url_input,image_input,threshold):
87
  # return [viz_img, processed_outputs]
88
  # print(type(viz_img))
89
 
90
- final_str = ""
 
91
  for score, label, box in zip(processed_outputs["scores"], processed_outputs["labels"], processed_outputs["boxes"]):
92
  box = [round(i, 2) for i in box.tolist()]
93
- final_str += f"Detected `{model.config.id2label[label.item()]}` with confidence `{score.item(), 3}` at location `{box}`\n"
 
 
 
94
 
 
95
 
96
  return viz_img, final_str
97
 
 
87
  # return [viz_img, processed_outputs]
88
  # print(type(viz_img))
89
 
90
+ final_str_abv = ""
91
+ final_str_else = ""
92
  for score, label, box in zip(processed_outputs["scores"], processed_outputs["labels"], processed_outputs["boxes"]):
93
  box = [round(i, 2) for i in box.tolist()]
94
+ if score.item() >= threshold:
95
+ final_str_abv += f"Detected `{model.config.id2label[label.item()]}` with confidence `{round(score.item(), 3)}` at location `{box}`\n"
96
+ else:
97
+ final_str_else += f"Detected `{model.config.id2label[label.item()]}` with confidence `{round(score.item(), 3)}` at location `{box}`\n"
98
 
99
+ final_str = "{ABOVE THRESHOLD OR EQUAL:*^50}\n".format("centered") + final_str_abv + "\n{BELOW THRESHOLD:*^50}\n".format("centered")+final_str_else
100
 
101
  return viz_img, final_str
102