ComfyUI Node

Runware Ultralytics

YOLO Finds the Faces, Diffusion Fixes Them

By Runware·Created 2 years ago·Updated about a month ago· 140
Runware Ultralytics
    • ultralytics
    CFGScale8.0
    confidence0.90
    inpaintSize1024
    maskBlur5
    maskPadding5
    negativePrompt
    positivePrompt
    steps20
    strength0.30

    Bad faces are the single most common reason a good image run goes in the trash. RunwareBuild_ultralytics automates the fix: it detects faces in your generated image, crops each one, runs a diffusion pass to refine it, and stitches the result back. The name comes from the Ultralytics YOLO detector doing the finding; the builder is what wires that detector's settings into an image model. It's a Runware/Params builder - output is a ultralytics object that plugs into models exposing that socket (the Juggernaut Flux family, Qwen-Image, Z-Image, FLUX schnell, and friends).

    How it works

    This is the classic "detect → crop → regenerate → stitch" face-fix loop, the same pattern people run locally with a face detector and an inpainting pass. The flow, per the tooltip: YOLO detects faces in the full image, crops each region, scales it to the inpaintSize you set, runs diffusion on just that crop, then blends it back with a feathered mask. Everything happens on Runware's cloud, so the whole loop costs you a fraction of a cent rather than a chunk of VRAM.

    The inputs that matter

    Most of the node is optional, and three settings dominate the result:

    • inpaintSize (128–2048, default 1024) - the pixel size each face crop is scaled to before diffusion runs. The tooltip gives the honest guidance: size it so most faces land in the 2–4× range of their original pixel size. Going beyond 8× degrades identity resemblance - a huge upscale makes the model invent a face that looks like a face but not your face. This is the input to tune first.
    • strength (default 0.3) - how aggressively the refinement rewrites the region. Lower preserves the original, higher allows more reconstruction. Start at the default; crank it only if faces are genuinely broken.
    • confidence (default 0.9) - detection threshold. Faces missed? Lower it. Random patches being "refined"? Raise it.

    Beyond those: CFGScale (guidance for the face pass, default 8), steps (default 20), maskBlur (feather on the stitch, default 5), maskPadding (context around the face so hair and neck come along, default 5), and positivePrompt/negativePrompt for the refinement pass - a positive like "detailed face, sharp eyes" can help, and the negative prompt is where you'd discourage artifacts.

    Wiring it in

    Output is ultralytics (single, not stackable). Wire it into an image model's ultralytics socket. It composes fine with LoRA and ControlNet builders on the same model node - the face pass is a layer on top of whatever the base model produced.

    Install and setup

    Standard pack install: ComfyUI Manager → search "Runware" → install → restart, or clone and pip install -r ComfyUI-Runware/requirements.txt (just runware-sdk, pillow, soundfile). No local YOLO weights - the detection runs on Runware's side. You need an API key (Settings → Runware API key, RUNWARE_API_KEY, or runware auth login) and a funded account; the community's recurring gripe is the ~$20 minimum top-up with a card on file, not the per-run price.

    Troubleshooting

    • Faces get worse - your inpaintSize is probably too big relative to the source faces. Read the 2–4× guidance again and drop it.
    • Some faces never get touched - detection. Lower confidence (or check the prompt isn't confusing the detector). Faces smaller than the refinement scale often get skipped.
    • Identity drifts across a batch - that's the upscaling/refinement catch the KB hammers: every generative rung rewrites identity. The fix here is restraint - lower strength and inpaintSize, not more aggressive settings.

    It's the "I don't want to hand-mask every face" node, and it mostly delivers. The trap is thinking stronger = better; with face refinement, gentler almost always wins.

    CategoryRunware/Params

    Inputs (9)

    NameTypeDefaultDescription
    CFGScaleoptFLOAT8.00–50Face refinement guidance scale.
    confidenceoptFLOAT0.900–1Confidence threshold for detection.
    inpaintSizeoptINT1024128–2048Image size (in pixels) to use for each inpainting region. YOLO detects faces, crops the region, and scales it to this size before running diffusion. Set so most faces land in the 2–4× range of their original pixel size. Going beyond 8× may degrade identity resemblance.
    maskBluroptINT50–100Mask feathering amount. Higher values create softer transitions between the enhanced face region and surrounding areas.
    maskPaddingoptINT50–20Padding around detected face in pixels. Expands the refinement area to include surrounding context like hair and neck.
    negativePromptoptSTRINGNegative prompt for detection.
    positivePromptoptSTRINGPositive prompt for detection.
    stepsoptINT201–100Number of face refinement steps.
    strengthoptFLOAT0.30Refinement strength. Lower values preserve more of the original, higher values allow more aggressive reconstruction.

    Outputs (1)

    NameTypeDescription
    ultralyticsRUNWARE_ULTRALYTICS