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