From b6d4d2e3ccc7683adda3819708dc7b49e66360e8 Mon Sep 17 00:00:00 2001 From: Tim Becker Date: Mon, 4 Dec 2017 12:07:24 -0500 Subject: [PATCH 1/2] added check for valid bounding boxes, #133 --- keras_rcnn/preprocessing/_object_detection.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/keras_rcnn/preprocessing/_object_detection.py b/keras_rcnn/preprocessing/_object_detection.py index c6dda5de..2bb559b5 100644 --- a/keras_rcnn/preprocessing/_object_detection.py +++ b/keras_rcnn/preprocessing/_object_detection.py @@ -67,6 +67,7 @@ def __init__( super(DictionaryIterator, self).__init__(len(self.dictionary), batch_size, shuffle, seed) + @property def next(self): # Lock indexing to prevent race conditions. with self.lock: @@ -126,6 +127,13 @@ def next(self): label[self.classes[b["class"]]] = 1 labels = numpy.append(labels, [[label]], axis=1) + # check of all boxes are valid, i.e. x1 < x2 and y1 < y2 + for i, b in enumerate(self.dictionary[image_index]["boxes"]): + if ( b["x1"] >= b["x2"] ) or ( b["x1"] >= b["x2"] ): + raise Exception( + "invalid bounding boxes (x1 > x2 or y1 > y2" + ) + # Scale the ground truth boxes to the selected image scale. boxes[batch_index, :, :4] *= self.scale From b689d010a60b28e649e2e06e1d19aa7eec7dd3ed Mon Sep 17 00:00:00 2001 From: Tim Becker Date: Mon, 4 Dec 2017 12:51:56 -0500 Subject: [PATCH 2/2] cleanup --- keras_rcnn/preprocessing/_object_detection.py | 1 - 1 file changed, 1 deletion(-) diff --git a/keras_rcnn/preprocessing/_object_detection.py b/keras_rcnn/preprocessing/_object_detection.py index 2bb559b5..f62ffff0 100644 --- a/keras_rcnn/preprocessing/_object_detection.py +++ b/keras_rcnn/preprocessing/_object_detection.py @@ -67,7 +67,6 @@ def __init__( super(DictionaryIterator, self).__init__(len(self.dictionary), batch_size, shuffle, seed) - @property def next(self): # Lock indexing to prevent race conditions. with self.lock: