You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 36ad4dc
Browse filesBrowse the repository at this point in the historyBrowse files
Enhance ONNX export and inference capabilities with output class filtering
- Added `output_classes` configuration to allow post-NMS class filtering in `production` settings, enabling users to specify which classes to keep after inference.
- Updated relevant functions and documentation to support the new output class feature, ensuring excluded classes still compete during NMS.
- Enhanced `README.md` and `config.schema.json` to reflect the new `output_classes` functionality and its usage.
- Improved test coverage for output class filtering to validate behavior during inference and ONNX export.
This update aims to provide more flexibility in managing class outputs.
|`training`|**lr_scheduler_type** first, then lr_scheduler_*, lr_warmup_steps, lr_scaling_*, use_lr_param_groups, lr_mult_*, then num_epochs, learning_rate, momentum, weight_decay, use_amp, gradient_accumulation_steps, max_grad_norm, loss_weights. See [Training — Learning rate scheduling](../docs/user-guide/training.md#learning-rate-scheduling) and [_base_/schedules/README.md](_base_/schedules/README.md). |
135
135
|`evaluation`|**`val_score_threshold`** (periodic val / `make eval-val` / `best_mAP`), **`test_score_threshold`** for **`test_map` / `make eval-test`** (null → **0.05**), iou_threshold, compute_map_*; **`final_nms_iou_threshold`** for eval-val NMS only (DOTA+HRSC: **0.1**, MMRotate test parity) |
136
-
| `production` | Optional **deploy / `image_demo`** overrides: `score_threshold` via `resolve_inference_score_threshold` (does **not** override train-val mAP; `odet preds` ignores it). DOTA 1× recipes set this to eval-val global F1 − **0.05** (Oriented R-CNN **0.55**, Faster R-CNN **0.6**, RetinaNet OBB **0.25** / HBB **0.35**, FCOS **0.2**); 3× inherits those floors. HRSC 1× recipes do the same (Oriented R-CNN / Faster R-CNN **0.85**, FCOS **0.2**). `per_class_score_threshold` merges on top of `evaluation` for preds/deploy only (`merge_per_class_score_thresholds`; mAP IoU is `evaluation.iou_threshold` only). **Decode (deploy / `image_demo`)** — RPN/NMS/threshold fields patch the loaded model via `apply_inference_config_to_model` (DOTA+HRSC+FAIR1M: final NMS **0.1**). **`odet preds`** prefers `evaluation.final_nms_iou_threshold` when set. Not applied during `tools/train.py` (training uses `model.*`, final NMS **0.1**). **Deploy / tiling** — `overlap_pixels`, `ignore_margin_pixels`, canvas flags (see **config.schema.json**). |
136
+
| `production` | Optional **deploy / `image_demo`** overrides: `score_threshold` via `resolve_inference_score_threshold` (does **not** override train-val mAP; `odet preds` ignores it). DOTA 1× recipes set this to eval-val global F1 − **0.05** (Oriented R-CNN **0.55**, Faster R-CNN **0.6**, RetinaNet OBB **0.25** / HBB **0.35**, FCOS **0.2**); 3× inherits those floors. HRSC 1× recipes do the same (Oriented R-CNN / Faster R-CNN **0.85**, FCOS **0.2**). `per_class_score_threshold` merges on top of `evaluation` for preds/deploy only (`merge_per_class_score_thresholds`; mAP IoU is `evaluation.iou_threshold` only). **`output_classes`**: post-NMS allowlist for preds / image_demo / deploy / ONNX export (excluded classes still compete in NMS). **Decode (deploy / `image_demo`)** — RPN/NMS/threshold fields patch the loaded model via `apply_inference_config_to_model` (DOTA+HRSC+FAIR1M: final NMS **0.1**). **`odet preds`** prefers `evaluation.final_nms_iou_threshold` when set. Not applied during `tools/train.py` (training uses `model.*`, final NMS **0.1**). **Deploy / tiling** — `overlap_pixels`, `ignore_margin_pixels`, canvas flags (see **config.schema.json**). |
|`loss`| loss_type (`focal_weighted` now also scales FCOS/RetinaNet sigmoid focal per class; `background_weight` is ROI-only), class_weight_method, background_weight, focal_alpha, focal_gamma, label_smoothing, **roi_grouped_ce_*** (coarse-to-fine ROI classifier curriculum in one run) |
Copy file name to clipboardExpand all lines: configs/config.schema.json
+5Lines changed: 5 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -427,6 +427,11 @@
427
427
"additionalProperties": { "type": "number" },
428
428
"description": "Per-class floors for preds/deploy only (merge_per_class_score_thresholds: evaluation then production). Does not affect train-val mAP."
429
429
},
430
+
"output_classes": {
431
+
"type": ["array", "null"],
432
+
"items": { "type": "string" },
433
+
"description": "Post-NMS class allowlist for odet preds, image_demo, deploy/Docker, and ONNX export (case-insensitive). Null = keep all. Prefer this over impossible score floors (e.g. 1.1) when hiding classes for a client — excluded classes still compete in NMS."
434
+
},
430
435
"final_nms_iou_threshold": { "type": ["number", "null"], "default": null, "description": "Deploy / image_demo final detection NMS IoU; when set, patches the live model after checkpoint load. odet preds / make eval-val use evaluation.final_nms_iou_threshold when that field is set." },
Copy file name to clipboardExpand all lines: deploy/example/README.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,4 +50,4 @@ curl -fsS http://127.0.0.1:8080/api/v1/health # OK
50
50
51
51
`POST /api/v1/process` body: `{"resolution": <meters per pixel>, "tiles": [<base64 JPEG or PNG>]}`. Response: GeoJSON FeatureCollection (category, confidence, length/width in meters). One request at a time (HTTP 429 if busy).
52
52
53
-
Inference knobs come from `config.production.*` (score floor, NMS, sliding-window overlap, canvas flags). DOTA Hub Oriented R-CNN 1× uses score 0.55 and NMS 0.1.
53
+
Inference knobs come from `config.production.*` (score floor, NMS, sliding-window overlap, canvas flags, optional `output_classes` post-NMS allowlist). DOTA Hub Oriented R-CNN 1× uses score 0.55 and NMS 0.1.
Copy file name to clipboardExpand all lines: export/PARITY.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ The delivered graph is **ONNX pre-NMS** (`rotated_fcos_pre_nms` for FCOS). Prepr
10
10
| Backbone + FCOS head + DistanceAnglePointCoder decode | Same weights/logic as `RotatedFCOS` eval via `rotated_fcos_decode_pre_nms` (includes GroupNorm). |
11
11
| Per-level pre-NMS cap | Always `topk(min(nms_pre, H×W))` then score / size / finite filters. Invalid top-k rows are zeroed (`score=0`, `w=h=0`) and left in the padded tensor. |
| Final NMS / score floors |`export.postprocess.finalize_detections_numpy` calling `export.nms` (numpy clip, or Shapely if `nms_backend=shapely`). Production `score_threshold` applied **before** NMS. Class-aware vs class-agnostic follows resolved `nms_class_agnostic` (`production` override, else `model`; export unset default is class-agnostic). Small float drift vs Shapely is possible on the `python` backend. |
13
+
| Final NMS / score floors |`export.postprocess.finalize_detections_numpy` calling `export.nms` (numpy clip, or Shapely if `nms_backend=shapely`). Production `score_threshold` applied **before** NMS. Optional `production.output_classes` allowlist runs **after** NMS. Class-aware vs class-agnostic follows resolved `nms_class_agnostic` (`production` override, else `model`; export unset default is class-agnostic). Small float drift vs Shapely is possible on the `python` backend. |
14
14
| Sliding-window tiling |`detect_image` tiles `fixed` / `crop` images larger than `window_size` (else `target_size`). Same edge-flush grid and `target_size / window_size` box scale as `run_inference_sliding_window`. Overlap default 200 px. Per-window NMS, then a second NMS across windows. Interior overlap margin stays 0. `pad` / `keep_ratio` are a single resize. |
Exporting a new graph from a checkpoint still needs oriented-det. From the repo root:
13
+
Exporting a new graph from a checkpoint still needs oriented-det (and `onnx` / `onnxruntime` / `onnxscript` via `.[export]`). Producer export uses the TorchScript ONNX path (`dynamo=False`). From the repo root:
14
14
15
15
```bash
16
16
uv pip install -e ".[export]"
@@ -97,6 +97,18 @@ Rotated NMS runs in Python after the ONNX graph (`export/nms.py`). Both modes ar
97
97
98
98
At export: `production.nms_class_agnostic` when set, else `model.nms_class_agnostic`, else **class-agnostic**. Re-export after changing the config so the sidecar picks it up. `odet export preds` also overlays the experiment config onto the loaded meta.
99
99
100
+
## Output class allowlist (post-NMS)
101
+
102
+
To hide classes for a client without score-floor hacks, set `production.output_classes`. The same field is honored by **PyTorch** (`odet preds`, `image_demo`, deploy/Docker) and **ONNX export** (sidecar / `odet export preds`). After score floors + NMS, only listed names are kept (case-insensitive). Excluded classes still compete in NMS, so a strong aircraft box can suppress a weaker overlapping drone before aircraft is dropped from the output.
103
+
104
+
```json
105
+
"production": {
106
+
"output_classes": ["drone", "shahed"]
107
+
}
108
+
```
109
+
110
+
`null` / omitted keeps every class. Prefer this over `per_class_score_threshold` values like `1.1`.
111
+
100
112
## Inference score overrides
101
113
102
114
The graph is pre-NMS only. It bakes `pre_nms_score_threshold` (0.05 on the current RTMDet export) and has no threshold input. Scores below that floor are already gone; a caller cannot recover them.
0 commit comments