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