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