Anish Hiranandani
commited on
Commit
·
68f6361
1
Parent(s):
0825cb7
Fix after suggestion
Browse files
detect.py
CHANGED
@@ -95,8 +95,12 @@ def detect(save_img=False):
|
|
95 |
for *xyxy, conf, cls in det:
|
96 |
if save_txt: # Write to file
|
97 |
xywh = (xyxy2xywh(torch.tensor(xyxy).view(1, 4)) / gn).view(-1).tolist() # normalized xywh
|
98 |
-
|
99 |
-
|
|
|
|
|
|
|
|
|
100 |
|
101 |
if save_img or view_img: # Add bbox to image
|
102 |
label = '%s %.2f' % (names[int(cls)], conf)
|
|
|
95 |
for *xyxy, conf, cls in det:
|
96 |
if save_txt: # Write to file
|
97 |
xywh = (xyxy2xywh(torch.tensor(xyxy).view(1, 4)) / gn).view(-1).tolist() # normalized xywh
|
98 |
+
if dataset.frame == 0:
|
99 |
+
with open(save_path[:save_path.rfind('.')] + '.txt', 'a') as f:
|
100 |
+
f.write(('%g ' * 5 + '\n') % (cls, *xywh)) # label format
|
101 |
+
else:
|
102 |
+
with open(save_path[:save_path.rfind('.')] + '_' + str(dataset.frame) + '.txt', 'a') as f:
|
103 |
+
f.write(('%g ' * 5 + '\n') % (cls, *xywh)) # label format
|
104 |
|
105 |
if save_img or view_img: # Add bbox to image
|
106 |
label = '%s %.2f' % (names[int(cls)], conf)
|