Add oriented bounding box support for DOTAv1 datasets#842
Add oriented bounding box support for DOTAv1 datasets#842janerikvw wants to merge 2 commits intoroboflow:developfrom
Conversation
…multi-dataset YAML config Add 5-parameter oriented bounding box prediction (cx, cy, w, h, angle) to RF-DETR, enabling rotated object detection for aerial/satellite imagery. This includes: - Model: bbox_embed outputs 5 params when oriented=True, with sigmoid angle in [0,1) - Loss: circular-aware L1 angle loss, spatial-only GIoU, spatial-only Hungarian matching - PostProcess: angle output in radians [0, pi) with corner conversion utilities - DOTAv1 dataset loader: parses corner-point annotations, converts to OBB representation - Multi-dataset YAML config: combine datasets with per-dataset weights, class mapping, format (coco/yolo/dota), oriented flag, and augmentation overrides - Keypoint-based OBB augmentation: corners tracked through geometric transforms - Box ops: corners_to_obb, obb_to_corners, circular_angle_loss utilities - 34 new tests covering all components https://claude.ai/code/session_01DC76DdnusAVRPbF1NXfska
|
|
Codecov Report❌ Patch coverage is ❌ Your patch check has failed because the patch coverage (60%) is below the target coverage (95%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## develop #842 +/- ##
=======================================
- Coverage 75% 74% -1%
=======================================
Files 92 94 +2
Lines 7148 7509 +361
=======================================
+ Hits 5383 5594 +211
- Misses 1765 1915 +150 🚀 New features to boost your workflow:
|
@janerikvw ^^ 🙏 |
Summary
This PR adds comprehensive support for oriented bounding boxes (OBB) in RF-DETR, including a new DOTAv1 dataset loader, multi-dataset configuration system, and OBB-specific operations and loss functions.
Key Changes
New Dataset Support
src/rfdetr/datasets/dota.py): ImplementsDotaDetectionclass to load DOTAv1 format datasets with 8-point corner annotations. Supports both oriented and axis-aligned bounding box modes.src/rfdetr/datasets/multi.py): Adds YAML-based multi-dataset configuration system withClassMappingDatasetwrapper for class remapping and OBB padding across heterogeneous datasets.OBB Operations
src/rfdetr/utilities/box_ops.py):corners_to_obb(): Converts 4 corner points to normalized OBB representation (cx, cy, w, h, angle)obb_to_corners(): Inverse conversion from OBB to corner pointscircular_angle_loss(): Circular loss for angle predictions accounting for 180° symmetryModel Updates
src/rfdetr/models/lwdetr.py): Addedorientedparameter to predict 5-dim boxes (cx, cy, w, h, angle) when enabledsrc/rfdetr/models/criterion.py): Addedorientedflag andloss_angle_coeffor angle loss weightingsrc/rfdetr/models/postprocess.py): Updated to handle 5-dim oriented box outputssrc/rfdetr/models/matcher.py): Updated to handle oriented boxes in cost computationConfiguration & Training
src/rfdetr/config.py):orientedfield toModelConfigloss_angle_coeftoTrainConfigdataset_fileto support "dota" and "multi" formatsDatasetEntryandMultiDatasetConfigclasses for multi-dataset YAML configssrc/rfdetr/datasets/transforms.py): EnhancedNormalizeto convert OBB corners to normalized angle representation; updated geometric transforms to handle corner points as keypointssrc/rfdetr/training/module_data.py): Added weighted sampling support for multi-dataset trainingsrc/rfdetr/_namespace.py): Propagatedorientedflag through build pipelineTesting
tests/datasets/test_dota.py): Comprehensive tests for dataset loading, oriented/non-oriented modes, class mapping, and edge casestests/datasets/test_multi.py): Tests for YAML config parsing, class mapping, and OBB paddingtests/utilities/test_obb_box_ops.py): Tests for corner↔OBB conversions, roundtrip consistency, and circular angle losstests/test_obb_config.py): Tests for new configuration fieldsImplementation Details
https://claude.ai/code/session_01DC76DdnusAVRPbF1NXfska