diff --git a/keras_rcnn/preprocessing/_object_detection.py b/keras_rcnn/preprocessing/_object_detection.py index c6dda5de..f62ffff0 100644 --- a/keras_rcnn/preprocessing/_object_detection.py +++ b/keras_rcnn/preprocessing/_object_detection.py @@ -126,6 +126,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