0llheaven commited on
Commit
7243432
1 Parent(s): 3891b7b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -32,10 +32,14 @@ def detect_objects(image, score_threshold):
32
  for score, label, box in zip(scores, labels, boxes):
33
  if score >= score_threshold: # Only draw if score is above threshold
34
  box = [round(i, 2) for i in box.tolist()]
35
- label_name = "Pneumonia" if label.item() == 0 else "Other"
36
  draw.rectangle(box, outline="red", width=3)
37
  draw.text((box[0], box[1]), f"{label_name}: {round(score.item(), 3)}", fill="red")
38
  labels_output.append(f"{label_name}: {round(score.item(), 3)}")
 
 
 
 
39
 
40
  return image, "\n".join(labels_output)
41
 
 
32
  for score, label, box in zip(scores, labels, boxes):
33
  if score >= score_threshold: # Only draw if score is above threshold
34
  box = [round(i, 2) for i in box.tolist()]
35
+ label_name = "Pneumonia" if label.item() == 0 else "No detection"
36
  draw.rectangle(box, outline="red", width=3)
37
  draw.text((box[0], box[1]), f"{label_name}: {round(score.item(), 3)}", fill="red")
38
  labels_output.append(f"{label_name}: {round(score.item(), 3)}")
39
+
40
+ # If no objects detected, append "No detection"
41
+ if not labels_output:
42
+ labels_output.append("No detection")
43
 
44
  return image, "\n".join(labels_output)
45