From 2d75f72598d5ce80786be61f140673a6d1dd7e57 Mon Sep 17 00:00:00 2001 From: Dean Mark <2552482+deanmark@users.noreply.github.com> Date: Sun, 25 Feb 2024 16:46:56 +0200 Subject: [PATCH] Add plot_images `conf_thresh` parameter (#8446) Co-authored-by: UltralyticsAssistant Co-authored-by: Glenn Jocher --- ultralytics/utils/plotting.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ultralytics/utils/plotting.py b/ultralytics/utils/plotting.py index 3c83bc4f..66a5296f 100644 --- a/ultralytics/utils/plotting.py +++ b/ultralytics/utils/plotting.py @@ -713,6 +713,7 @@ def plot_images( on_plot=None, max_subplots=16, save=True, + conf_thres=0.25, ): """Plot image grid with labels.""" if isinstance(images, torch.Tensor): @@ -778,7 +779,7 @@ def plot_images( c = classes[j] color = colors(c) c = names.get(c, c) if names else c - if labels or conf[j] > 0.25: # 0.25 conf thresh + if labels or conf[j] > conf_thres: label = f"{c}" if labels else f"{c} {conf[j]:.1f}" annotator.box_label(box, label, color=color, rotated=is_obb) @@ -800,7 +801,7 @@ def plot_images( kpts_[..., 0] += x kpts_[..., 1] += y for j in range(len(kpts_)): - if labels or conf[j] > 0.25: # 0.25 conf thresh + if labels or conf[j] > conf_thres: annotator.kpts(kpts_[j]) # Plot masks @@ -816,7 +817,7 @@ def plot_images( im = np.asarray(annotator.im).copy() for j in range(len(image_masks)): - if labels or conf[j] > 0.25: # 0.25 conf thresh + if labels or conf[j] > conf_thres: color = colors(classes[j]) mh, mw = image_masks[j].shape if mh != h or mw != w: