ComfyUI Node
CV Embedding Match
Matches every vector in one embedding set against every vector in another, with the two metrics cv2.FaceRecognizerSF.match implements: cosine similarity and the L2 distance between L2-normalized vectors. Written as plain array maths on purpose - it needs no model file and therefore works on ANY embeddings, not just SFace: the 'CV Deep Features' backbone vectors, DNN class scores, your own descriptors. Typical use: 'query' = the faces in the scene, 'gallery' = the known people; then 'best_index' says who each query face is and 'is_match' says whether to believe it. Empty inputs give empty outputs, never an error.
CV Embedding Match
- query
- gallery
- scores
- best_index
- best_score
- is_match
- any_match
◄metriccosine similarity (higher = same)►
◄threshold0.363►
Categoryimage/CV/dnn
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| query | NPARRAY | (A, D) embeddings to identify - e.g. the faces found in the scene. A single (D,) vector is accepted as one row. | |
| gallery | NPARRAY | (B, D) known reference embeddings, same dimension D. Each query row is compared against all of them. | |
| metric | COMBO | cosine similarity (higher = same) | The two metrics cv2.FaceRecognizerSF.match implements. Cosine is a SIMILARITY (bigger is more alike, best match = maximum); normalized L2 is a DISTANCE (smaller is more alike, best match = minimum). This only chooses HOW scores are computed and compared - where the accept/reject line sits is entirely the 'threshold' input. |
| threshold | FLOAT | 0.363-1–100 | Decision threshold for 'is_match', always used: with cosine a match needs score >= threshold, with normalized L2 it needs score <= threshold. The right value depends on YOUR embeddings; as a reference, SFace's official face-identity operating points are 0.363 (cosine) and 1.128 (normalized L2), which is where the default comes from. Remember to change it when you switch metric. |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| scores | NPARRAY | (A, B) float32 score matrix, query rows x gallery columns - preview it with 'Preview CV Array' (heatmap) to see the whole comparison at once. |
| best_index | NPARRAY | (A,) int32 index of the best gallery entry for each query row (-1 when the gallery is empty). |
| best_score | NPARRAY | (A,) float32 score of that best entry. |
| is_match | NPARRAY | (A,) uint8 0/255 - whether the best score passes the threshold. Use it as labels for 'CV Draw Points' or to filter the query boxes. |
| any_match | BOOLEAN | True when at least one query row matched - branch on it with 'Basic data handling: IfElse'. |