Supervision 0.31 sees depth. ComparisonAnnotator now sees grayscale
Описание и применение
ComparisonAnnotator теперь корректно обрабатывает градационные изображения, позволяя сравнивать детекции на глубинных, термальных и МРТ-изображениях без преобразования в BGR.
Задача
ComparisonAnnotator crashed when annotating grayscale frames because it attempted to write three-channel colors into single-channel images.
Результат
ComparisonAnnotator now handles grayscale frames, enabling direct comparison of detections on depth, thermal, and MRI images without conversion to BGR. The change adds 8 tests and improves library consistency.
Рабочий процесс
- 1. Identify grayscale support gap by running a probe script on all annotators and image layouts.
- 2. Search repository for existing grayscale handling; find _color_for_canvas helper added in #2755.
- 3. Modify ComparisonAnnotator to pass its colors through _color_for_canvas.
- 4. Add eight new tests that compare grayscale output to the first channel of BGR output across multiple detection types and image layouts.
- 5. Run tests on both NumPy fallback and opencv-python backends; confirm all pass.
- 6. Merge PR #2803 and update changelog.
- 7. Notify users via release notes that grayscale comparison is now supported.
Доказательства
ComparisonAnnotator raised a ValueError on all three single-channel inputs.
The fix routes the annotator's three colours through that helper and adds eight tests that check grayscale output against the BGR output, channel for channel.
All 8 fail on develop and pass with the change, on the NumPy fallback and on opencv-python 5.0.0.
- Дата записи: 2026-11-01T02:44:20.366Z