Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 "
|
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 |
|