Spaces:
Runtime error
Runtime error
extra
Browse files
app.py
CHANGED
|
@@ -76,10 +76,29 @@ def process_image_and_plot(image,iou_threshold=0.5, threshold=0.4):
|
|
| 76 |
|
| 77 |
|
| 78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
|
| 80 |
# Get detections
|
| 81 |
with torch.no_grad():
|
| 82 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
detect = non_max_suppression(detections, iou_threshold, threshold)
|
| 84 |
# BBOX = rescale_boxes(detect[0], img_size, image.shape[:2])
|
| 85 |
|
|
|
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
+
nms_boxes = non_max_suppression(
|
| 80 |
+
bboxes[0], iou_threshold=iou_threshold, threshold=threshold, box_format="midpoint",
|
| 81 |
+
)
|
| 82 |
+
|
| 83 |
|
| 84 |
# Get detections
|
| 85 |
with torch.no_grad():
|
| 86 |
+
output = model(transformed_image)
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
boxes = [[] for _ in range(1)]
|
| 91 |
+
|
| 92 |
+
for i in range(3):
|
| 93 |
+
batch_size, A, S, _, _ = output[i].shape
|
| 94 |
+
anchor = scaled_anchors[i]
|
| 95 |
+
boxes_scale_i = cells_to_bboxes(output[i], anchor, S=S, is_preds=True)
|
| 96 |
+
for idx, box in enumerate(boxes_scale_i):
|
| 97 |
+
bboxes[idx] += box
|
| 98 |
+
|
| 99 |
+
nms_boxes = non_max_suppression(
|
| 100 |
+
bboxes[0], iou_threshold=iou_threshold, threshold=threshold, box_format="midpoint",
|
| 101 |
+
)
|
| 102 |
detect = non_max_suppression(detections, iou_threshold, threshold)
|
| 103 |
# BBOX = rescale_boxes(detect[0], img_size, image.shape[:2])
|
| 104 |
|