ComfyUI Node

Draw KPS

Placing your own face keypoints when detection won't cooperate

By nosiu·Created 3 years ago·Updated about a year ago· 264
Draw KPS
  • kps
  • image_reference
  • kps_data
width1024
height1024

This is the manual override for everything InstantID normally figures out automatically. Instead of running insightface's face detection to locate the five landmark points it needs (eyes, nose, mouth corners), you place them yourself, by hand, on a canvas. It exists for two situations: you keep hitting "No face detected in pose image" and detection just isn't going to work for your source, or you're not starting from a photo at all - you're generating a person purely from a text prompt and need to tell InstantID where the face should even go.

Why you'd want this over automatic detection

Face detection fails at extreme angles - insightface can't reliably find landmark positions on a face rotated far enough off-axis, and when that happens, whatever AngleFromFace or PreprocessImage tries to compute downstream will be wrong or simply error out. Drawing KPS yourself sidesteps that failure mode entirely, at the cost of doing it by hand. It's also the only way to do pure text-to-image generation with this pack - since v0.1.0 you're no longer required to swap a face into an existing photo; you can place KPS wherever you want a face to appear and generate from a prompt alone.

How you actually use it

Click and drag the five points around on the canvas. The shortcuts, straight from the README: Ctrl+drag to move a point, Ctrl+wheel to zoom the canvas, Alt+wheel to adjust how far the other four points sit from the blue point (the nose). Once you've placed them where you want, the node shows you the angle by which the image would need to rotate to align that face - useful context even if you're not feeding it into a rotation step.

One detail worth knowing: each keypoint's opacity is individually adjustable. Lowering a point's opacity weakens its influence on generation without removing it - the README's example is deliberately fading a point to make room for something like glasses, trading a little likeness for the accessory actually reading correctly.

The inputs and outputs that matter

  • image_reference (optional) - a background image to draw against, so you can align KPS visually to something real instead of guessing blind. If you provide this, the node's own width/height fields get disabled and the output takes the reference image's dimensions instead.
  • width / height (both default 1024) - canvas size, only relevant when there's no image_reference.

Output: kps_data (KPS_DATA), which goes to KpsMaker to become an actual control image, or through KpsRotate/KpsScale/KpsCrop first if you need to transform it further.

Install

ComfyUI Manager: search comfyui-instantId-faceswap, or git clone https://github.com/nosiu/comfyui-instantId-faceswap into custom_nodes/ and pip install -r requirements.txt. No model download needed for this node specifically - it's a pure UI/canvas tool, no insightface or InstantID weights required to use it.

Common issues & troubleshooting

You've hit "No face detected in pose image" repeatedly. This is exactly the situation this node solves. Rather than continuing to fight pad and mask size on PreprocessImage/AngleFromFace, switch to drawing KPS by hand here - it's slower per-image but deterministic.

Points feel finicky to position precisely. Use image_reference if you have any real photo to align against, even a rough one - dragging points against a blank canvas at the right proportions is much harder than eyeballing them against an actual face.

Old saved workflows don't carry KPS positions. As of v0.1.1, drawn KPS positions are saved into the workflow itself, which wasn't true before - if you're opening an older saved graph, you may need to redraw.

CategoryInstantId Faceswap

Inputs (4)

NameTypeDefaultDescription
widthINT10240–16384
heightINT10240–16384
kpsHIDDEN_STRING_JSON
image_referenceoptIMAGE

Outputs (1)

NameTypeDescription
kps_dataKPS_DATA