Add detect.py --hide-conf --hide-labels --line-thickness options (#2658)
Browse files* command line option for line thickness and hiding labels
* command line option for line thickness and hiding labels
* command line option for line thickness and hiding labels
* command line option for line thickness and hiding labels
* command line option for line thickness and hiding labels
* command line option for hiding confidence values
* Update detect.py
Co-authored-by: Glenn Jocher <[email protected]>
detect.py
CHANGED
@@ -110,8 +110,9 @@ def detect(opt):
|
|
110 |
|
111 |
if save_img or opt.save_crop or view_img: # Add bbox to image
|
112 |
c = int(cls) # integer class
|
113 |
-
label = f'{names[c]} {conf:.2f}'
|
114 |
-
|
|
|
115 |
if opt.save_crop:
|
116 |
save_one_box(xyxy, im0s, file=save_dir / 'crops' / names[c] / f'{p.stem}.jpg', BGR=True)
|
117 |
|
@@ -169,6 +170,9 @@ if __name__ == '__main__':
|
|
169 |
parser.add_argument('--project', default='runs/detect', help='save results to project/name')
|
170 |
parser.add_argument('--name', default='exp', help='save results to project/name')
|
171 |
parser.add_argument('--exist-ok', action='store_true', help='existing project/name ok, do not increment')
|
|
|
|
|
|
|
172 |
opt = parser.parse_args()
|
173 |
print(opt)
|
174 |
check_requirements(exclude=('pycocotools', 'thop'))
|
|
|
110 |
|
111 |
if save_img or opt.save_crop or view_img: # Add bbox to image
|
112 |
c = int(cls) # integer class
|
113 |
+
label = None if opt.hide_labels else (names[c] if opt.hide_conf else f'{names[c]} {conf:.2f}')
|
114 |
+
|
115 |
+
plot_one_box(xyxy, im0, label=label, color=colors[c], line_thickness=opt.line_thickness)
|
116 |
if opt.save_crop:
|
117 |
save_one_box(xyxy, im0s, file=save_dir / 'crops' / names[c] / f'{p.stem}.jpg', BGR=True)
|
118 |
|
|
|
170 |
parser.add_argument('--project', default='runs/detect', help='save results to project/name')
|
171 |
parser.add_argument('--name', default='exp', help='save results to project/name')
|
172 |
parser.add_argument('--exist-ok', action='store_true', help='existing project/name ok, do not increment')
|
173 |
+
parser.add_argument('--line-thickness', default=3, type=int, help='bounding box thickness (pixels)')
|
174 |
+
parser.add_argument('--hide-labels', default=True, action='store_true', help='hide labels')
|
175 |
+
parser.add_argument('--hide-conf', default=True, action='store_true', help='hide confidences')
|
176 |
opt = parser.parse_args()
|
177 |
print(opt)
|
178 |
check_requirements(exclude=('pycocotools', 'thop'))
|