Dynamic Crop¶
Class: DynamicCropBlockV1
Source: inference.core.workflows.core_steps.transformations.dynamic_crop.v1.DynamicCropBlockV1
Create dynamic crops from an image based on detections from detections-based model.
This is useful when placed after an ObjectDetection block as part of a multi-stage workflow. For example, you could use an ObjectDetection block to detect objects, then the DynamicCropBlock block to crop objects, then an OCR block to run character recognition on each of the individual cropped regions.
In addition, for instance segmentation predictions (which provide segmentation mask for each
bounding box) it is possible to remove background in the crops, outside of detected instances.
To enable that functionality, set mask_opacity
to positive value and optionally tune
background_color
.
Type identifier¶
Use the following identifier in step "type"
field: roboflow_core/dynamic_crop@v1
to add the block as
as step in your workflow.
Properties¶
Name | Type | Description | Refs |
---|---|---|---|
name |
str |
Enter a unique identifier for this step.. | ❌ |
mask_opacity |
float |
For instance segmentation, mask_opacity can be used to control background removal. Opacity 1.0 removes the background, while 0.0 leaves the crop unchanged.. | ✅ |
background_color |
Union[Tuple[int, int, int], str] |
For background removal based on segmentation mask, new background color can be selected. Can be a hex string (like '#431112') RGB string (like '(128, 32, 64)') or a RGB tuple (like (18, 17, 67)).. | ✅ |
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 Dynamic Crop
in version v1
.
- inputs:
Detection Offset
,LMM
,Roboflow Custom Metadata
,Image Convert Grayscale
,VLM as Detector
,Absolute Static Crop
,Multi-Label Classification Model
,Relative Static Crop
,Line Counter Visualization
,Detections Classes Replacement
,Gaze Detection
,Background Color Visualization
,OCR Model
,Camera Focus
,Image Contours
,Image Slicer
,Reference Path Visualization
,Instance Segmentation Model
,Keypoint Detection Model
,SIFT Comparison
,Object Detection Model
,Triangle Visualization
,Path Deviation
,Line Counter
,Detections Stabilizer
,Detections Transformation
,Byte Tracker
,Depth Estimation
,Google Vision OCR
,Roboflow Dataset Upload
,Dynamic Zone
,Llama 3.2 Vision
,Clip Comparison
,Perspective Correction
,Object Detection Model
,Crop Visualization
,Identify Changes
,Webhook Sink
,Dot Visualization
,Detections Filter
,Model Comparison Visualization
,Email Notification
,Classification Label Visualization
,Camera Calibration
,Instance Segmentation Model
,Slack Notification
,Stability AI Image Generation
,Detections Merge
,Time in Zone
,Trace Visualization
,Time in Zone
,Corner Visualization
,Image Threshold
,Blur Visualization
,Local File Sink
,CogVLM
,Stability AI Inpainting
,Keypoint Detection Model
,SIFT
,Circle Visualization
,Overlap Filter
,OpenAI
,Moondream2
,Path Deviation
,Florence-2 Model
,Twilio SMS Notification
,Label Visualization
,Stitch Images
,Image Preprocessing
,Bounding Rectangle
,Detections Stitch
,Template Matching
,Byte Tracker
,Grid Visualization
,Dominant Color
,Polygon Zone Visualization
,Keypoint Visualization
,LMM For Classification
,Stitch OCR Detections
,Bounding Box Visualization
,Image Blur
,OpenAI
,Halo Visualization
,Google Gemini
,Ellipse Visualization
,Color Visualization
,Pixelate Visualization
,YOLO-World Model
,VLM as Detector
,Velocity
,Roboflow Dataset Upload
,Polygon Visualization
,Segment Anything 2 Model
,Single-Label Classification Model
,VLM as Classifier
,CSV Formatter
,Image Slicer
,Model Monitoring Inference Aggregator
,Mask Visualization
,Anthropic Claude
,Identify Outliers
,Florence-2 Model
,Byte Tracker
,Dynamic Crop
,Detections Consensus
- outputs:
Size Measurement
,LMM
,Detection Offset
,Buffer
,Image Convert Grayscale
,Roboflow Custom Metadata
,VLM as Detector
,Absolute Static Crop
,Multi-Label Classification Model
,Distance Measurement
,Relative Static Crop
,Line Counter Visualization
,Gaze Detection
,Detections Classes Replacement
,Background Color Visualization
,OCR Model
,Camera Focus
,Image Contours
,Image Slicer
,Reference Path Visualization
,Keypoint Detection Model
,Instance Segmentation Model
,SIFT Comparison
,Object Detection Model
,Triangle Visualization
,Path Deviation
,Detections Stabilizer
,Line Counter
,Detections Transformation
,Multi-Label Classification Model
,Byte Tracker
,Depth Estimation
,Google Vision OCR
,Llama 3.2 Vision
,Roboflow Dataset Upload
,Dynamic Zone
,Clip Comparison
,Perspective Correction
,Object Detection Model
,Crop Visualization
,Dot Visualization
,Detections Filter
,Model Comparison Visualization
,Instance Segmentation Model
,Classification Label Visualization
,Camera Calibration
,Qwen2.5-VL
,Stability AI Image Generation
,Detections Merge
,Time in Zone
,Trace Visualization
,Time in Zone
,Corner Visualization
,Line Counter
,Image Threshold
,Blur Visualization
,QR Code Detection
,CogVLM
,Stability AI Inpainting
,Keypoint Detection Model
,SIFT
,Circle Visualization
,Overlap Filter
,OpenAI
,Moondream2
,Path Deviation
,Florence-2 Model
,Label Visualization
,Stitch Images
,Image Preprocessing
,Bounding Rectangle
,Detections Stitch
,Template Matching
,Byte Tracker
,SmolVLM2
,Dominant Color
,Polygon Zone Visualization
,Keypoint Visualization
,LMM For Classification
,Stitch OCR Detections
,Bounding Box Visualization
,CLIP Embedding Model
,OpenAI
,Halo Visualization
,Google Gemini
,Ellipse Visualization
,Image Blur
,Color Visualization
,Barcode Detection
,Pixelate Visualization
,Single-Label Classification Model
,Pixel Color Count
,YOLO-World Model
,VLM as Detector
,Velocity
,Roboflow Dataset Upload
,Segment Anything 2 Model
,Polygon Visualization
,Single-Label Classification Model
,VLM as Classifier
,Image Slicer
,Clip Comparison
,Model Monitoring Inference Aggregator
,Mask Visualization
,VLM as Classifier
,Anthropic Claude
,Florence-2 Model
,Byte Tracker
,Dynamic Crop
,Detections Consensus
Input and Output Bindings¶
The available connections depend on its binding kinds. Check what binding kinds
Dynamic Crop
in version v1
has.
Bindings
-
input
images
(image
): The input image for this step..predictions
(Union[instance_segmentation_prediction
,object_detection_prediction
,keypoint_detection_prediction
]): Detection model output containing bounding boxes for cropping..mask_opacity
(float_zero_to_one
): For instance segmentation, mask_opacity can be used to control background removal. Opacity 1.0 removes the background, while 0.0 leaves the crop unchanged..background_color
(Union[rgb_color
,string
]): For background removal based on segmentation mask, new background color can be selected. Can be a hex string (like '#431112') RGB string (like '(128, 32, 64)') or a RGB tuple (like (18, 17, 67))..
-
output
crops
(image
): Image in workflows.predictions
(Union[object_detection_prediction
,instance_segmentation_prediction
,keypoint_detection_prediction
]): Prediction with detected bounding boxes in form of sv.Detections(...) object ifobject_detection_prediction
or Prediction with detected bounding boxes and segmentation masks in form of sv.Detections(...) object ifinstance_segmentation_prediction
or Prediction with detected bounding boxes and detected keypoints in form of sv.Detections(...) object ifkeypoint_detection_prediction
.
Example JSON definition of step Dynamic Crop
in version v1
{
"name": "<your_step_name_here>",
"type": "roboflow_core/dynamic_crop@v1",
"images": "$inputs.image",
"predictions": "$steps.my_object_detection_model.predictions",
"mask_opacity": "<block_does_not_provide_example>",
"background_color": "#431112"
}