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