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