ComfyUI Node

Face Similarity

Finally, a number for 'does that actually look like them?'

By chflame163·Created 2 years ago·Updated about a year ago· 41
Face Similarity
  • image1
  • image2
  • similarity
◄detect_method▾►

Every face-consistency workflow - a character LoRA, IP-Adapter FaceID, InstantID, PuLID, pick your poison - ends the same way: you stare at two images and ask "is that close enough?" Eyeballing likeness is how everyone does it, and it's unreliable, because your eye lies to you after the fortieth generation. This node is the antidote: feed it two images, get one float from 0 to 100 that says how similar the two faces are. The author's rule of thumb: past 50, it's very similar. That's the whole pitch, and for a utility node, it does exactly what it says.

It's from chflame163, the same person behind ComfyUI_LayerStyle - the install README is literally copy-pasted from that pack, including a leftover reference to a "ComfyUI_LayerStyle plugin directory." Once you know the 😺dzNodes category, you know the author. This is a small side tool from a well-known developer, not some abandoned weekend repo, and it shows: it's dead simple and it works.

How it works

No AI model downloads, no API, no key. Under the hood it wraps the face_recognition library, which is dlib in a trench coat. For each image it:

  1. Finds the face with dlib's HOG face detector (face_locations)
  2. Extracts a 128-dimensional face embedding (face_encodings)
  3. Measures the Euclidean distance between the two embeddings (face_distance)
  4. Turns that into your score: (1 - distance) * 100, rounded to two decimals

So the score is a recognition distance, the same biometric trick that powers face-ID check-ins. That's a strength and a trap, and the trap deserves a paragraph.

The inputs that matter

Only three, and two of them are images:

  • image1 / image2 - the two IMAGE tensors to compare. Wire in whatever you're validating: a generated output vs. the reference, two renders from a LoRA, a training candidate vs. the source set.
  • detect_method - a dropdown with exactly one option, face_recognition. It's a placeholder for future methods, not a real choice. Don't go looking for a better setting; there isn't one yet.

The output is a single similarity FLOAT, and the node is marked as an output node, so the number just appears in the UI when the workflow runs. That's it. There's nothing to wire the result into - it's a verdict, not a value to feed downstream.

Installing it (read this before you hit issues)

Easiest path: ComfyUI Manager → search "FaceSimilarity" → install, restart. Manual path is the usual cd ComfyUI/custom_nodes && git clone https://github.com/chflame163/ComfyUI_FaceSimilarity then restart.

The real install story is dlib, and this is where people get burned. face_recognition needs dlib, and dlib is notoriously miserable to build from source - it needs CMake and a working C++ toolchain. The author knows, which is why the pack ships prebuilt Windows wheels:

..\..\..\python_embeded\python.exe -m pip install .\whl\dlib-19.24.1-cp311-cp311-win_amd64.whl

That's for the official portable package with Python 3.11; there's a cp310 wheel for 3.10.x too. Then install the rest:

..\..\..\python_embeded\python.exe -m pip install -r requirements.txt

requirements.txt pulls torch, numpy, opencv-contrib-python, and face-recognition. Note that those dlib wheels are Windows-only - on Linux or macOS, pip will try to compile dlib from source and you'll need cmake and a compiler installed first (sudo apt install build-essential cmake on Debian/Ubuntu, or just brew install cmake on macOS). People do get through it; just know it's the entire difficulty of this pack.

Where it bites

  • No face found → hard error. If either image has no detectable face, the node crashes (it blindly grabs [0] from the face list). Cartoon faces, heavy occlusion, tiny or side-profile faces - dlib's HOG detector is 2017 tech and it will fail on all of those. Feed it clean, front-facing crops.
  • Multiple faces? Only the first counts. If an image has several faces, it compares whichever the detector finds first. Crop before you compare.
  • It measures identity, not look-alikeness. This is the big conceptual trap. The embedding encodes biometric identity, so the same person in wildly different lighting, angle, or art style - say, a photo vs. an anime render - will score poorly even when it's "obviously" the same person. Conversely it has no opinion on hair, makeup, or expression. It's a sanity check for "same person," not a perceptual quality metric. Use it to gate your batch, then trust your eyes for the aesthetic call.

Is it essential? No. Is it worth two minutes of install time? If you do any face-consistency work at all - yes, because "close enough" stops being a feeling and becomes a number you can fail against.

Category😺dzNodes/FaceSimilarity

Inputs (3)

NameTypeDefaultDescription
image1IMAGE—
image2IMAGE—
detect_methodCOMBO1 options: face_recognition

Outputs (1)

NameTypeDescription
similarityFLOAT—