image-crop-each-by-class — Conditional AI Model
Turn a detector's boxes into one crop per object — five people in, five crops out — collected as an image list in left-to-right, top-to-bottom, size or detection order. A Boxes text names each crop's box on the same line, and Paste Each by Coordinates puts the whole processed list back in one step. CPU, instant.
Details
- CategoryConditional
- Year-1
- License
Inputs & Outputs
- ImageInputimage
The input image
- TextInputstring
Line separated input string. A line contains a class and bounding box coordinate
- ImagesOutputlist:image
One crop per detected object, in the chosen order
- BoxesOutputstring
Each crop's box as Left,Top,Right,Bottom, one line per crop in list order
Parameters
- target_classesstringdefault
Classes to crop, comma-separated. Leave empty to crop every detected object.
Class names to crop, comma-separated, matched case-insensitively against the labels the upstream Object Detection node emits. Every detection of any listed class becomes its own crop. Empty (the default) crops every detection that has a box — the usual choice when the detector already targets one subject (a face detector, a SAM prompt). Names that match nothing fail with AI.TARGET_CLASS_NOT_DETECTED, whose message lists the classes the detector did find, with counts.
- dilationintegerdefault 0range 0–100
Box enlargement, % of box size (0-100)
Enlarges the box by this percentage of its own width and height (half on each side) before cropping — useful to include surrounding context (e.g. hair around a detected face); 20 makes the box 20% wider and taller. 0 (default) crops exactly to the detected box. The Boxes output already includes it, so paste back by coordinates rather than by class.
- orderstringdefault Left to Rightoptions: Left to Right, Top to Bottom, Largest First, Detection Order
Order of the crops in the list
Order of the crops in the Images list (and the lines of Boxes). 'Left to Right' (default) sorts by the box's left edge, 'Top to Bottom' by its top edge, 'Largest First' by box area, 'Detection Order' keeps the detector's order. Ties fall back to position, so the order is the same on every run.
- max_countintegerdefault 0range 0–64
Most crops to keep, first in order. 0 keeps all (up to 64).
Keeps only the first N crops in the chosen order. 0 (default) keeps them all, up to 64; a photo with more detections keeps the first 64.
Tags
Alternatives in Selection & Extraction
- Color Pick by Class
Extract a segmentation class by name.
- Color Pick by RGB Value
Extract segmentation regions by exact RGB color.
- Image Collect
Gather separately made images into one image list, in port order.
- Image Crop by Class
Crop detected objects by class name.
- Image Crop by Coord
Crop a region from explicit bounding-box coordinates.
- Image Gate by Text
Pass or block an image based on text match.
- Image Selector
Pick first non-empty image from inputs (fallback).
- List Extract
Extract one image from an image list by index.