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