From 0573a39ec3b1a3accbcf7e66c3ebd3155120c9cd Mon Sep 17 00:00:00 2001 From: Denis Date: Wed, 7 Apr 2021 02:38:48 +0300 Subject: [PATCH] Fix rounding issue that caused 1px box shift for YOLO format. (#730) --- libs/yolo_io.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/yolo_io.py b/libs/yolo_io.py index 039acdb6..e8ee8f01 100644 --- a/libs/yolo_io.py +++ b/libs/yolo_io.py @@ -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