Nodes/ComfyUI-QwenImageWanBridge/Qwen Smart Crop (Experimental)
ComfyUI Node

Qwen Smart Crop (Experimental)

Auto face-cropping that can lean on the Qwen VLM (experimental)

By fblissjr·Created 12 months ago·Updated 4 months ago· 188
Qwen Smart Crop (Experimental)
  • image
  • vlm_context
  • cropped_image
  • info
  • debug_viz
detection_modeauto_fallback
padding0.20
output_squaretrue
square_anchorface_headshot
min_crop_size256
vlm_promptLocate the primary face in this image. Report the bbox coordinates in JSON format.
vlm_max_tokens100
vlm_temperature0.10
vlm_top_p0.95
debug_modefalse

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 on auto_fallback; it degrades gracefully. Reach for vlm_detect only 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_headshot by default).
  • vlm_context (optional) - the handle to a loaded Qwen VLM, required if you want vlm_detect to 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 ManagerComfyUI-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.

CategoryQwenImage/Experimental

Inputs (12)

NameTypeDefaultDescription
imageIMAGEInput image to crop
detection_modeCOMBOauto_fallbackDetection 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
paddingFLOAT0.200–1Padding around detected region (0.2 = 20% expansion)
output_squareBOOLEANtrueForce output to square aspect ratio
square_anchorCOMBOface_headshotWhen 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_sizeINT25664–2048Minimum crop dimension in pixels
vlm_contextoptVLM_CONTEXTRequired for vlm_detect mode - connect from shrug-prompter
vlm_promptoptSTRINGLocate 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_tokensoptINT10010–500Max tokens for VLM response (bbox should be short)
vlm_temperatureoptFLOAT0.100–2VLM temperature (lower = more deterministic bbox)
vlm_top_poptFLOAT0.950–1VLM top_p sampling
debug_modeoptBOOLEANfalseOutput debug visualization

Outputs (3)

NameTypeDescription
cropped_imageIMAGE
infoSTRING
debug_vizIMAGE