How to change the bounding box thickness and label text in yolov5?

Viewed 1120

I am using YOLOv5s for object detection on custom datasets, there are multiple objects in given video, sometimes label text and bounding box thickness looks very bad. how can I customize these things?

2 Answers

when using detect.py, pass in the following arguments to adjust the labels and bounding boxes:

--line-thickness 1
--hide-labels True
--hide-conf True

For the --line-thickness argument, pass in an integer value to adjust the thickness, for labels and confidence, they are set to False by default. Setting them to True will hide them.

Be careful using --hide-labels True or hide-conf True.
Under certain circumstances you can encounter an ErrorMessage. Only --hide-labels and --hide-conf should work perfectly fine.

Here is a list of arguments you can use with detect.py.

detect.py [-h] [--weights WEIGHTS [WEIGHTS ...]] [--source SOURCE]
                 [--data DATA] [--imgsz IMGSZ [IMGSZ ...]]
                 [--conf-thres CONF_THRES] [--iou-thres IOU_THRES]
                 [--max-det MAX_DET] [--device DEVICE] [--view-img]
                 [--save-txt] [--save-conf] [--save-crop] [--nosave]
                 [--classes CLASSES [CLASSES ...]] [--agnostic-nms]
                 [--augment] [--visualize] [--update] [--project PROJECT]
                 [--name NAME] [--exist-ok] [--line-thickness LINE_THICKNESS]
                 [--hide-labels] [--hide-conf] [--half] [--dnn]
Related