supervision
supervision copied to clipboard
Regression from 0.25.1 to 0.26.1
Search before asking
- [x] 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!
Under Windows with Python 3.13 I've run the example with no issues
@marcotaranta I recreated this issue in mac, is it only occurring in mac
Hi @EugeoSynthesisThirtyTwo, @marcotaranta, @Aaraviitkgp!
Thanks a lot for your interest in supervision. I believe this bug has already been fixed in the develop branch. Could one of you install the release candidate version and confirm that the issue no longer appears?
pip install supervision==0.27.0rc4