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