Detections Filter¶
Class: DetectionsFilterBlockV1
Source: inference.core.workflows.core_steps.transformations.detections_filter.v1.DetectionsFilterBlockV1
Filter detection predictions based on customizable conditions, selectively removing detections that don't meet specified criteria (e.g., class names, confidence scores, bounding box properties) while preserving only the detections that match your filtering logic.
How This Block Works¶
This block applies conditional filtering to detection predictions using a flexible query language system. The block:
- Takes detection predictions (object detection, instance segmentation, or keypoint detection) and filtering operation definitions as input
- Evaluates each detection against the filtering conditions specified in the
operationsparameter - Extracts detection properties (e.g., class_name, confidence, bounding box coordinates) using property extraction operations
- Compares extracted properties against criteria using binary statements (e.g., class_name in list, confidence > threshold)
- Filters out detections that don't match the conditions, keeping only detections that satisfy the filter criteria
- Returns filtered predictions containing only the detections that passed the filter conditions
The block uses a query language system that supports extracting various detection properties (class names, confidence scores, bounding box coordinates, etc.) and applying conditional logic to filter detections. Filtering operations can check if properties are in lists, compare numeric values, check string equality, or use other comparators. The operations_parameters dictionary provides runtime values (like class name lists or thresholds) that are referenced in the filtering operations, allowing dynamic filtering criteria that can change based on workflow inputs or computed values. Multiple filtering operations can be chained together to create complex filtering logic.
Common Use Cases¶
- Class-Based Filtering: Filter detections to keep only specific object classes (e.g., keep only "person" and "car" detections, remove all others), enabling focused processing on relevant object types while excluding unwanted detections
- Confidence Threshold Filtering: Remove low-confidence detections to improve detection quality (e.g., keep detections with confidence > 0.7, filter out uncertain predictions), ensuring downstream processing works with reliable detections
- Multi-Criteria Filtering: Apply multiple filtering conditions simultaneously (e.g., keep detections where class_name is in allowed list AND confidence > threshold), combining class and confidence filtering for precise control
- Dynamic Filtering Based on Workflow State: Use workflow inputs or computed values to determine filtering criteria (e.g., filter classes based on user input, adjust confidence threshold based on lighting conditions), enabling adaptive filtering that responds to changing conditions
- Pre-Processing for Downstream Blocks: Filter detections before passing to visualization, counting, or storage blocks (e.g., remove false positives before counting, filter out background classes before visualization), reducing noise and improving accuracy of subsequent operations
- Selective Processing Workflows: Route different filtered subsets to different downstream blocks (e.g., filter high-confidence detections to one path, low-confidence to another), enabling conditional processing based on detection quality or type
Connecting to Other Blocks¶
The filtered predictions from this block can be connected to:
- Detection model blocks (e.g., Object Detection Model, Instance Segmentation Model, Keypoint Detection Model) to receive predictions that are filtered based on class, confidence, or other properties
- Visualization blocks (e.g., Bounding Box Visualization, Polygon Visualization, Label Visualization) to display only the filtered detections, reducing visual clutter and focusing on relevant objects
- Counting and analytics blocks (e.g., Line Counter, Time in Zone, Velocity) to count or analyze only specific filtered classes or confidence levels, ensuring accurate metrics for the objects of interest
- Data storage blocks (e.g., Local File Sink, CSV Formatter, Roboflow Dataset Upload, Webhook Sink) to save or transmit only filtered detection results, reducing storage and bandwidth usage by excluding irrelevant detections
- Other transformation blocks (e.g., Detections Merge, Detections Transform, Detection Offset) to apply additional transformations to the filtered subset, enabling complex processing pipelines on filtered detections
- Flow control blocks (e.g., Continue If, Rate Limiter) to conditionally trigger downstream processing based on whether filtered detections meet certain criteria, enabling conditional workflows based on filtered results
Type identifier¶
Use the following identifier in step "type" field: roboflow_core/detections_filter@v1to add the block as
as step in your workflow.
Properties¶
| Name | Type | Description | Refs |
|---|---|---|---|
name |
str |
Enter a unique identifier for this step.. | ❌ |
operations |
List[Union[ClassificationPropertyExtract, ConvertDictionaryToJSON, ConvertImageToBase64, ConvertImageToJPEG, DetectionsFilter, DetectionsOffset, DetectionsPropertyExtract, DetectionsRename, DetectionsSelection, DetectionsShift, DetectionsToDictionary, Divide, ExtractDetectionProperty, ExtractFrameMetadata, ExtractImageProperty, LookupTable, Multiply, NumberRound, NumericSequenceAggregate, PickDetectionsByParentClass, RandomNumber, SequenceAggregate, SequenceApply, SequenceElementsCount, SequenceLength, SequenceMap, SortDetections, StringMatches, StringSubSequence, StringToLowerCase, StringToUpperCase, TimestampToISOFormat, ToBoolean, ToNumber, ToString]] |
Definition of filtering logic using the query language system. Specifies one or more filtering operations (e.g., DetectionsFilter) that use StatementGroup syntax to define conditional logic. Each operation can extract detection properties (class_name, confidence, coordinates, etc.) and compare them using binary statements (e.g., class_name in list, confidence > threshold). Multiple operations can be chained to create complex filtering logic. The operations reference parameter names from operations_parameters to access runtime values.. | ❌ |
The Refs column marks possibility to parametrise the property with dynamic values available
in workflow runtime. See Bindings for more info.
Available Connections¶
Compatible Blocks
Check what blocks you can connect to Detections Filter in version v1.
- inputs:
Stability AI Outpainting,CLIP Embedding Model,Delta Filter,SAM 3,Motion Detection,Contrast Enhancement,Cosine Similarity,Corner Visualization,Object Detection Model,Ellipse Visualization,Image Preprocessing,Heatmap Visualization,VLM As Classifier,OpenAI,Byte Tracker,Keypoint Visualization,Detections Consensus,First Non Empty Or Default,JSON Parser,Single-Label Classification Model,Dynamic Crop,Polygon Visualization,QR Code Generator,Stitch Images,OpenRouter,Semantic Segmentation Model,Dynamic Zone,Time in Zone,Segment Anything 2 Model,Buffer,EasyOCR,Contrast Equalization,Image Threshold,Anthropic Claude,Halo Visualization,Keypoint Detection Model,Triangle Visualization,Detection Offset,Image Contours,SAM2 Video Tracker,OpenAI,SAM 3,Grid Visualization,VLM As Detector,Object Detection Model,Image Convert Grayscale,Reference Path Visualization,Stitch OCR Detections,Dominant Color,SIFT Comparison,Identify Changes,Roboflow Dataset Upload,CSV Formatter,Object Detection Model,Mask Visualization,Stability AI Image Generation,Qwen-VL,Stitch OCR Detections,Velocity,Qwen3.5,Perception Encoder Embedding Model,Bounding Box Visualization,Google Gemma,Detection Event Log,Bounding Rectangle,CogVLM,Instance Segmentation Model,SAM 3,Inner Workflow,Llama 3.2 Vision,Detections Stabilizer,Anthropic Claude,Depth Estimation,OpenAI,Image Slicer,Gaze Detection,PTZ Tracking (ONVIF),Environment Secrets Store,MoonshotAI Kimi,MoonshotAI Kimi,Line Counter,Keypoint Detection Model,Per-Class Confidence Filter,Semantic Segmentation Model,QR Code Detection,Detections Merge,Absolute Static Crop,Google Gemini,VLM As Classifier,Email Notification,OpenAI,Pixel Color Count,Rate Limiter,LMM For Classification,Text Display,Mask Area Measurement,Circle Visualization,Detections Combine,Image Stack,Mask Edge Snap,Perspective Correction,Multi-Label Classification Model,Camera Focus,Seg Preview,Roboflow Vision Events,OC-SORT Tracker,Trace Visualization,Time in Zone,Email Notification,Model Comparison Visualization,YOLO-World Model,Polygon Zone Visualization,Byte Tracker,GLM-OCR,Image Blur,Clip Comparison,Model Monitoring Inference Aggregator,Cache Get,Detections Stitch,Detections List Roll-Up,Instance Segmentation Model,Google Gemini,Pixelate Visualization,SIFT,Instance Segmentation Model,Polygon Visualization,Data Aggregator,Qwen2.5-VL,Roboflow Custom Metadata,Florence-2 Model,Property Definition,Local File Sink,Icon Visualization,Single-Label Classification Model,Detections Filter,ByteTrack Tracker,Barcode Detection,Size Measurement,Multi-Label Classification Model,Detections Transformation,LMM,Keypoint Detection Model,S3 Sink,Cache Set,BoT-SORT Tracker,SIFT Comparison,Qwen3-VL,Morphological Transformation,OpenAI-Compatible LLM,Identify Outliers,Crop Visualization,Blur Visualization,Google Gemma API,Image Slicer,Qwen 3.5 API,Path Deviation,Background Color Visualization,Slack Notification,Dimension Collapse,Anthropic Claude,Qwen 3.6 API,Webhook Sink,Color Visualization,Relative Static Crop,Llama 3.2 Vision,Path Deviation,Instance Segmentation Model,Qwen3.5-VL,Expression,Google Vision OCR,Camera Focus,Google Gemini,Distance Measurement,Single-Label Classification Model,SORT Tracker,Twilio SMS Notification,Moondream2,Multi-Label Classification Model,Template Matching,Classification Label Visualization,Florence-2 Model,Time in Zone,Dot Visualization,Background Subtraction,Roboflow Dataset Upload,Stability AI Inpainting,Line Counter,Detections Classes Replacement,Label Visualization,Overlap Filter,Camera Calibration,Halo Visualization,Clip Comparison,Continue If,Line Counter Visualization,Byte Tracker,OCR Model,VLM As Detector,Overlap Analysis,Twilio SMS/MMS Notification,Morphological Transformation,SmolVLM2 - outputs:
BoT-SORT Tracker,Crop Visualization,Camera Focus,Blur Visualization,Mask Visualization,Corner Visualization,Ellipse Visualization,Stitch OCR Detections,Roboflow Vision Events,Velocity,Heatmap Visualization,Trace Visualization,OC-SORT Tracker,Path Deviation,Background Color Visualization,Time in Zone,Byte Tracker,Color Visualization,Bounding Box Visualization,Keypoint Visualization,Detections Consensus,Model Comparison Visualization,Detection Event Log,Bounding Rectangle,Path Deviation,Byte Tracker,Dynamic Crop,Polygon Visualization,Distance Measurement,SORT Tracker,Detections Stabilizer,Model Monitoring Inference Aggregator,Dynamic Zone,Detections Stitch,Time in Zone,Detections List Roll-Up,Segment Anything 2 Model,Pixelate Visualization,PTZ Tracking (ONVIF),Florence-2 Model,Time in Zone,Line Counter,Dot Visualization,Polygon Visualization,Roboflow Dataset Upload,Halo Visualization,Per-Class Confidence Filter,Stability AI Inpainting,Roboflow Custom Metadata,Line Counter,Detections Classes Replacement,Florence-2 Model,Label Visualization,Icon Visualization,Detection Offset,Overlap Filter,SAM2 Video Tracker,Detections Merge,Detections Filter,ByteTrack Tracker,Halo Visualization,Size Measurement,Detections Transformation,Mask Area Measurement,Circle Visualization,Byte Tracker,Stitch OCR Detections,Detections Combine,Overlap Analysis,Roboflow Dataset Upload,Mask Edge Snap,Triangle Visualization,Perspective Correction
Input and Output Bindings¶
The available connections depend on its binding kinds. Check what binding kinds
Detections Filter in version v1 has.
Bindings
-
input
predictions(Union[keypoint_detection_prediction,instance_segmentation_prediction,object_detection_prediction]): Detection predictions to filter (object detection, instance segmentation, or keypoint detection). Each detection is evaluated against the filtering conditions specified in the operations parameter. Only detections that match the filter criteria are included in the output. Supports batch processing, allowing filtering of multiple detection sets simultaneously..operations_parameters(*): Dictionary mapping parameter names (referenced in operations) to actual values from the workflow. These parameters provide runtime values used in filtering operations (e.g., class name lists, confidence thresholds). Keys match parameter names used in the operations definition, and values are selectors referencing workflow inputs, step outputs, or computed values. Example: {'classes': '$inputs.allowed_classes', 'threshold': 0.7} where 'classes' and 'threshold' are referenced in the operations..
-
output
predictions(Union[object_detection_prediction,instance_segmentation_prediction,keypoint_detection_prediction]): Prediction with detected bounding boxes in form of sv.Detections(...) object ifobject_detection_predictionor Prediction with detected bounding boxes and segmentation masks in form of sv.Detections(...) object ifinstance_segmentation_predictionor Prediction with detected bounding boxes and detected keypoints in form of sv.Detections(...) object ifkeypoint_detection_prediction.
Example JSON definition of step Detections Filter in version v1
{
"name": "<your_step_name_here>",
"type": "roboflow_core/detections_filter@v1",
"predictions": "$steps.object_detection_model.predictions",
"operations": [
{
"filter_operation": {
"statements": [
{
"comparator": {
"type": "in (Sequence)"
},
"left_operand": {
"operations": [
{
"property_name": "class_name",
"type": "ExtractDetectionProperty"
}
],
"type": "DynamicOperand"
},
"right_operand": {
"operand_name": "classes",
"type": "DynamicOperand"
},
"type": "BinaryStatement"
}
],
"type": "StatementGroup"
},
"type": "DetectionsFilter"
}
],
"operations_parameters": {
"classes": "$inputs.classes"
}
}