Skip to content

Regression from 0.25.1 to 0.26.1Β #1983

@EugeoSynthesisThirtyTwo

Description

@EugeoSynthesisThirtyTwo

Search before asking

  • I have searched the Supervision issues and found no similar bug report.

Bug

In the 0.25.1 version, I can give a lookup array, but it crashes on 0.26.1 (see minimal reproductible example section)

Traceback (most recent call last):
  File "bug_supervision.py", line 20, in <module>
    annotated_image = box_annotator.annotate(image, detection, custom_color_lookup=lookup)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "miniconda3\envs\rfdetr\Lib\site-packages\supervision\utils\conversion.py", line 26, in wrapper
    annotated_np = annotate_func(self, scene_np, *args, **kwargs)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "miniconda3\envs\rfdetr\Lib\site-packages\supervision\annotators\core.py", line 216, in annotate
    color = resolve_color(
            ^^^^^^^^^^^^^^
  File "miniconda3\envs\rfdetr\Lib\site-packages\supervision\annotators\utils.py", line 145, in resolve_color
    if color_lookup == ColorLookup.TRACK and idx == PENDING_TRACK_ID:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

Environment

Python 3.11.13

Minimal Reproducible Example

import numpy as np
from PIL import Image
import supervision as sv

colors = [sv.Color.from_hex("#DD2244"), sv.Color.from_hex("#44DD22"), sv.Color.from_hex("#2244DD")]
color_palette = sv.ColorPalette(colors)
box_annotator = sv.BoxAnnotator(color=color_palette)
label_annotator = sv.LabelAnnotator(color=color_palette)

image = Image.open("example.jpg")
lookup = np.array([1, 0], dtype=np.int16)
detection = sv.Detections(
    xyxy=np.array([[712, 812, 728, 823], [88.75, 652, 115, 669]], dtype=np.float32),
    mask=None,
    confidence=np.array([0.38, 0.21], dtype=np.float32),
    class_id=np.array([0, 0]),
    tracker_id=None, data={}, metadata={}
)

annotated_image = box_annotator.annotate(image, detection, custom_color_lookup=lookup)
annotated_image.save("example_annotated.png")

Additional

No response

Are you willing to submit a PR?

  • Yes I'd like to help by submitting a PR!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions