From 04081f810270712ba3a69577c47e5dcfa850fa90 Mon Sep 17 00:00:00 2001 From: weida wang <43233772+wwdok@users.noreply.github.com> Date: Fri, 13 Nov 2020 00:37:16 +0800 Subject: [PATCH] Trailing --save-txt whitespace bug fix (#1374) * update Write results * Update detect.py * Update test.py Co-authored-by: Glenn Jocher --- detect.py | 2 +- test.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/detect.py b/detect.py index 5cf3b97..fed737e 100644 --- a/detect.py +++ b/detect.py @@ -107,7 +107,7 @@ def detect(save_img=False): xywh = (xyxy2xywh(torch.tensor(xyxy).view(1, 4)) / gn).view(-1).tolist() # normalized xywh line = (cls, *xywh, conf) if opt.save_conf else (cls, *xywh) # label format with open(txt_path + '.txt', 'a') as f: - f.write(('%g ' * len(line) + '\n') % line) + f.write(('%g ' * len(line)).rstrip() % line + '\n') if save_img or view_img: # Add bbox to image label = '%s %.2f' % (names[int(cls)], conf) diff --git a/test.py b/test.py index 644d286..cef13f7 100644 --- a/test.py +++ b/test.py @@ -140,7 +140,7 @@ def test(data, xywh = (xyxy2xywh(torch.tensor(xyxy).view(1, 4)) / gn).view(-1).tolist() # normalized xywh line = (cls, *xywh, conf) if save_conf else (cls, *xywh) # label format with open(str(save_dir / 'labels' / Path(paths[si]).stem) + '.txt', 'a') as f: - f.write(('%g ' * len(line) + '\n') % line) + f.write(('%g ' * len(line)).rstrip() % line + '\n') # W&B logging if len(wandb_images) < log_imgs: