supervision icon indicating copy to clipboard operation
supervision copied to clipboard

Enhancement/add obb support confusion matrix

Open AshAnand34 opened this issue 8 months ago • 1 comments

Description

This pull request introduces support for evaluating oriented bounding boxes (OBBs) in the confusion matrix calculations within the supervision library. The changes include adding a new parameter to enable OBB support, modifying the IoU calculation logic, and adding comprehensive tests to validate the functionality.

Enhancements to IoU and Confusion Matrix Calculations:

  • Added the use_oriented_boxes parameter to the from_detections, from_tensors, and evaluate_detection_batch methods, allowing users to toggle between axis-aligned and oriented bounding box IoU calculations.
  • Updated the IoU computation logic to use oriented_box_iou_batch when use_oriented_boxes is set to True. This ensures accurate IoU calculations for OBBs.

Type of change

Please delete options that are not relevant.

  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [x] New feature (non-breaking change which adds functionality)
  • [x] This change requires a documentation update

How has this change been tested, please provide a testcase or example of how you tested the change?

Added a new test file, test/metrics/test_confusion_matrix_obb.py, to validate the confusion matrix functionality with and without OBB support. These tests include scenarios for perfect matches and slight offsets between predictions and ground truth.

Docs

  • [x] Docs updated? What were the changes:
  • Enhanced the example in the from_detections method's docstring to demonstrate how to use the use_oriented_boxes parameter with both axis-aligned and oriented bounding boxes.

AshAnand34 avatar May 15 '25 07:05 AshAnand34

Excellent initiative on adding OBB support to confusion matrix evaluation! This enhancement addresses a critical gap for oriented object detection benchmarking. The implementation approach is solid and follows good software engineering practices.

Technical Assessment:

  1. Architecture: The use_oriented_boxes parameter design is clean and maintains backward compatibility. The conditional IoU logic between box_iou_batch and oriented_box_iou_batch is well-structured.

  2. Implementation Strengths:

    • Comprehensive parameter propagation through from_detections, from_tensors, and evaluate_detection_batch
    • Dedicated test suite for OBB scenarios
    • Clear documentation updates with practical examples
    • Non-breaking change design
  3. Addressing Review Feedback:

    • @soumik12345's suggestion to add OBB support to ConfusionMatrix.benchmark is valid and should be implemented
    • The failing test case indicates potential issues with the current oriented IoU implementation

Technical Recommendations:

  1. Test Debugging: Investigate the failing test case by:

    • Verifying oriented_box_iou_batch output for your test geometries
    • Adding debug prints to compare expected vs actual IoU values
    • Ensuring OBB format consistency (center, width, height, angle representation)
  2. Benchmark Method: Add the use_oriented_boxes parameter to the benchmark classmethod for complete API consistency

  3. Edge Cases: Consider testing scenarios with:

    • Various rotation angles (0°, 45°, 90°, etc.)
    • Degenerate cases (zero area boxes)
    • High-overlap oriented boxes at different angles

This enhancement will significantly benefit the computer vision community working with oriented detection tasks. The approach aligns well with modern evaluation practices.

Best regards, Gabriel

galafis avatar Sep 27 '25 14:09 galafis