Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -34,19 +34,14 @@ def detect_objects(image, score_threshold):
|
|
34 |
if score >= score_threshold: # Only draw if score is above threshold
|
35 |
no_detection = False
|
36 |
box = [round(i, 2) for i in box.tolist()]
|
37 |
-
|
38 |
-
if label.item() == 0:
|
39 |
-
label_name = "Pneumonia"
|
40 |
-
else:
|
41 |
-
label_name = "Other"
|
42 |
-
|
43 |
draw.rectangle(box, outline="red", width=3)
|
44 |
draw.text((box[0], box[1]), f"{label_name}: {round(score.item(), 3)}", fill="red")
|
45 |
labels_output.append(f"{label_name}: {round(score.item(), 3)}")
|
46 |
|
47 |
# If no detections, set label as 'Other'
|
48 |
if no_detection:
|
49 |
-
labels_output.append("
|
50 |
|
51 |
return image, "\n".join(labels_output)
|
52 |
|
|
|
34 |
if score >= score_threshold: # Only draw if score is above threshold
|
35 |
no_detection = False
|
36 |
box = [round(i, 2) for i in box.tolist()]
|
37 |
+
label_name = "Pneumonia" if label.item() == 0 else "Other"
|
|
|
|
|
|
|
|
|
|
|
38 |
draw.rectangle(box, outline="red", width=3)
|
39 |
draw.text((box[0], box[1]), f"{label_name}: {round(score.item(), 3)}", fill="red")
|
40 |
labels_output.append(f"{label_name}: {round(score.item(), 3)}")
|
41 |
|
42 |
# If no detections, set label as 'Other'
|
43 |
if no_detection:
|
44 |
+
labels_output.append("No Detection")
|
45 |
|
46 |
return image, "\n".join(labels_output)
|
47 |
|