Skip to content

Conversation

@lou-roboflow
Copy link
Collaborator

@lou-roboflow lou-roboflow commented Dec 24, 2025

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
image

Given the following dynamic crops for person detection:
image

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

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

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

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)
image

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

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

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

  • Docs updated? What were the changes: Inline

Copy link
Contributor

Copilot AI left a 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.

@lou-roboflow lou-roboflow marked this pull request as draft December 24, 2025 21:12
Copy link

Copilot AI commented Dec 26, 2025

@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.

@lou-roboflow lou-roboflow marked this pull request as ready for review December 26, 2025 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants