Search code examples
yolov8

Unable to hide bounding boxes and labels in YOLOv8


I'm trying to hide the bounding boxes and the labels after a prediction in YOLOv8. I've set the necessary attributes but I still see the bounding boxes and labels in the final render.show(). What am I doing wrong?

# load model
model = YOLO('ultralyticsplus/yolov8m')

# set model parameters
conf = 0.2
iou = 0.5
ag_nms = False

# try to turn off bounding boxes and labels
model.overrides['hide_labels'] = True
model.overrides['hide_conf'] = True
model.overrides['show'] = False

# set image
image = 'pic.jpg'

# perform inference
results = model.predict(
    image,
    show=False,
    hide_labels=True,
    hide_conf=True,
    conf=conf,
    iou=iou,
)

# observe results
render = render_result(model=model, image=image, result=results[0])
render.show() # still sees the bounding boxes here

Solution

  • The parameters hide_labels, hide_conf seems to be deprecated and will be removed in 'ultralytics 8.2'. Try to use the actual parameters instead:

    show_labels=False
    show_conf=False
    

    I don't know what is 'render' in your script, but I suppose you don't need to directly override the model using model.overrides() to hide boxes, just use the suitable parameter for model.predict():

    boxes=False
    

    The actual Yolov8 parameters are here: https://docs.ultralytics.com/usage/cfg/#predict