From 4a8cf4f0968ba860e6c372618766f33dd95b0972 Mon Sep 17 00:00:00 2001 From: Artyom Date: Tue, 3 Jul 2018 16:41:30 +0300 Subject: [PATCH 1/2] Update box_utils.py fixed return value for no object detection --- layers/box_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layers/box_utils.py b/layers/box_utils.py index 84214947b..bea7bfc96 100644 --- a/layers/box_utils.py +++ b/layers/box_utils.py @@ -186,7 +186,7 @@ def nms(boxes, scores, overlap=0.5, top_k=200): keep = scores.new(scores.size(0)).zero_().long() if boxes.numel() == 0: - return keep + return keep, 0 x1 = boxes[:, 0] y1 = boxes[:, 1] x2 = boxes[:, 2] From f6850151d35f8e0b77f57034988459a63d677937 Mon Sep 17 00:00:00 2001 From: Artyom Date: Tue, 3 Jul 2018 16:42:24 +0300 Subject: [PATCH 2/2] Update detection.py fixed count == 0 error --- layers/functions/detection.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/layers/functions/detection.py b/layers/functions/detection.py index 0d1ef8d30..2c26eeceb 100644 --- a/layers/functions/detection.py +++ b/layers/functions/detection.py @@ -52,6 +52,8 @@ def forward(self, loc_data, conf_data, prior_data): boxes = decoded_boxes[l_mask].view(-1, 4) # idx of highest scoring and non-overlapping boxes per class ids, count = nms(boxes, scores, self.nms_thresh, self.top_k) + if count == 0: + continue output[i, cl, :count] = \ torch.cat((scores[ids[:count]].unsqueeze(1), boxes[ids[:count]]), 1)