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