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@v1to 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:
VLM as Detector,Byte Tracker,Google Vision OCR,Overlap Filter,SAM 3,Classification Label Visualization,Detections Stabilizer,Circle Visualization,Image Contours,Relative Static Crop,Detections Filter,Image Preprocessing,LMM For Classification,VLM as Classifier,Ellipse Visualization,Stitch Images,Triangle Visualization,Stability AI Inpainting,Detections Combine,QR Code Generator,Image Slicer,Background Color Visualization,Model Monitoring Inference Aggregator,Segment Anything 2 Model,Template Matching,Moondream2,Velocity,OCR Model,Dot Visualization,Florence-2 Model,SIFT,Morphological Transformation,Detections Transformation,EasyOCR,Reference Path Visualization,Halo Visualization,SIFT Comparison,Gaze Detection,Polygon Visualization,Image Slicer,Florence-2 Model,Detection Offset,Slack Notification,Clip Comparison,Image Convert Grayscale,Instance Segmentation Model,OpenAI,Byte Tracker,Color Visualization,Line Counter,PTZ Tracking (ONVIF).md),Object Detection Model,Keypoint Detection Model,Google Gemini,Label Visualization,Email Notification,Llama 3.2 Vision,Trace Visualization,Byte Tracker,Dynamic Zone,YOLO-World Model,Email Notification,Corner Visualization,Mask Visualization,Time in Zone,OpenAI,Stability AI Outpainting,CogVLM,Roboflow Custom Metadata,Detections Stitch,Stitch OCR Detections,Blur Visualization,Dominant Color,Time in Zone,CSV Formatter,Crop Visualization,VLM as Detector,OpenAI,Grid Visualization,Detections Classes Replacement,Perspective Correction,Twilio SMS Notification,Absolute Static Crop,Single-Label Classification Model,Seg Preview,Contrast Equalization,Roboflow Dataset Upload,Roboflow Dataset Upload,Polygon Zone Visualization,Stability AI Image Generation,Webhook Sink,Depth Estimation,Bounding Box Visualization,Camera Focus,Line Counter Visualization,Instance Segmentation Model,Multi-Label Classification Model,Icon Visualization,Image Blur,Time in Zone,Pixelate Visualization,Image Threshold,Detections Merge,Path Deviation,Keypoint Detection Model,Anthropic Claude,LMM,Google Gemini,Identify Outliers,Dynamic Crop,Bounding Rectangle,Path Deviation,Detections Consensus,Model Comparison Visualization,Camera Calibration,Local File Sink,Keypoint Visualization,Identify Changes,Object Detection Model - outputs:
VLM as Detector,Byte Tracker,Google Vision OCR,SAM 3,Overlap Filter,Detections Stabilizer,Image Preprocessing,LMM For Classification,Ellipse Visualization,Stitch Images,Triangle Visualization,Detections Combine,Image Slicer,VLM as Classifier,Background Color Visualization,Model Monitoring Inference Aggregator,Segment Anything 2 Model,Template Matching,Distance Measurement,Dot Visualization,EasyOCR,Halo Visualization,Byte Tracker,Color Visualization,Llama 3.2 Vision,QR Code Detection,Line Counter,Size Measurement,Corner Visualization,Mask Visualization,Time in Zone,Stability AI Outpainting,Roboflow Custom Metadata,Barcode Detection,Dominant Color,Time in Zone,Crop Visualization,VLM as Detector,Perspective Correction,Clip Comparison,Single-Label Classification Model,Contrast Equalization,Polygon Zone Visualization,CLIP Embedding Model,Bounding Box Visualization,Camera Focus,Icon Visualization,Image Blur,Time in Zone,Path Deviation,Anthropic Claude,Multi-Label Classification Model,Dynamic Crop,Bounding Rectangle,Path Deviation,Detections Consensus,Model Comparison Visualization,Classification Label Visualization,Circle Visualization,Image Contours,Relative Static Crop,Detections Filter,VLM as Classifier,Stability AI Inpainting,Moondream2,Velocity,OCR Model,Florence-2 Model,SIFT,Morphological Transformation,Detections Transformation,Gaze Detection,Reference Path Visualization,SIFT Comparison,Buffer,Polygon Visualization,Image Slicer,Florence-2 Model,Detection Offset,Clip Comparison,Perception Encoder Embedding Model,Instance Segmentation Model,OpenAI,Image Convert Grayscale,PTZ Tracking (ONVIF).md),Line Counter,Object Detection Model,Keypoint Detection Model,Google Gemini,Label Visualization,Email Notification,Trace Visualization,Byte Tracker,Dynamic Zone,YOLO-World Model,CogVLM,OpenAI,Detections Stitch,Stitch OCR Detections,Blur Visualization,Single-Label Classification Model,OpenAI,Detections Classes Replacement,Absolute Static Crop,Seg Preview,Roboflow Dataset Upload,Roboflow Dataset Upload,Stability AI Image Generation,Depth Estimation,Line Counter Visualization,Instance Segmentation Model,Multi-Label Classification Model,Pixelate Visualization,Image Threshold,Detections Merge,Keypoint Detection Model,LMM,Google Gemini,Pixel Color Count,SmolVLM2,Qwen2.5-VL,Camera Calibration,Keypoint Visualization,Object Detection Model
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[object_detection_prediction,keypoint_detection_prediction,instance_segmentation_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[string,rgb_color]): 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_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 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"
}