wangjin2000
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -74,14 +74,15 @@ def detect_objects(image_path):
|
|
74 |
return results, dicom_image, dicom_meta
|
75 |
|
76 |
def draw_bounding_boxes(img, results):
|
|
|
77 |
for (x1, y1, x2, y2), conf, cls in results:
|
78 |
x1, y1, x2, y2, cls = map(int, [x1, y1, x2, y2, cls])
|
79 |
conf = round(conf.detach().item(), 4)
|
80 |
print("results in draw_bounding box:",[(x1, y1, x2, y2), conf, cls])
|
81 |
-
|
82 |
cv2.rectangle(img, (x1, y1), (x2, y2), (255, 0, 0), 2)
|
83 |
cv2.putText(img, f'{model.names[int(cls)]} {conf:.2f}', (x1, y1 - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.9, (36, 255, 12), 2)
|
84 |
-
return img,
|
85 |
|
86 |
def show_preds_image(filepath):
|
87 |
results, img0, dicom_meta = detect_objects(filepath)
|
|
|
74 |
return results, dicom_image, dicom_meta
|
75 |
|
76 |
def draw_bounding_boxes(img, results):
|
77 |
+
dets = []
|
78 |
for (x1, y1, x2, y2), conf, cls in results:
|
79 |
x1, y1, x2, y2, cls = map(int, [x1, y1, x2, y2, cls])
|
80 |
conf = round(conf.detach().item(), 4)
|
81 |
print("results in draw_bounding box:",[(x1, y1, x2, y2), conf, cls])
|
82 |
+
dets.append([(x1, y1, x2, y2), conf, cls])
|
83 |
cv2.rectangle(img, (x1, y1), (x2, y2), (255, 0, 0), 2)
|
84 |
cv2.putText(img, f'{model.names[int(cls)]} {conf:.2f}', (x1, y1 - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.9, (36, 255, 12), 2)
|
85 |
+
return img, dets
|
86 |
|
87 |
def show_preds_image(filepath):
|
88 |
results, img0, dicom_meta = detect_objects(filepath)
|