glenn-jocher
commited on
Commit
•
91547ed
1
Parent(s):
251aeaf
Update detect.py (#3087)
Browse files* Update detect.py
* Update detect.py
detect.py
CHANGED
@@ -5,7 +5,6 @@ from pathlib import Path
|
|
5 |
import cv2
|
6 |
import torch
|
7 |
import torch.backends.cudnn as cudnn
|
8 |
-
from numpy import random
|
9 |
|
10 |
from models.experimental import attempt_load
|
11 |
from utils.datasets import LoadStreams, LoadImages
|
@@ -79,7 +78,7 @@ def detect(opt):
|
|
79 |
# Process detections
|
80 |
for i, det in enumerate(pred): # detections per image
|
81 |
if webcam: # batch_size >= 1
|
82 |
-
p, s, im0, frame = path[i], '
|
83 |
else:
|
84 |
p, s, im0, frame = path, '', im0s.copy(), getattr(dataset, 'frame', 0)
|
85 |
|
@@ -108,7 +107,6 @@ def detect(opt):
|
|
108 |
if save_img or opt.save_crop or view_img: # Add bbox to image
|
109 |
c = int(cls) # integer class
|
110 |
label = None if opt.hide_labels else (names[c] if opt.hide_conf else f'{names[c]} {conf:.2f}')
|
111 |
-
|
112 |
plot_one_box(xyxy, im0, label=label, color=colors(c, True), line_thickness=opt.line_thickness)
|
113 |
if opt.save_crop:
|
114 |
save_one_box(xyxy, im0s, file=save_dir / 'crops' / names[c] / f'{p.stem}.jpg', BGR=True)
|
|
|
5 |
import cv2
|
6 |
import torch
|
7 |
import torch.backends.cudnn as cudnn
|
|
|
8 |
|
9 |
from models.experimental import attempt_load
|
10 |
from utils.datasets import LoadStreams, LoadImages
|
|
|
78 |
# Process detections
|
79 |
for i, det in enumerate(pred): # detections per image
|
80 |
if webcam: # batch_size >= 1
|
81 |
+
p, s, im0, frame = path[i], f'{i}: ', im0s[i].copy(), dataset.count
|
82 |
else:
|
83 |
p, s, im0, frame = path, '', im0s.copy(), getattr(dataset, 'frame', 0)
|
84 |
|
|
|
107 |
if save_img or opt.save_crop or view_img: # Add bbox to image
|
108 |
c = int(cls) # integer class
|
109 |
label = None if opt.hide_labels else (names[c] if opt.hide_conf else f'{names[c]} {conf:.2f}')
|
|
|
110 |
plot_one_box(xyxy, im0, label=label, color=colors(c, True), line_thickness=opt.line_thickness)
|
111 |
if opt.save_crop:
|
112 |
save_one_box(xyxy, im0s, file=save_dir / 'crops' / names[c] / f'{p.stem}.jpg', BGR=True)
|