提交 68f63616 authored 作者: Anish Hiranandani's avatar Anish Hiranandani

Fix after suggestion

上级 0825cb7f
...@@ -95,8 +95,12 @@ def detect(save_img=False): ...@@ -95,8 +95,12 @@ 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[:save_path.rfind('.')] + '.txt', 'a') as file: if dataset.frame == 0:
file.write(('%g ' * 5 + '\n') % (cls, *xywh)) # label format with open(save_path[:save_path.rfind('.')] + '.txt', 'a') as f:
f.write(('%g ' * 5 + '\n') % (cls, *xywh)) # label format
else:
with open(save_path[:save_path.rfind('.')] + '_' + str(dataset.frame) + '.txt', 'a') as f:
f.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
label = '%s %.2f' % (names[int(cls)], conf) label = '%s %.2f' % (names[int(cls)], conf)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论