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