Florence-2 Smart Region Selector (FAL API)
Florence-2 Smart Region Selector — say 'face' or 'glasses', get a mask back
- image
- mask
- mask_image
- info
- center_x
- center_y
- crop_width
- crop_height
This node is how you go from "I want to retouch the face" to a ComfyUI mask without drawing anything. It sends your image to Florence-2 through FAL's API, and you pick a region type - face, glasses, upper_body, lower_body, full_body, or object - and it returns the detected region as a mask, plus the geometry to feed the crop nodes.
The name matters: it's the smart region selector, the front end for the pack's whole crop/stitch architecture. The mask it produces can drive either path - NB2 Smart Region for the Nano Banana flow, or Smart Mask Crop for the GPT Image flow - and its info output carries shape hints that the crop nodes use to pick the right rectangle.
How it works
Florence-2 runs on FAL's servers (not locally), so this node uploads your image and gets back segmentation or a grounding bounding box. The default detection_mode = auto uses a bbox for faces and segmentation elsewhere; if segmentation grabs the wrong thing for a face, switch to grounding_bbox. The returned mask's rectangle metadata is what powers the region defaults: face → 1:1, glasses → 16:9, upper_body/lower_body → 1:1, full_body → 9:16 - those hints ride along in the info output so downstream nodes size themselves.
The inputs that matter
Required is just image and region_type. After that:
custom_text- required only whenregion_type = object; that's where you type "bra", "watch", "wheel", whatever.padding_percent(default 8) - expands the detected bbox, which feeds downstream crop sizing. Faces: 10–18; small objects: 5–12.selection_mode-largest(default, pick the biggest match) ormerge_all(union every match into one mask).return_rect_mask- off by default; toggle to get a rectangle mask instead of the raw semantic blob.upload_max_dimension(default 2048) - longest edge before upload. The tooltip's tip is practical: lower it to 1536 or 1024 if FAL closes the connection, which is a real thing that happens with huge source images.api_key/api_key_env_var- FAL key orFAL_KEYenv var.
Outputs: mask, mask_image, info, and the geometry ints (center_x, center_y, crop_width, crop_height) that let you build manual crop nodes if you want them.
The flow
NB2Florence2RegionSelector -> mask -> NB2 Smart Region -> NB2 Crop -> Nano Banana 2 -> NB2 Stitch
or for the masked path:
NB2Florence2RegionSelector -> mask -> Smart Mask Crop -> GPT Image Edit -> Smart Mask Stitch
Keys, install, gotchas
This is a FAL node, so it needs a key: paste it in api_key or set FAL_KEY before launching ComfyUI and fully restart. Key resolution order is direct api_key → env var (FAL_KEY by default) → this pack's optional config.ini → a sibling fal-flux-nodes/config.ini if you have that pack. A 401 Unauthorized from storage/auth/token on first run means the key isn't reaching the process - fix that before touching anything else. And note the pack's security reminder: the repo never stores your key, but if you paste it into a node and save the workflow yourself, it can persist in the JSON.
Install the pack once for all nodes:
cd ComfyUI/custom_nodes
git clone https://github.com/amortegui84/comfyui-inpaint-cropstitch-nb2
or search comfyui-inpaint-cropstitch-nb2 in ComfyUI Manager, restart. Want a fully local Florence path instead? The README points to kijai's ComfyUI-Florence2 - then feed its mask into NB2 Smart Region with depad_florence = True (Florence letterboxes internally, which shifts the bbox if you don't correct it).
Inputs (11)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| region_type | COMBO | face | 6 options: glasses, face, upper_body, lower_body, full_body, object |
| custom_textopt | STRING | — | |
| selection_modeopt | COMBO | largest | 2 options: largest, merge_all |
| padding_percentopt | FLOAT | 8.00–100 | — |
| return_rect_maskopt | BOOLEAN | false | — |
| api_keyopt | STRING | — | |
| api_key_env_varopt | STRING | FAL_KEY | — |
| mask_blur_percentopt | FLOAT | 0.00–100 | Soft blur applied to the returned Florence mask. |
| upload_max_dimensionopt | INT | 2048512–4096 | Downscale longest image edge before upload. Lower this if FAL closes the connection. |
| detection_modeopt | COMBO | auto | Use grounding_bbox for face if segmentation grabs the wrong region. |
Outputs (7)
| Name | Type | Description |
|---|---|---|
| mask | MASK | — |
| mask_image | IMAGE | — |
| info | STRING | — |
| center_x | INT | — |
| center_y | INT | — |
| crop_width | INT | — |
| crop_height | INT | — |