Skip to content

Commit

Permalink
Fix rounding issue that caused 1px box shift for YOLO format. (HumanS…
Browse files Browse the repository at this point in the history
  • Loading branch information
Ledorub authored Apr 6, 2021
1 parent 3425fef commit 0573a39
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions libs/yolo_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@ def yolo_line_to_shape(self, class_index, x_center, y_center, w, h):
y_min = max(float(y_center) - float(h) / 2, 0)
y_max = min(float(y_center) + float(h) / 2, 1)

x_min = int(self.img_size[1] * x_min)
x_max = int(self.img_size[1] * x_max)
y_min = int(self.img_size[0] * y_min)
y_max = int(self.img_size[0] * y_max)
x_min = round(self.img_size[1] * x_min)
x_max = round(self.img_size[1] * x_max)
y_min = round(self.img_size[0] * y_min)
y_max = round(self.img_size[0] * y_max)

return label, x_min, y_min, x_max, y_max

Expand Down

0 comments on commit 0573a39

Please sign in to comment.