Skip to content
This repository was archived by the owner on Dec 1, 2021. It is now read-only.

Commit

Permalink
avoid ValueError for TFDS with BBox on the last pixel
Browse files Browse the repository at this point in the history
  • Loading branch information
hadusam committed Sep 15, 2020
1 parent ba646b9 commit 50ced6a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions blueoil/utils/tfds_builders/object_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 50ced6a

Please sign in to comment.