Skip to content

Commit

Permalink
Trailing --save-txt whitespace bug fix (ultralytics#1374)
Browse files Browse the repository at this point in the history
* update Write results

* Update detect.py

* Update test.py

Co-authored-by: Glenn Jocher <[email protected]>
  • Loading branch information
wwdok and glenn-jocher authored Nov 12, 2020
1 parent ce3872f commit 04081f8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 04081f8

Please sign in to comment.