-
Notifications
You must be signed in to change notification settings - Fork 242
Roll up detections block #1853
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Roll up detections block #1853
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces a new "Dimension Roll Up" block that merges detections from secondary models run on dynamic crops back into parent image coordinates. This is a highly needed feature for workflows involving nested detection pipelines (e.g., cropping and running inference on crops, then consolidating results).
Key changes:
- Implements merging of bounding boxes and instance segmentation masks from child detections back to parent coordinates
- Supports configurable confidence strategies (max, mean, min) and overlap thresholds for merging overlapping detections
- Uses IoU-based merging with union-find algorithm to group overlapping detections per class
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 18 comments.
| File | Description |
|---|---|
inference/core/workflows/core_steps/loader.py |
Registers the new DimensionRollUpBlockV1 block by adding import and including it in the load_blocks() list |
inference/core/workflows/core_steps/fusion/dimension_rollup/v1.py |
Complete implementation of the dimension rollup block with manifest, transformation logic, mask/bbox merging algorithms, and helper functions for polygon conversion |
inference/core/workflows/core_steps/fusion/dimension_rollup/__init__.py |
Empty init file for the new dimension_rollup module |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
inference/core/workflows/core_steps/fusion/dimension_rollup/v1.py
Outdated
Show resolved
Hide resolved
inference/core/workflows/core_steps/fusion/dimension_rollup/v1.py
Outdated
Show resolved
Hide resolved
inference/core/workflows/core_steps/fusion/dimension_rollup/v1.py
Outdated
Show resolved
Hide resolved
inference/core/workflows/core_steps/fusion/dimension_rollup/v1.py
Outdated
Show resolved
Hide resolved
inference/core/workflows/core_steps/fusion/dimension_rollup/v1.py
Outdated
Show resolved
Hide resolved
inference/core/workflows/core_steps/fusion/dimension_rollup/v1.py
Outdated
Show resolved
Hide resolved
inference/core/workflows/core_steps/fusion/dimension_rollup/v1.py
Outdated
Show resolved
Hide resolved
inference/core/workflows/core_steps/fusion/dimension_rollup/v1.py
Outdated
Show resolved
Hide resolved
|
@lou-roboflow I've opened a new pull request, #1855, to work on those changes. Once the pull request is ready, I'll request review from you. |
Description
Adds "dimension rollup" - a highly needed block that takes the detections from inferences run on dynamic crops and bumps them back up into whatever parent detection coordinate space they came from. This potentially requires some detection merging - masks and bounding boxes are merged based on IoU thresholds (with fully merging detections being the default). Keypoints can be merged with a specified, optional radius (defaults to 10px). This will work with any combination of object detection, segmentation and keypoint predictions (but it'll only ever pull out the coordinate system for the parent).
An example (we have a number of these) would be dynamic cropping of text, running OCR on that text, and then placing the detected text on the original image that the dynamic crops came from.
While I wanted to have the parent input simply be the detection from the dynamic crop, the workflow engine doesn't allow mixing parameters with different dimensionality. So it's necessary to use a dimensionality reduction block before this block (if there's any way around this, I'd be happy to implement it to keep use of the block simpler).
Most of this was vibe coded. It took quite a bit of iteration to get the options and output format correct, but I've left all of the generated code intact.
IMPORTANT: This makes the assumption that the detections used for the crops are in the same order as the list resulting from dimensionality reduction. As far as I can tell, that's true but if there's a better way to make the association, such as a guid, I'm open to it. I couldn't find one though.
Test workflow (also used for integration tests)

test_workflow.json
Given the following dynamic crops for person detection:

Parent: Object Detection, Child: Segmentation, IoU Threshold: 0

Parent: Object Detection, Child: Object Detection, IoU Threshold: 0 (bounding boxes merged)

Parent: Object Detection, Child: Object Detection, IoU Threshold: 1 (bounding boxes not merged)

The keypoint tests below add 300px padding around the crops to test keypoint merging.
Parent: Object Detection, Child: Keypoint Detection, IoU Threshold: 0, Keypoint Merge Radius: 10 (default)

Parent: Object Detection, Child: Keypoint Detection, IoU Threshold: 0, Keypoint Merge Radius: 0

Type of change
Please delete options that are not relevant.
How has this change been tested, please provide a testcase or example of how you tested the change?
Included integration tests and test workflow. All combinations of object detection, segmentation, and keypoint detection have been tested.
Any specific deployment considerations
N/A
Docs