Qwen Smart Crop (Experimental)
Auto face-cropping that can lean on the Qwen VLM (experimental)
- image
- vlm_context
- cropped_image
- info
- debug_viz
QwenSmartCrop takes an image and crops it down to the face - or to whatever the "important" region is - with a handful of detection strategies to choose from. The party trick is that one of those strategies (vlm_detect) can reuse the Qwen vision-language model you already have loaded to find the face by asking it, instead of running a separate face detector. That's a neat idea. It's also, in the author's own words on the node, "experimental - not production ready," so calibrate accordingly: this is a fun thing to poke at, not a step to hang a batch job on.
Where it fits: face cropping is a routine chore in identity and character work. Qwen-Image-Edit famously drifts on faces - users report inpainting the face back after an edit - and any face-fix pass wants a clean, square, centered crop of the head to work on. Normally you'd reach for a dedicated face-detection node. QwenSmartCrop tries to fold that into the Qwen ecosystem, and to let the VLM do the locating when the classic detectors don't.
How it works
You pick a detection_mode and the node finds a region, pads it, and (optionally) squares it off. The modes range from dumb-but-reliable to clever-but-flaky: center_square just takes the middle, portrait_auto and saliency_crop use heuristics, vlm_detect asks the vision model for a bounding box in JSON, and auto_fallback (the default) tries the smart routes and drops back to a safe one if they fail. The vlm_detect path is why there's a whole cluster of vlm_* inputs - they're the sampling settings for that model call.
The inputs and outputs that matter
image- what you're cropping.detection_mode- the strategy. Start onauto_fallback; it degrades gracefully. Reach forvlm_detectonly when you've got the VLM wired up and the heuristics are missing the face.padding(default 0.2) - how much room around the detected region. Too tight clips foreheads and chins; 0.2 is a reasonable headroom.output_square+square_anchor- force a square crop and decide what it centers on (face_headshotby default).vlm_context(optional) - the handle to a loaded Qwen VLM, required if you wantvlm_detectto actually run.
Outputs: cropped_image (the result), info (a text report of what it decided), and debug_viz (the detection drawn on the image, invaluable when a crop goes wrong).
How to install it
ComfyUI Manager → ComfyUI-QwenImageWanBridge → install → restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/fblissjr/ComfyUI-QwenImageWanBridge
then restart. The heuristic modes are self-contained; vlm_detect needs a Qwen2.5-VL model loaded and passed in via vlm_context, which is the same encoder the rest of this pack revolves around - so if you're already running a Qwen-Image-Edit graph you likely have it.
Common issues & troubleshooting
It crops the wrong thing or nothing. Look at debug_viz first - it shows you what the detector actually found. If the smart modes are whiffing, auto_fallback will still hand you a usable center crop, which is the whole point of that mode.
vlm_detect errors or returns garbage. It depends on the VLM returning clean JSON coordinates, and VLMs don't always. Lower vlm_temperature (default 0.1 is already conservative) for more deterministic boxes, and make sure vlm_context is actually connected - without it that mode has no model to ask.
It's flaky in general. It is. The node ships flagged experimental and not production-ready, and the pack as a whole is a research sandbox with breaking changes expected. For a dependable face crop in a real pipeline, a mature dedicated detector is the safer bet; use this when you want to stay inside the Qwen graph or play with VLM-driven cropping.
Inputs (12)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | Input image to crop | |
| detection_mode | COMBO | auto_fallback | Detection strategy: center_square: Simple center crop to square portrait_auto: Upper-center bias for portraits saliency_crop: Edge/variance detection vlm_detect: Use Qwen3-VL to find face (requires VLM_CONTEXT) auto_fallback: Try VLM, fall back to saliency, then geometric |
| padding | FLOAT | 0.200–1 | Padding around detected region (0.2 = 20% expansion) |
| output_square | BOOLEAN | true | Force output to square aspect ratio |
| square_anchor | COMBO | face_headshot | When making square crops, anchor to: face_headshot: Uses bbox WIDTH for square size - perfect for face crops (avoids body) top: Align to top of bbox, use full padded height (may include shoulders) center: Center on detected bbox (may include extra area) bottom: Align to bottom of bbox left/right: Align horizontally |
| min_crop_size | INT | 25664–2048 | Minimum crop dimension in pixels |
| vlm_contextopt | VLM_CONTEXT | Required for vlm_detect mode - connect from shrug-prompter | |
| vlm_promptopt | STRING | Locate the primary face in this image. Report the bbox coordinates in JSON format. | Custom VLM detection prompt for Qwen3-VL (expects JSON with bbox_2d) |
| vlm_max_tokensopt | INT | 10010–500 | Max tokens for VLM response (bbox should be short) |
| vlm_temperatureopt | FLOAT | 0.100–2 | VLM temperature (lower = more deterministic bbox) |
| vlm_top_popt | FLOAT | 0.950–1 | VLM top_p sampling |
| debug_modeopt | BOOLEAN | false | Output debug visualization |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| cropped_image | IMAGE | — |
| info | STRING | — |
| debug_viz | IMAGE | — |