From e080e66b7cc39c5c735337a17dfaeb0bf07d846d Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 9 Aug 2021 01:15:21 +0200 Subject: [PATCH] Fixed bug in dataset code: the IOU was calculated wrongly, mixing up pixel-scale and grid-scale coordinates. This is resulting in very small IOU values for the middle and large grid scale, preventing a training signal for this part of the network. This does may also explain the poorer training performance compared to the original implementation, because 2/3 of the network is not getting a training signal. I fixed the bug simply by dividing the anchor boxes by the strides for calculating the IOU consistently with grid-level coordinaes. The result looks correct now. --- core/dataset.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/dataset.py b/core/dataset.py index 38cf4495..adb93ee2 100644 --- a/core/dataset.py +++ b/core/dataset.py @@ -332,8 +332,8 @@ def preprocess_true_boxes(self, bboxes): anchors_xywh[:, 0:2] = ( np.floor(bbox_xywh_scaled[i, 0:2]).astype(np.int32) + 0.5 ) - anchors_xywh[:, 2:4] = self.anchors[i] - + anchors_xywh[:, 2:4] = self.anchors[i] / self.strides[i] + iou_scale = utils.bbox_iou( bbox_xywh_scaled[i][np.newaxis, :], anchors_xywh )