Unverified 提交 04081f81 authored 作者: weida wang's avatar weida wang 提交者: GitHub

Trailing --save-txt whitespace bug fix (#1374)

* update Write results * Update detect.py * Update test.py Co-authored-by: 's avatarGlenn Jocher <glenn.jocher@ultralytics.com>
上级 ce3872f8
...@@ -107,7 +107,7 @@ def detect(save_img=False): ...@@ -107,7 +107,7 @@ def detect(save_img=False):
xywh = (xyxy2xywh(torch.tensor(xyxy).view(1, 4)) / gn).view(-1).tolist() # normalized xywh 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 line = (cls, *xywh, conf) if opt.save_conf else (cls, *xywh) # label format
with open(txt_path + '.txt', 'a') as f: 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 if save_img or view_img: # Add bbox to image
label = '%s %.2f' % (names[int(cls)], conf) label = '%s %.2f' % (names[int(cls)], conf)
......
...@@ -140,7 +140,7 @@ def test(data, ...@@ -140,7 +140,7 @@ def test(data,
xywh = (xyxy2xywh(torch.tensor(xyxy).view(1, 4)) / gn).view(-1).tolist() # normalized xywh 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 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: 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 # W&B logging
if len(wandb_images) < log_imgs: if len(wandb_images) < log_imgs:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论