Skip to content

Fix #489: use public supervision API for annotation (works on 0.18-0.29)#614

Open
prawnsgupta wants to merge 1 commit into
JdeRobot:masterfrom
prawnsgupta:fix/489-supervision-api
Open

Fix #489: use public supervision API for annotation (works on 0.18-0.29)#614
prawnsgupta wants to merge 1 commit into
JdeRobot:masterfrom
prawnsgupta:fix/489-supervision-api

Conversation

@prawnsgupta

Copy link
Copy Markdown

Fixes #489.

Problem. tabs/dataset_viewer.py imported BoxAnnotator from the internal path supervision.detection.annotate, which was removed in supervision ≥ 0.22, causing ModuleNotFoundError for anyone whose environment resolves a supervision newer than the pinned 0.18.0. While investigating I also found that the shared utils/image.py::draw_detections() helper (used by tabs/inference.py) crashes on modern supervision because its palette fallback calls sv.Color.DEFAULT / sv.ColorPalette.default(), both of which raise AttributeError on recent versions (and are not caught by its except TypeError).

Fix.

  • utils/image.py: use sv.ColorPalette.DEFAULT (available on old and new supervision) and keep the existing old-API/new-API try/except, so both BoxAnnotator-combined (≤0.21) and BoxAnnotator + LabelAnnotator (≥0.22) paths work.
  • tabs/dataset_viewer.py: remove the broken inline annotation and delegate to draw_detections(), matching how tabs/inference.py already renders detections.

Verification. Tested end-to-end against supervision 0.18.0 (current pin) and 0.29.1 (latest); both render boxes/labels and return a valid uint8 ndarray. No dependency changes required — confirmed numpy 1.26.4 (project pin) coexists with modern supervision.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: ModuleNotFoundError due to supervision API change

1 participant