From 68f63616b3e53c1c4156900f239eccba6c8279b7 Mon Sep 17 00:00:00 2001 From: Anish Hiranandani Date: Thu, 25 Jun 2020 18:23:36 -0700 Subject: [PATCH] Fix after suggestion --- detect.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/detect.py b/detect.py index e4a7ddb..9c4990e 100644 --- a/detect.py +++ b/detect.py @@ -95,8 +95,12 @@ def detect(save_img=False): for *xyxy, conf, cls in det: if save_txt: # Write to file 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: - file.write(('%g ' * 5 + '\n') % (cls, *xywh)) # label format + if dataset.frame == 0: + 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 label = '%s %.2f' % (names[int(cls)], conf)