소스 검색

Fix after suggestion

5.0
Anish Hiranandani 4 년 전
부모
커밋
68f63616b3
1개의 변경된 파일6개의 추가작업 그리고 2개의 파일을 삭제
  1. +6
    -2
      detect.py

+ 6
- 2
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)

Loading…
취소
저장