Add Per-Class Confidence Filter workflow block#2283
Open
dcaroboflow wants to merge 2 commits intomainfrom
Open
Add Per-Class Confidence Filter workflow block#2283dcaroboflow wants to merge 2 commits intomainfrom
dcaroboflow wants to merge 2 commits intomainfrom
Conversation
Adds a new transformation block roboflow_core/per_class_confidence_filter@v1
that filters detection predictions using a different confidence threshold
per class. Detections are kept only if their confidence is at least the
threshold configured for their class, with a configurable default_threshold
fallback for classes that are not listed.
The existing detections_filter block can express this via its query language,
but requires a verbose StatementGroup/BinaryStatement configuration. This
block exposes a simple {"class_name": threshold} dictionary for the common
per-class case.
Supports object detection, instance segmentation, and keypoint detection
prediction kinds. Includes a unit test suite covering manifest validation,
boundary conditions, unknown-class fallback, empty inputs, and batch
processing, plus an integration test exercising the full ExecutionEngine
path with synthetic detections.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new transformation block
roboflow_core/per_class_confidence_filter@v1that filters detection predictions by applying a different confidence threshold per class.class_thresholdsfall back to a configurabledefault_threshold(defaults to 0.3)core_steps/loader.py; appears as Per-Class Confidence Filter under theflow_controlsection in the Workflows UIWhy a new block
The existing
detections_filterblock applies a single confidence threshold across all classes — you can filter to a class list or set a global confidence cutoff, but you cannot say "keeppersononly above 0.98 andcaronly above 0.5" without writing extremely verbose nestedStatementGroups by hand (which the UI's Configure popup does not surface). This block fills that gap with a purpose-built{class_name: threshold}input for the common per-class case.API
```json
{
"type": "roboflow_core/per_class_confidence_filter@v1",
"name": "filter",
"predictions": "$steps.detector.predictions",
"class_thresholds": {"person": 0.98, "car": 0.5},
"default_threshold": 0.3
}
```
class_thresholdsalso accepts a workflow input or step output selector pointing to a dictionary.Tests
tests/workflows/unit_tests/core_steps/transformations/test_per_class_confidence_filter.py): manifest validation, per-class threshold drops, inclusive boundary, unknown-class fallback, empty predictions, empty thresholds, batch processingtests/workflows/integration_tests/execution/test_workflow_with_per_class_confidence_filter.py): full ExecutionEngine path with synthetic detections, including default-threshold fallback and multi-image batchesAll 15 tests pass locally. `make style` applied.
Test plan
/workflows/blocks/describewith correct UI metadata (name, section, icon)