`bbox` and `masks` coloring based on `track-ids` (#16073)

Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Co-authored-by: Laughing <61612323+Laughing-q@users.noreply.github.com>
Co-authored-by: Ultralytics Assistant <135830346+UltralyticsAssistant@users.noreply.github.com>
pull/15961/head^2
Muhammad Rizwan Munawar 2 months ago committed by GitHub
parent 9b8f0d925d
commit 7c61569630
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 19
      ultralytics/engine/results.py

@ -522,7 +522,13 @@ class Results(SimpleClass):
.contiguous()
/ 255
)
idx = pred_boxes.cls if pred_boxes and color_mode == "class" else reversed(range(len(pred_masks)))
idx = (
pred_boxes.id
if pred_boxes.id is not None and color_mode == "instance"
else pred_boxes.cls
if pred_boxes and color_mode == "class"
else reversed(range(len(pred_masks)))
)
annotator.masks(pred_masks.data, colors=[colors(x, True) for x in idx], im_gpu=im_gpu)
# Plot Detect results
@ -535,7 +541,16 @@ class Results(SimpleClass):
annotator.box_label(
box,
label,
color=colors(i if color_mode == "instance" else c, True),
color=colors(
c
if color_mode == "class"
else id
if id is not None
else i
if color_mode == "instance"
else None,
True,
),
rotated=is_obb,
)

Loading…
Cancel
Save