diff --git a/blueoil/utils/tfds_builders/object_detection.py b/blueoil/utils/tfds_builders/object_detection.py index 280c85354..22ae52bcc 100644 --- a/blueoil/utils/tfds_builders/object_detection.py +++ b/blueoil/utils/tfds_builders/object_detection.py @@ -16,6 +16,10 @@ import tensorflow_datasets as tfds +def _clip_max(num, max=1.0): + return num if num < max else max + + class ObjectDetectionBuilder(tfds.core.GeneratorBasedBuilder): """ A custom TFDS builder for object detection dataset. @@ -77,8 +81,8 @@ def _generate_examples(self, dataset): "bbox": tfds.features.BBox( ymin / height, xmin / width, - (ymin + h) / height, - (xmin + w) / width, + _clip_max((ymin + h) / height), + _clip_max((xmin + w) / width), ) } for xmin, ymin, w, h, label in annotations