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