Commit dda78fb
authored
Feature/segmentation overlap box (#2362)
* workflows: add Overlap Analysis block + detections_overlaps kind
New roboflow_core/overlap_analysis@v1 (also known as OverlapAnalysis)
under core_steps/fusion/overlap_analysis/. Takes two sv.Detections
inputs at the same dimensionality (reference_predictions,
candidate_predictions) and returns, per workflow row, a list of
per-pair overlap records of the new DETECTIONS_OVERLAPS_KIND
(internal_data_type List[Dict[str, Any]]).
Geometry mirrors the original "compute intersection / reference.area"
flow: vectorised sv.box_iou_batch fast-prefilter for non-touching
pairs, then shapely Polygon intersection for surviving pairs. Polygons
are built from sv.mask_to_polygons (longest contour, validated) when
the source detection has a mask, otherwise from the 4-corner bbox.
sv.Detections always exposes a `mask` attribute, but it can be None
for bbox-only sources; the helper handles both.
Per-record schema documented on DETECTIONS_OVERLAPS_KIND. Optional
reference_detection_id / candidate_detection_id keys appear only when
the source sv.Detections.data carries detection_id. The relation is
intentionally non-symmetric: the denominator is always the reference
detection's area.
Wiring:
- entities/types.py: declare DETECTIONS_OVERLAPS_KIND with formal
per-record schema in docs.
- core_steps/loader.py: import the new kind + block; register the
kind in load_kinds(), KINDS_SERIALIZERS (via serialize_wildcard_kind,
which dispatches List[dict] recursively), and KINDS_DESERIALIZERS
(via deserialize_list_of_values_kind for baseline list validation);
append the block to the blocks list.
* workflows: unit tests for OverlapAnalysisBlockV1
17 deterministic tests covering manifest validation (positional + alias
type literals, range check), every behavioural branch of run():
- bbox-only path: full containment, partial overlap, below threshold,
threshold boundary just above and just below, disjoint inputs.
- mask path: rectangular masks inside identical bboxes verify the
shapely / sv.mask_to_polygons branch (bbox IoU would be 1.0, mask
overlap is ~0.5).
- mask path fallback: a degenerate mask (<3 vertices in the longest
contour) is rejected and the helper falls back to the 4-corner bbox
polygon.
- detection_id propagation: present-on-both, present-on-one-only.
- empty inputs (left and right).
- N x M cardinality with mixed overlaps and disjoint pairs.
- Parity test: bbox-only fixtures cross-checked against a verbatim
port of the original Python-block code, asserting equal (class-pair,
ratio) record sets.
No whole-output snapshots or change-detector assertions.
* workflows: integration test for OverlapAnalysisBlockV1
End-to-end ExecutionEngine workflow JSON that runs two
RoboflowObjectDetectionModel steps at different confidence thresholds
and feeds their predictions into the OverlapAnalysis block.
Assertions are shape-based (record schema, ratio range, detection_id
propagation) rather than numeric so the test stays stable across model
weight nudges. Registered with the workflows gallery decorator to
match the convention used by every other fusion-block integration
test in the suite.
A second test pins min_overlap=1.0 and asserts that every emitted
record has ratio == 1.0 (the only way to clear the threshold).
Local env in this commit cannot compile the full loader chain because
of a pre-existing missing `trackers` package import in
core_steps/trackers/botsort/v1.py:5 (unrelated to this change). The
test follows the same pattern as the working
test_workflow_with_detections_consensus_block.py and runs in CI.
* Make linters happy1 parent 6fb9105 commit dda78fb
6 files changed
Lines changed: 998 additions & 0 deletions
File tree
- inference/core/workflows
- core_steps
- fusion/overlap_analysis
- execution_engine/entities
- tests/workflows
- integration_tests/execution
- unit_tests/core_steps/fusion
Whitespace-only changes.
Lines changed: 213 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
197 | 200 | | |
198 | 201 | | |
199 | 202 | | |
| |||
627 | 630 | | |
628 | 631 | | |
629 | 632 | | |
| 633 | + | |
630 | 634 | | |
631 | 635 | | |
632 | 636 | | |
| |||
831 | 835 | | |
832 | 836 | | |
833 | 837 | | |
| 838 | + | |
834 | 839 | | |
835 | 840 | | |
836 | 841 | | |
| |||
1009 | 1014 | | |
1010 | 1015 | | |
1011 | 1016 | | |
| 1017 | + | |
1012 | 1018 | | |
1013 | 1019 | | |
1014 | 1020 | | |
| |||
Lines changed: 49 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
467 | 467 | | |
468 | 468 | | |
469 | 469 | | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
470 | 519 | | |
471 | 520 | | |
472 | 521 | | |
| |||
0 commit comments