Skip to content

Commit 86c10c6

Browse files
jeffaudicursoragent
andcommitted
Release 0.2.0.
Rotated FCOS (anchor-free) with Hub 3× rIoU weights, decoded IoU loss, and TF/ONNX export. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 1eac318 commit 86c10c6

90 files changed

Lines changed: 287217 additions & 156 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎README.md‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
- **Geometry**: Rotated bounding boxes (rbox: cx, cy, w, h, angle), quadrilateral boxes (qbox), polygon ↔ rbox ↔ hbox conversions, angle normalization (le90, 0–180°), flip/rotate/scale transforms, visualization helpers
88
- **IoU & NMS**: Rotated IoU and oriented NMS (CPU with optional GPU kernels when available); AABB pre-filtering; `obb_to_xyxy` / HBB conversion
99
- **Datasets**: DOTA polygon loader (pattern, split file, or separate folders), image tiling, label filtering, ignore masks, oriented mAP evaluation
10-
- **Models**: **Oriented R-CNN** ([Xie et al., ICCV 2021](https://openaccess.thecvf.com/content/ICCV2021/html/Xie_Oriented_R-CNN_for_Object_Detection_ICCV_2021_paper.html); horizontal RPN + MidpointOffset → oriented RoIAlign + oriented ROI head), **Rotated Faster R-CNN** (Ren et al., NeurIPS 2015 two-stage baseline with horizontal RPN + horizontal RoIAlign + rotated ROI head; MMRotate reference), **Rotated RetinaNet** ([Lin et al., ICCV 2017](https://openaccess.thecvf.com/content_ICCV_2017/papers/Lin_Focal_Loss_for_ICCV_2017_paper.pdf); oriented anchors, sigmoid focal loss); ResNet + FPN backbones; selective loading of external checkpoints where configs wire `checkpoint.load_from_checkpoint`
10+
- **Models**: **Oriented R-CNN** ([Xie et al., ICCV 2021](https://openaccess.thecvf.com/content/ICCV2021/html/Xie_Oriented_R-CNN_for_Object_Detection_ICCV_2021_paper.html); horizontal RPN + MidpointOffset → oriented RoIAlign + oriented ROI head), **Rotated Faster R-CNN** (Ren et al., NeurIPS 2015 two-stage baseline with horizontal RPN + horizontal RoIAlign + rotated ROI head; MMRotate reference), **Rotated RetinaNet** ([Lin et al., ICCV 2017](https://openaccess.thecvf.com/content_ICCV_2017/papers/Lin_Focal_Loss_for_ICCV_2017_paper.pdf); oriented anchors, sigmoid focal loss), **Rotated FCOS** (anchor-free single-stage; distance-angle coder, centerness, L1 / KFIoU / decoded rIoU); ResNet + FPN backbones; selective loading of external checkpoints where configs wire `checkpoint.load_from_checkpoint`
1111
- **Training**: JSON configs + **`odet train`**, mixed precision (AMP), gradient accumulation, checkpointing, best-metric tracking, TensorBoard, optional curriculum learning and profiling
1212

1313
## Installation
@@ -139,19 +139,19 @@ DOTA configs: per-model `dota_le90_1x.json` / `dota_le90_3x.json` under [configs
139139
See **[docs/roadmap.md](docs/roadmap.md)** for the full public plan. Summary:
140140

141141
- **v0.1** (shipped): Geometry, IoU/NMS, DOTA, three ResNet-FPN detectors, config training, Hub pretrained weights
142-
- **v0.2**: probiou Faster R-CNN 3× on Hub
143-
- **v0.3**: Rotated FCOS (anchor-free single-stage)
144-
- **v0.4**: HRSC2016 and FAIR1M dataset support
145-
- **v0.5**: RTMDet-R and native YOLO-OBB (AGPL-free production tier)
146-
- **v0.6+**: Swin-FPN backbone; optional fused CUDA kernels; hosted docs
142+
- **v0.1.1** (shipped): ProbIoU Faster R-CNN 1×/3× on Hub
143+
- **v0.2** (shipped): Rotated FCOS (anchor-free single-stage); Hub `rotated_fcos_dota_le90_3x_riou` (81.58% eval-val mAP50)
144+
- **v0.3**: HRSC2016 and FAIR1M dataset support
145+
- **v0.4**: RTMDet-R and native YOLO-OBB (AGPL-free production tier)
146+
- **v0.5+**: Swin-FPN backbone; optional fused CUDA kernels; hosted docs
147147

148148
## Contributing
149149

150150
Contributions are welcome. Run tests with `pytest`, format with `black` and `ruff`. See [docs/contributing.md](docs/contributing.md) for guidelines.
151151

152152
## Publishing to PyPI
153153

154-
Version **0.1.1** — tag releases as **`v0.1.1`** (git) matching `version` in `pyproject.toml`.
154+
Version **0.2.0** — tag releases as **`v0.2.0`** (git) matching `version` in `pyproject.toml`.
155155

156156
Configs: edit **`configs/`** at the repo root, then **`make sync-configs`** so **`oriented_det/configs/`** stays in sync (see **`oriented_det/configs/vendored_manifest.txt`**). CI runs **`make check-configs`**.
157157

‎configs/README.md‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ OrientedDet publishes **DOTA le90 pretrain** checkpoints on Hugging Face Hub. Se
2222
| Rotated RetinaNet 3× | [rotated_retinanet/dota_le90_3x.json](rotated_retinanet/dota_le90_3x.json) | `rotated_retinanet_dota_le90_3x` | 71.52% |
2323
| Rotated Faster R-CNN 1× | [rotated_faster_rcnn/dota_le90_1x.json](rotated_faster_rcnn/dota_le90_1x.json) | `rotated_faster_rcnn_dota_le90_1x` | 77.57% |
2424
| Rotated Faster R-CNN 3× | [rotated_faster_rcnn/dota_le90_3x.json](rotated_faster_rcnn/dota_le90_3x.json) | `rotated_faster_rcnn_dota_le90_3x` | 83.42% |
25+
| Rotated FCOS 3× rIoU | [rotated_fcos/dota_le90_3x_riou.json](rotated_fcos/dota_le90_3x_riou.json) | `rotated_fcos_dota_le90_3x_riou` | 81.58% |
26+
| Rotated FCOS 3× KFIoU aux | [rotated_fcos/dota_le90_3x_kfiou_aux.json](rotated_fcos/dota_le90_3x_kfiou_aux.json) | `rotated_fcos_dota_le90_3x_kfiou_aux` | 77.18% |
2527

2628
Download: `odet pretrained download <slug>` or `"load_from_checkpoint": "hf://<slug>"`. Published eval-val reports: [`docs/eval-reports/`](../docs/eval-reports/) (markdown + analysis JSON; `predictions.json` stays in gitignored [`predictions/`](../predictions/) for the viewer).
2729

@@ -52,6 +54,7 @@ Example in an external project that keeps local dataset fragments:
5254
- **[oriented_rcnn/](oriented_rcnn/)** — Oriented R-CNN (horizontal RPN + midpoint-offset + oriented ROI). See [oriented_rcnn/README.md](oriented_rcnn/README.md).
5355
- **[rotated_faster_rcnn/](rotated_faster_rcnn/)** — Rotated Faster R-CNN. Standard recipe: ProbIoU main ROI loss, Smooth L1 aux 0.1, angle weight 1.0 (`dota_le90_1x.json`; 3× via `dota_le90_3x.json`). See [rotated_faster_rcnn/README.md](rotated_faster_rcnn/README.md).
5456
- **[rotated_retinanet/](rotated_retinanet/)** — Rotated RetinaNet (one-stage). See [rotated_retinanet/README.md](rotated_retinanet/README.md).
57+
- **[rotated_fcos/](rotated_fcos/)** — Rotated FCOS (anchor-free one-stage; L1, optional KFIoU aux, or decoded rIoU primary). See [rotated_fcos/README.md](rotated_fcos/README.md).
5558

5659
## Muted keys
5760

@@ -75,7 +78,7 @@ All options, types, and defaults: **[config.schema.json](config.schema.json)** (
7578
| Section | Description |
7679
|--------|-------------|
7780
| `_base_` | Base config path(s): relative to current file, `@odet:…`, or absolute |
78-
| `model_type` | `oriented_rcnn`, `rotated_faster_rcnn`, or `rotated_retinanet` |
81+
| `model_type` | `oriented_rcnn`, `rotated_faster_rcnn`, `rotated_retinanet`, or `rotated_fcos` |
7982
| `dataset` | data_root, format (dota / airbus_playground), train_tiles_dir, val_tiles_dir, **train_tiles_dirs**, **val_tiles_dirs** (optional lists; union without on-disk merge), **same_folder** (DOTA: images and .txt in same dir), **overlap** (tile overlap px, even; deploy uses margin = overlap/2), annotations_file, split_file, **val_split_id**, **train_includes_val** (Airbus: train on all folds; val fold for monitoring only), difficult_strategy, **filter_empty_gt** (DOTA: drop tiles with no GT after filters; MMRotate parity), max_train_samples, max_val_samples, **max_samples_shuffle_seed** (deterministic spread when capping), allowed_classes, ignore_labels, map_labels |
8083
| `data_loader` | batch_size, num_workers, shuffle, pin_memory |
8184
| `model` | backbone, fpn_*, anchor_*, target_means/stds, roi_* (loss, batch, iou, schedule, **roi_proj_xy**), rpn_*, use_hbb_for_matching, add_gt_as_proposals, **rpn_nms_threshold** (proposal NMS), **final_nms_iou_threshold** / **final_nms_iou_schedule_*** (post–ROI-head NMS), **final_nms_use_cpu** (exact polygon final NMS on CPU), nms_class_agnostic, max_detections_per_image, inference_pre_nms_score_threshold |
@@ -91,7 +94,7 @@ All options, types, and defaults: **[config.schema.json](config.schema.json)** (
9194

9295
## PyPI package (`oriented_det.configs`)
9396

94-
A subset of this tree is copied into **`oriented_det/configs/`** for wheels (see **`oriented_det/configs/vendored_manifest.txt`**), including Rotated RetinaNet and Rotated Faster R-CNN DOTA recipes. After editing files here:
97+
A subset of this tree is copied into **`oriented_det/configs/`** for wheels (see **`oriented_det/configs/vendored_manifest.txt`**), including Oriented R-CNN, Faster R-CNN, RetinaNet, and Rotated FCOS DOTA recipes. After editing files here:
9598

9699
```bash
97100
make sync-configs # update vendored copy
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"model_type": "rotated_fcos",
3+
"model": {
4+
"backbone": "resnet50",
5+
"pretrained_backbone": true,
6+
"trainable_layers": 5,
7+
"fpn_returned_layers": [2, 3, 4],
8+
"fpn_strides": [8, 16, 32, 64, 128],
9+
"fpn_extra_level": true,
10+
"fcos_stacked_convs": 4,
11+
"fcos_center_sampling": true,
12+
"fcos_center_sample_radius": 1.5,
13+
"fcos_norm_on_bbox": true,
14+
"fcos_centerness_on_reg": true,
15+
"fcos_scale_angle": true,
16+
"fcos_angle_weight": 1.0,
17+
"fcos_nms_pre": 2000,
18+
"box_reg_loss_type": "l1",
19+
"aux_loss_type": null,
20+
"aux_loss_weight": 0.0,
21+
"box_reg_weight": 1.0,
22+
"roi_loss_type": "focal",
23+
"roi_focal_alpha": 0.25,
24+
"roi_focal_gamma": 2.0,
25+
"max_detections_per_image": 2000
26+
},
27+
"tensorboard": {
28+
"log_debug_anchors_proposals": false
29+
},
30+
"loss": {
31+
"loss_type": "focal",
32+
"focal_alpha": 0.25,
33+
"focal_gamma": 2.0
34+
}
35+
}

‎configs/config.schema.json‎

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,25 @@
207207
"roi_box_reg_norm": { "type": "string", "default": "sampled_all", "enum": ["sampled_all", "positives_only"], "description": "Smooth L1 normalization: sampled_all (MMDet avg_factor over pos+neg) or positives_only (mean over positives)." },
208208
"roi_box_reg_smooth_l1_aux_weight": { "type": "number", "default": 0.0, "description": "Encoded Smooth L1 aux weight when roi_box_reg_main_loss_type is probiou/riou/kfiou." },
209209
"retinanet_stacked_convs": { "type": "integer", "default": 1, "minimum": 1, "description": "RetinaNet shared 3x3 conv depth before cls/reg (MMRotate: 4)." },
210-
"box_reg_loss_type": { "type": "string", "default": "smooth_l1", "enum": ["smooth_l1", "l1"], "description": "RetinaNet box regression loss (MMRotate: l1)." },
211-
"box_reg_weight": { "type": "number", "default": 1.0, "description": "RetinaNet box regression loss weight." },
210+
"box_reg_loss_type": { "type": "string", "default": "smooth_l1", "enum": ["smooth_l1", "l1", "kfiou", "riou"], "description": "RetinaNet: smooth_l1/l1 encoded. FCOS: l1 (encoded), kfiou (decoded KFIoU), or riou (decoded differentiable polygon IoU, 1-IoU). FCOS riou is not sampling pairwise_rotated_iou." },
211+
"box_reg_weight": { "type": "number", "default": 1.0, "description": "RetinaNet/FCOS box regression loss weight." },
212+
"fcos_stacked_convs": { "type": "integer", "default": 4, "minimum": 1, "description": "Rotated FCOS conv tower depth (MMRotate: 4)." },
213+
"fcos_center_sampling": { "type": "boolean", "default": true, "description": "FCOS center sampling around GT centers." },
214+
"fcos_center_sample_radius": { "type": "number", "default": 1.5, "description": "FCOS center sample radius in stride units." },
215+
"fcos_norm_on_bbox": { "type": "boolean", "default": true, "description": "Normalize FCOS ltrb targets by FPN stride." },
216+
"fcos_centerness_on_reg": { "type": "boolean", "default": true, "description": "Attach FCOS centerness head to the regression tower." },
217+
"fcos_scale_angle": { "type": "boolean", "default": true, "description": "Learnable Scale on FCOS angle prediction." },
218+
"fcos_regress_ranges": {
219+
"type": ["array", "null"],
220+
"items": { "type": "array", "items": { "type": "number" }, "minItems": 2, "maxItems": 2 },
221+
"description": "Per-FPN-level (min,max) regress ranges for FCOS assignment. null = MMRotate defaults."
222+
},
223+
"fcos_angle_weight": { "type": "number", "default": 1.0, "description": "Weight on le90-wrapped angle L1 in FCOS box regression." },
224+
"fcos_nms_pre": { "type": "integer", "default": 2000, "description": "Max FCOS candidates kept per FPN level before NMS." },
225+
"aux_loss_type": { "type": ["string", "null"], "default": null, "enum": [null, "kfiou", "probiou"], "description": "FCOS decoded auxiliary box loss on positives (centerness-weighted). Use with aux_loss_weight > 0 and L1 primary. Sampling riou is rejected. Includes an aspect-gated heading term unless aux_angle_weight is 0." },
226+
"aux_loss_weight": { "type": "number", "default": 0.0, "description": "Weight for FCOS aux_loss_type. 0 disables aux. Typical 0.1 with L1 primary." },
227+
"aux_angle_weight": { "type": "number", "default": 1.0, "description": "Weight of the aspect-gated heading term inside FCOS decoded aux (ω sin²(2Δθ)). 0 disables; ignored when aux is off. Typical 1.0." },
228+
"aux_angle_lambda": { "type": "number", "default": 1.0, "description": "λ for the GT aspect gate ω = exp(-log²(w*/h*)/λ²). Must be > 0 when aux_angle_weight > 0. λ=1 → ω≈0.62 at AR=2, ω≈0.30 at AR=3." },
212229
"roi_batch_size_per_image": { "type": "integer", "default": 512, "description": "ROI proposals to sample per image for training." },
213230
"roi_positive_iou_threshold": { "type": "number", "default": 0.5, "description": "IoU threshold for positive ROI proposals." },
214231
"roi_negative_iou_threshold": { "type": "number", "default": 0.5, "description": "IoU threshold for negative ROI proposals." },

‎configs/oriented_rcnn/README.md‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -212,15 +212,6 @@ The method achieves state-of-the-art accuracy while maintaining competitive effi
212212
| [`dota_le90_1x.json`](./dota_le90_1x.json) | [`oriented_rcnn_r50_fpn_dota_le90_1x-5b128e72.json`](../../pretrained/oriented_rcnn_r50_fpn_dota_le90_1x-5b128e72.json) | [`oriented_rcnn_r50_fpn_dota_le90_1x-5b128e72.log`](../../pretrained/oriented_rcnn_r50_fpn_dota_le90_1x-5b128e72.log) | 1× (12 ep) | `runs/oriented_rcnn/20260616-030231` | `best_mAP_0.78.pth` | 74.79% | `oriented_rcnn_dota_le90_1x` |
213213
| [`dota_le90_3x.json`](./dota_le90_3x.json) | [`oriented_rcnn_r50_fpn_dota_le90_3x-68957f98.json`](../../pretrained/oriented_rcnn_r50_fpn_dota_le90_3x-68957f98.json) | [`oriented_rcnn_r50_fpn_dota_le90_3x-68957f98.log`](../../pretrained/oriented_rcnn_r50_fpn_dota_le90_3x-68957f98.log) | 3× (36 ep) | `runs/oriented_rcnn/20260621-092802` | `best_mAP_0.82.pth` | 79.40% | `oriented_rcnn_dota_le90_3x` |
214214

215-
### MMRotate reference
216-
217-
DOTA1.0
218-
219-
| Backbone | mAP | Angle | lr schd | Mem (GB) | Inf Time (fps) | Aug | Batch Size | MMRotate config name | Download |
220-
| :----------------------: | :---: | :---: | :-----: | :------: | :------------: | :-: | :--------: | :-------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
221-
| ResNet50 (1024,1024,200) | 75.69 | le90 | 1x | 8.46 | 16.2 | - | 2 | `oriented_rcnn_r50_fpn_1x_dota_le90` | [model](https://download.openmmlab.com/mmrotate/v0.1.0/oriented_rcnn/oriented_rcnn_r50_fpn_1x_dota_le90/oriented_rcnn_r50_fpn_1x_dota_le90-6d2b2ce0.pth) \| [log](https://download.openmmlab.com/mmrotate/v0.1.0/oriented_rcnn/oriented_rcnn_r50_fpn_1x_dota_le90/oriented_rcnn_r50_fpn_1x_dota_le90_20220127_100150.log.json) |
222-
| ResNet50 (1024,1024,200) | 75.63 | le90 | 1x | 7.37 | 21.2 | - | 2 | `oriented_rcnn_r50_fpn_fp16_1x_dota_le90` | [model](https://download.openmmlab.com/mmrotate/v0.1.0/oriented_rcnn/oriented_rcnn_r50_fpn_fp16_1x_dota_le90/oriented_rcnn_r50_fpn_fp16_1x_dota_le90-57c88621.pth) \| [log](https://download.openmmlab.com/mmrotate/v0.1.0/oriented_rcnn/oriented_rcnn_r50_fpn_fp16_1x_dota_le90/oriented_rcnn_r50_fpn_fp16_1x_dota_le90_20220303_195049.log.json) |
223-
224215
## Usage
225216

226217
### Training

0 commit comments

Comments
 (0)