Add detect.py --hide-conf --hide-labels --line-thickness options (#2658)
* 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 <glenn.jocher@ultralytics.com>
This commit is contained in:
1 parent
14d2d2d75f
commit
f662c18507
1 file changed
+6
-2
@@ -110,8 +110,9 @@ def detect(opt):
|
|||||||
|
|
||||||
if save_img or opt.save_crop or view_img: # Add bbox to image
|
if save_img or opt.save_crop or view_img: # Add bbox to image
|
||||||
c = int(cls) # integer class
|
c = int(cls) # integer class
|
||||||
label = f'{names[c]} {conf:.2f}'
|
label = None if opt.hide_labels else (names[c] if opt.hide_conf else f'{names[c]} {conf:.2f}')
|
||||||
plot_one_box(xyxy, im0, label=label, color=colors[c], line_thickness=3)
|
|
||||||
|
plot_one_box(xyxy, im0, label=label, color=colors[c], line_thickness=opt.line_thickness)
|
||||||
if opt.save_crop:
|
if opt.save_crop:
|
||||||
save_one_box(xyxy, im0s, file=save_dir / 'crops' / names[c] / f'{p.stem}.jpg', BGR=True)
|
save_one_box(xyxy, im0s, file=save_dir / 'crops' / names[c] / f'{p.stem}.jpg', BGR=True)
|
||||||
|
|
||||||
@@ -169,6 +170,9 @@ if __name__ == '__main__':
|
|||||||
parser.add_argument('--project', default='runs/detect', help='save results to project/name')
|
parser.add_argument('--project', default='runs/detect', help='save results to project/name')
|
||||||
parser.add_argument('--name', default='exp', help='save results to project/name')
|
parser.add_argument('--name', default='exp', help='save results to project/name')
|
||||||
parser.add_argument('--exist-ok', action='store_true', help='existing project/name ok, do not increment')
|
parser.add_argument('--exist-ok', action='store_true', help='existing project/name ok, do not increment')
|
||||||
|
parser.add_argument('--line-thickness', default=3, type=int, help='bounding box thickness (pixels)')
|
||||||
|
parser.add_argument('--hide-labels', default=True, action='store_true', help='hide labels')
|
||||||
|
parser.add_argument('--hide-conf', default=True, action='store_true', help='hide confidences')
|
||||||
opt = parser.parse_args()
|
opt = parser.parse_args()
|
||||||
print(opt)
|
print(opt)
|
||||||
check_requirements(exclude=('pycocotools', 'thop'))
|
check_requirements(exclude=('pycocotools', 'thop'))
|
||||||
|
|||||||
Reference in new issue
Block a user