--save-txt extension fix

This commit is contained in:
Glenn Jocher 2020-05-16 11:51:49 -07:00
parent 3a71daf4bc
commit 27c7b02fff
1 changed files with 1 additions and 1 deletions

View File

@ -124,7 +124,7 @@ def detect(save_img=False):
for *xyxy, conf, cls in det: for *xyxy, conf, cls in det:
if save_txt: # Write to file if save_txt: # Write to file
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
with open(save_path + '.txt', 'a') as file: with open(save_path[:save_path.rfind('.')] + '.txt', 'a') as file:
file.write(('%g ' * 5 + '\n') % (cls, *xywh)) # label format file.write(('%g ' * 5 + '\n') % (cls, *xywh)) # label format
if save_img or view_img: # Add bbox to image if save_img or view_img: # Add bbox to image