Nodes/⚗ AlchemicaSampler/⚗ Alchemica Face Match (ArcFace identity score)
ComfyUI Node

⚗ Alchemica Face Match (ArcFace identity score)

An ArcFace score for your generated faces

By Nessuno76·Created about a month ago·Updated 22 days ago· 4
⚗ Alchemica Face Match (ArcFace identity score)
  • reference
  • image
  • similarity
  • accepted
  • report
◄threshold0.45►
◄model_namebuffalo_l►

You know the loop: generate twelve variations of a character, squint at them, keep four, wonder for the rest of the week whether variation 7 was better than variation 3. This node replaces the squinting with a number.

It computes the cosine similarity between the ArcFace embeddings of a reference face and each generated face - the same metric face-recognition systems use - and returns it as a float you can gate on. Runs on the CPU via onnxruntime, so it never competes with the image model for VRAM.

Inputs and outputs

  • reference - the reference photo. Only the first image is used.
  • image - the generated image(s) to check. For a batch, you get the worst score of the batch, not the average, which is the useful behaviour: a batch is only as good as its worst face.
  • threshold - minimum similarity to accept, default 0.45. The tooltip gives the calibration: 0.45 is "same person in another pose or light", 0.60 is very strict.
  • model_name - buffalo_l by default, antelopev2 if you have it.

Outputs: similarity (FLOAT), accepted (BOOLEAN, similarity >= threshold), report (STRING). It's an output node, so it runs on every queue and prints to the console as well.

The reading scale, from the node's own header:

| Score | Meaning | |---|---| | ≥ 0.60 | very likely the same person | | 0.45–0.60 | same person, other pose / light / age | | 0.30–0.45 | doubtful, family resemblance | | < 0.30 | a different person |

Why this is worth having

It converts a taste judgement into a measurement, which is what you need the moment you're generating at volume - a character sheet, a LoRA dataset, a batch of poses for one person. Put it at the end of a graph, gate the save on accepted, and come back to a folder of faces that pass. Or run it as a pure measurement and sort the batch by score.

It's also the honest way to test whether that new LoRA or that Face Blend description is doing anything. Same seed, same prompt, one change, one number.

The grace notes, and the trap in them

The node never raises an exception, by design - a workflow that only wants images keeps working. That means it returns sentinel values instead:

  • -2 = the check couldn't run at all. insightface, or its model, is missing. The report says which.
  • -1 = no face found in the reference photo, or in the image being checked.

Both are below any sane threshold, so accepted is False - including when the check simply didn't happen. If you gate your saves on accepted and forget to install insightface, you'll get zero images and a very quiet reason why. Read the report; it spells it out.

The insightface dependency

insightface is optional for the pack, required for a real score, and it's the same dependency that IP-Adapter FaceID, InstantID and PuLID all carry - so if you already have it for those, this node just works. Model folders are looked for in ComfyUI's insightface model path, models/insightface, and ~/.insightface; if none is found, insightface downloads the model itself on first run unless you've placed one.

Two things to know. On Windows, installing insightface usually wants a C++ build toolchain, which is why so many people find it the annoying part of every face pipeline. And licensing: the insightface library is MIT, its pretrained models are not - non-commercial. Fine for a hobby and for measuring your own work; a conversation you need to have before shipping commercial output built on it.

Installing

# ComfyUI Manager: search "AlchemicaSampler"
cd ComfyUI/custom_nodes && git clone https://github.com/Nessuno76/ComfyUI-AlchemicaSampler

ComfyUI 0.36+, no pip dependencies from the pack itself, restart the server after cloning. Then, only if you want real scores:

pip install insightface onnxruntime

Common issues

Score is -2 or -1. See above: -2 is "insightface isn't there", -1 is "no face in the image". Both are in the report text.

Scores look harsh after a big restyle. ArcFace embeds identity, not style. A heavy stylisation or a half-hidden face will score below 0.45 even when a human would say it's clearly the same person. Lower the threshold and stop reading it as a verdict.

Two faces in the reference. The largest face wins. Crop the reference to the person you mean.

Category⚗ AlchemicaMente/characters

Inputs (4)

NameTypeDefaultDescription
referenceIMAGEThe reference photo (only the first image is used)
imageIMAGEThe generated image(s) to check
thresholdFLOAT0.450–1Minimum similarity to accept. 0.45 = same person in another pose/light; 0.60 = very strict
model_nameCOMBObuffalo_l2 options: buffalo_l, antelopev2

Outputs (3)

NameTypeDescription
similarityFLOAT—
acceptedBOOLEAN—
reportSTRING—