Fix rounding issue that caused 1px box shift for YOLO format. (#730)

This commit is contained in:
Denis 2021-04-07 02:38:48 +03:00 committed by GitHub
parent 3425fefd8d
commit 0573a39ec3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -129,10 +129,10 @@ class YoloReader:
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