TExcelTAD
Home › Computer Vision: Images to Detection, Segmentation & Tracking › Face Recognition: Embeddings, Verification and Identification

Face Recognition: Embeddings, Verification and Identification

Face detection says where a face is. Face recognition says whose it is, and it comes in two forms that are easy to confuse and are measured differently:

  • Verification (1:1). "Is this the person they claim to be?" A phone unlock or an e-gate at an airport compares the live face with one enrolled template and answers yes or no.
  • Identification (1:N). "Who is this, if anyone?" The face is compared with a gallery of NN enrolled people. In a closed set the person is known to be in the gallery; in the realistic open set the system must also be able to say "nobody I know".

Both are built on the same idea: a network maps an aligned face crop to an embedding, a vector of 128 to 512 numbers, such that photos of the same person land close together and photos of different people land far apart. Everything after the network is geometry and thresholds, and that is what this lesson builds from scratch.

Note: A face embedding used to recognise people is biometric data, a special category under GDPR Art. 9: processing it needs one of the Art. 9(2) conditions (typically explicit consent), usually a data protection impact assessment, and strict purpose limitation. The EU AI Act (Regulation (EU) 2024/1689; its prohibitions apply from 2 February 2025) bans building face databases by untargeted scraping of the internet or CCTV and the use of real-time remote biometric identification in publicly accessible spaces for law enforcement, apart from narrow exceptions (searching for specific victims or missing persons, preventing an imminent threat to life or a terrorist attack, locating suspects of serious crimes); other remote biometric identification is high-risk. Several US states (Illinois' BIPA, for example) require written consent. Read privacy, consent and licensing before you enrol a single face.

The pipeline

photoH x W x 3 detectbox + 5 points align112 x 112 crop embed (CNN)unit vector verification 1:1cos to 1 template>= t: accept identification 1:Nrank N templatesbest >= t: its idelse: unknown enrolment runs the same pipeline once per personand stores only the template vector

Each stage matters. A detector that misses or crops badly ruins everything after it. Alignment removes in-plane rotation, scale and position, so that the network sees every face in the same frame and can spend its capacity on identity. The network is trained so that a simple dot product compares two faces. And the threshold is a business decision, set from measured error rates.

Alignment with five landmarks

Modern face detectors (RetinaFace, YuNet, MTCNN) return five landmarks: the two eye centres, the nose tip and the two mouth corners. Alignment finds the similarity transform (rotation RR, uniform scale ss, translation t\mathbf{t}; four degrees of freedom) that moves the detected points pi\mathbf{p}_i closest to fixed template positions qi\mathbf{q}_i in a 112 x 112 crop:

min⁡s,R,t∑i=15∥sRpi+t−qi∥2\min_{s, R, \mathbf{t}} \sum_{i=1}^{5} \lVert s R \mathbf{p}_i + \mathbf{t} - \mathbf{q}_i \rVert^2

A similarity transform, not a full affine one: it must not shear or squash a face, because face shape is part of identity. The least-squares solution (Umeyama, 1991) comes from an SVD of the covariance between the centred point sets, as in the SVD lesson and geometric transformations. Below it is written from scratch, tested on landmarks with a known rotation and scale, compared with OpenCV's estimateAffinePartial2D, and then used with only the two eye centres from the eye cascade to align the astronaut's face.

python · try it yourself
import numpy as np
import cv2
from skimage import data
cv2.setLogLevel(0)

# Landmark template of the 112 x 112 crops used by ArcFace-style models (image-left eye, image-right eye, nose,
# image-left mouth corner, image-right mouth corner), in pixels
TEMPLATE = np.array([[38.2946, 51.6963], [73.5318, 51.5014], [56.0252, 71.7366],
                     [41.5493, 92.3655], [70.7299, 92.2041]])

def similarity(src, dst):
    """Least-squares s, R, t with dst ~ s R src + t (Umeyama), returned as a 2 x 3 matrix."""
    mu_s, mu_d = src.mean(axis=0), dst.mean(axis=0)
    a, b = src - mu_s, dst - mu_d
    U, S, Vt = np.linalg.svd(b.T @ a / len(src))
    D = np.diag([1.0, np.sign(np.linalg.det(U @ Vt))])     # forbid a reflection
    R = U @ D @ Vt
    s = np.trace(np.diag(S) @ D) / a.var(axis=0).sum()
    t = mu_d - s * R @ mu_s
    return np.hstack([s * R, t[:, None]])

def apply(M, pts):
    return pts @ M[:, :2].T + M[:, 2]

# "Detected" landmarks: the template turned by 25 degrees, scaled 2.4 times, shifted, with 1.5 px noise
rng = np.random.default_rng(0)
a = np.deg2rad(25)
rot = np.array([[np.cos(a), -np.sin(a)], [np.sin(a), np.cos(a)]])
photo = 2.4 * TEMPLATE @ rot.T + [300, 120] + rng.normal(0, 1.5, (5, 2))

M = similarity(photo, TEMPLATE)
scale, angle = np.hypot(M[0, 0], M[1, 0]), np.degrees(np.arctan2(M[1, 0], M[0, 0]))
err = np.linalg.norm(apply(M, photo) - TEMPLATE, axis=1)
print(f"recovered scale {scale:.3f} (true 1/2.4 = {1 / 2.4:.3f}), angle {angle:.1f} degrees (true -25)")
print(f"landmark error after alignment: mean {err.mean():.2f} px, max {err.max():.2f} px")
M_cv, _ = cv2.estimateAffinePartial2D(photo, TEMPLATE, method=cv2.LMEDS)
print(f"largest difference to cv2.estimateAffinePartial2D: {np.abs(M - M_cv).max():.3f}")

# Real image: the two eye centres from the eye cascade (face-detection lesson) mapped onto the template's eyes
eyes = np.array([[187 + 29 / 2, 86 + 29 / 2], [232 + 29 / 2, 89 + 29 / 2]])     # image-left, image-right
M2 = similarity(eyes, TEMPLATE[:2])
crop = cv2.warpAffine(data.astronaut(), M2, (112, 112), borderMode=cv2.BORDER_REPLICATE)
tilt = np.degrees(np.arctan2(eyes[1, 1] - eyes[0, 1], eyes[1, 0] - eyes[0, 0]))
print(f"eye line in the photo tilted {tilt:.1f} degrees; aligned crop {crop.shape}, eyes now at",
      apply(M2, eyes).round(1).tolist())
recovered scale 0.420 (true 1/2.4 = 0.417), angle -24.8 degrees (true -25)
landmark error after alignment: mean 0.59 px, max 0.84 px
largest difference to cv2.estimateAffinePartial2D: 0.000
eye line in the photo tilted 3.8 degrees; aligned crop (112, 112, 3), eyes now at [[38.3, 51.7], [73.5, 51.5]]

The SVD solution recovers the scale (0.420 against the true 0.417) and the angle (-24.8 degrees against -25) from five noisy points, and leaves a mean landmark error of 0.59 pixels, which is the 1.5-pixel noise averaged down; OpenCV's estimator gives the same matrix to three decimals. On the real photo the eye line is tilted by 3.8 degrees; after the warp both eyes sit exactly on the template's eye positions in a 112 x 112 crop. With two points a similarity transform fits exactly (four equations, four unknowns), so two eyes are enough to align, and the other three landmarks make the fit robust to one bad point.

Embeddings and cosine similarity

The recognition network ends with an embedding e∈Rd\mathbf{e} \in \mathbb{R}^d that is divided by its length, so every face is a point on the unit sphere (∥e∥=1\lVert \mathbf{e} \rVert = 1). Two faces are compared by cosine similarity, which for unit vectors is the dot product and is tied to the Euclidean distance:

s(e1,e2)=e1⊤e2=cos⁡θ,∥e1−e2∥2=2−2cos⁡θs(\mathbf{e}_1, \mathbf{e}_2) = \mathbf{e}_1^{\top} \mathbf{e}_2 = \cos \theta, \qquad \lVert \mathbf{e}_1 - \mathbf{e}_2 \rVert^2 = 2 - 2 \cos \theta

So "small distance" and "high cosine" are the same ranking. Scores of pairs of the same person are called genuine, scores of different people impostor. Verification accepts when s≥ts \ge t, and its two error rates are:

FAR(t)=#{impostor pairs with s≥t}#{impostor pairs},FRR(t)=#{genuine pairs with s<t}#{genuine pairs}\text{FAR}(t) = \frac{\#\{\text{impostor pairs with } s \ge t\}}{\#\{\text{impostor pairs}\}}, \qquad \text{FRR}(t) = \frac{\#\{\text{genuine pairs with } s < t\}}{\#\{\text{genuine pairs}\}}

The false accept rate (FAR, in standards also false match rate, FMR) is the security risk, the false reject rate (FRR, false non-match rate) the annoyance. Raising tt trades one for the other; the equal error rate (EER) is where they meet. They are exactly the false-positive rate and one minus the recall of ROC and PR curves, with genuine pairs as positives. Genuine pairs are rare (with 100 people and 5 photos each there are 1,000 genuine and 123,750 impostor pairs), so set the share of positives low and look at the left end of the ROC curve:

05010005scorecountScores by true classpositive →← negativenegativepositivepredicted +predicted −actual posactual neg52TP48FN21FP879TNprecision 0.712 recall 0.520 F1 0.6010.00.51.00.00.51.0false positive rateTPRROC curveAUC 0.921- - chance0.00.51.00.00.51.0recallprecisionPrecision-recallAP 0.664- - chance

In the lab, FAR is the false-positive rate (impostors right of the threshold) and FRR is 1−recall1 - \text{recall}. Move the threshold right and FAR falls while FRR rises; increase the separation dd (a better embedding network) and both fall. Real systems are quoted as "FRR at FAR = 10−410^{-4}" or "TAR (true accept rate, 1−FRR1 - \text{FRR}) at FAR = 10−610^{-6}", far out on the left of that curve, where a few hundred thousand impostor pairs are needed just to measure the rate.

No face recognition model is available offline here, so the next example uses synthetic embeddings: each of 100 identities gets a random centre on the 128-d unit sphere, and each photo is that centre plus Gaussian noise (pose, light, expression, age), renormalised. The numbers are therefore illustrative; the code is exactly what you would run on real embeddings.

python · try it yourself
import numpy as np

rng = np.random.default_rng(0)
n_ids, per_id, d = 100, 5, 128

def unit(v):
    return v / np.linalg.norm(v, axis=-1, keepdims=True)

centres = unit(rng.normal(size=(n_ids, d)))
emb = unit(np.repeat(centres, per_id, axis=0) + rng.normal(0, 0.13, (n_ids * per_id, d)))
ids = np.repeat(np.arange(n_ids), per_id)

S = emb @ emb.T                                         # all cosine similarities
iu = np.triu_indices(len(emb), k=1)                     # each pair once
scores, same = S[iu], (ids[:, None] == ids[None, :])[iu]
gen, imp = scores[same], scores[~same]
print(f"{len(gen)} genuine pairs: mean {gen.mean():.3f}, min {gen.min():.3f}")
print(f"{len(imp)} impostor pairs: mean {imp.mean():.3f}, max {imp.max():.3f}")

print(" t     FAR       FRR")
for t in [0.15, 0.20, 0.25, 0.30, 0.35]:
    print(f"{t:.2f}  {np.mean(imp >= t):.6f}  {np.mean(gen < t):.4f}")

ts = np.linspace(0, 1, 2001)
far = np.array([np.mean(imp >= t) for t in ts]); frr = np.array([np.mean(gen < t) for t in ts])
k = np.argmin(np.abs(far - frr))
print(f"EER about {(far[k] + frr[k]) / 2:.4f} at t = {ts[k]:.3f}")
t3 = np.quantile(imp, 1 - 1e-3)                         # threshold for FAR = 0.001
print(f"threshold for FAR = 0.001: t = {t3:.3f}, FRR there = {np.mean(gen < t3):.4f}")
1000 genuine pairs: mean 0.317, min 0.064
123750 impostor pairs: mean -0.000, max 0.352
 t     FAR       FRR
0.15  0.045406  0.0110
0.20  0.012040  0.0530
0.25  0.002117  0.1900
0.30  0.000283  0.3970
0.35  0.000016  0.6730
EER about 0.0266 at t = 0.172
threshold for FAR = 0.001: t = 0.271, FRR there = 0.2680

These synthetic embeddings behave like a mediocre real model. Genuine pairs average a cosine of 0.317, impostor pairs 0.000 (random directions in 128 dimensions are nearly orthogonal), but the two tails overlap: the worst genuine pair scores 0.064 and the best impostor 0.352. The table is the trade-off: at t=0.20t = 0.20 about 1.2 % of impostor pairs are accepted and 5.3 % of genuine pairs rejected; at 0.30 FAR drops to 0.03 % while FRR rises to 39.7 %. The EER is about 2.7 % at t=0.172t = 0.172, and a security target of FAR = 0.001 needs t=0.271t = 0.271, where 26.8 % of genuine attempts fail. Note how few impostor pairs sit above the strict thresholds: FAR = 0.000016 is 2 pairs out of 123,750, so FAR estimates below about 10−410^{-4} need far larger test sets.

Identification: ranking a gallery

Identification compares a probe with all NN gallery templates and ranks them. In a closed set the measure is rank-1 accuracy (is the best match the right person?) and more generally the CMC curve, rank-kk accuracy, which person re-identification uses too. In an open set the best match is accepted only if its score passes a threshold tt, and two rates replace FAR and FRR: the detection and identification rate (DIR: enrolled probes whose best match is correct and above tt) and the false positive identification rate (FPIR: probes of people not in the gallery who are matched to someone anyway).

A large gallery makes identification much harder than verification. If a single comparison falsely matches with probability FAR, a probe of an unknown person compared with NN independent templates is falsely matched to someone with probability

FPIR≈1−(1−FAR)N≈N⋅FARfor small N⋅FAR\text{FPIR} \approx 1 - (1 - \text{FAR})^{N} \approx N \cdot \text{FAR} \quad \text{for small } N \cdot \text{FAR}

A FAR of 10−410^{-4}, fine for a phone, means about 1 false hit for every 10 strangers checked against a watch list of 1,000 people. This is why the threshold for 1:N search must be far stricter, and why "the system found a match" is a lead for a human to check, never a proof.

python · try it yourself
import numpy as np

rng = np.random.default_rng(0)
n_ids, per_id, d = 100, 5, 128

def unit(v):
    return v / np.linalg.norm(v, axis=-1, keepdims=True)

centres = unit(rng.normal(size=(n_ids, d)))
emb = unit(np.repeat(centres, per_id, axis=0) + rng.normal(0, 0.13, (n_ids * per_id, d)))
ids = np.repeat(np.arange(n_ids), per_id)

enrolled = np.arange(80)                                # identities 80..99 are strangers
first = np.arange(n_ids) * per_id
gallery, g_ids = emb[first[enrolled]], enrolled         # one template per enrolled person
probe_mask = np.ones(len(emb), bool); probe_mask[first] = False
probes, p_ids = emb[probe_mask], ids[probe_mask]
known = p_ids < 80

S = probes @ gallery.T
best = S.argmax(axis=1); best_score = S.max(axis=1)
print(f"closed set: {known.sum()} probes of enrolled people, rank-1 accuracy {np.mean(g_ids[best[known]] == p_ids[known]):.3f}")
print(f"open set: {(~known).sum()} probes of strangers")
print(" t     DIR    FPIR")
for t in [0.20, 0.25, 0.30, 0.35]:
    dir_ = np.mean((g_ids[best[known]] == p_ids[known]) & (best_score[known] >= t))
    fpir = np.mean(best_score[~known] >= t)
    print(f"{t:.2f}  {dir_:.3f}  {fpir:.3f}")

far = 1e-4
for N in [1, 100, 1000, 100000]:
    print(f"FAR {far:g} per comparison, gallery {N:6d}: FPIR {1 - (1 - far) ** N:.4f}")
closed set: 320 probes of enrolled people, rank-1 accuracy 0.887
open set: 80 probes of strangers
 t     DIR    FPIR
0.20  0.878  0.600
0.25  0.797  0.175
0.30  0.613  0.000
0.35  0.331  0.000
FAR 0.0001 per comparison, gallery      1: FPIR 0.0001
FAR 0.0001 per comparison, gallery    100: FPIR 0.0100
FAR 0.0001 per comparison, gallery   1000: FPIR 0.0952
FAR 0.0001 per comparison, gallery 100000: FPIR 1.0000

With one template per enrolled person, 88.7 % of the 320 probes of enrolled people find the right person at rank 1. The open-set table shows why the threshold is needed: at t=0.20t = 0.20, 60 % of the 80 strangers would be "recognised" as someone on the list. At 0.30 no stranger is matched, but only 61.3 % of enrolled probes are identified. The last lines are the formula for growing galleries: a FAR of 10−410^{-4} per comparison becomes a 1 % false-hit rate per search against 100 people, 9.5 % against 1,000, and a near-certain false hit against 100,000.

Training the embedding: margins on the sphere

A face network is trained as a classifier over the training identities (tens of thousands to millions of people), then the classifier head is thrown away and the layer before it is the embedding. Plain softmax cross-entropy separates the training identities but does not make the clusters tight, so face models add a margin. With unit embeddings e\mathbf{e} and unit class weights wj\mathbf{w}_j, the logit of class jj is scos⁡θjs \cos \theta_j, and ArcFace (2019) adds an angle mm to the true class yy only:

L=−log⁡escos⁡(θy+m)escos⁡(θy+m)+∑j≠yescos⁡θjL = -\log \frac{e^{s \cos(\theta_y + m)}}{e^{s \cos(\theta_y + m)} + \sum_{j \ne y} e^{s \cos \theta_j}}

with typical values s=64s = 64 and m=0.5m = 0.5 radians. The network is only rewarded when the face is closer to its own class by a margin, which squeezes each identity into a small cap on the sphere. CosFace subtracts mm from the cosine instead, SphereFace multiplies the angle. The alternative family trains on pairs or triplets directly (contrastive and triplet losses): FaceNet (2015) used a triplet loss on 128-d embeddings. The effect of the margin on one training face:

python · try it yourself
import numpy as np

def arcface_loss(cos, y, s=64.0, m=0.5):
    theta = np.arccos(np.clip(cos, -1, 1))
    logits = s * cos.copy()
    logits[y] = s * np.cos(theta[y] + m)
    p = np.exp(logits - logits.max()); p /= p.sum()
    return -np.log(p[y]), p[y]

# cosine of one training face to its own class (index 0) and to three other identities
faces = {"loose face": np.array([0.70, 0.50, 0.10, -0.20]), "tight face": np.array([0.95, 0.50, 0.10, -0.20])}
for name, cos in faces.items():
    for m in [0.0, 0.2, 0.5]:
        loss, p = arcface_loss(cos, 0, m=m)
        print(f"{name}, margin {m:.1f}: p(true class) {p:.4f}, loss {loss:.2e}")
loose face, margin 0.0: p(true class) 1.0000, loss 2.76e-06
loose face, margin 0.2: p(true class) 0.9441, loss 5.75e-02
loose face, margin 0.5: p(true class) 0.0000, loss 1.46e+01
tight face, margin 0.0: p(true class) 1.0000, loss 3.11e-13
tight face, margin 0.2: p(true class) 1.0000, loss 5.53e-11
tight face, margin 0.5: p(true class) 1.0000, loss 7.69e-06

Without a margin the loose face (cosine 0.70 to its class, 0.50 to the nearest other) is already classified with probability 1.0000 at scale s=64s = 64, so its loss is 2.8×10−62.8 \times 10^{-6} and it would barely move the weights. With m=0.2m = 0.2 its loss is 0.058, and with m=0.5m = 0.5 it is 14.6: its angle to its own class plus 0.5 radians is larger than its angle to the other identity, so the network is pushed hard to pull it in. The tight face (cosine 0.95) still has a tiny loss even with m=0.5m = 0.5. The margin spends the training signal on faces that are correct but not clearly correct.

A recorded sanity check with a generic network

ResNet-18 trained on ImageNet is not a face model, but its 512-d average-pooled features show what an embedding does. The recorded example crops the astronaut's face, makes changed versions of the same crop (mirror, darker, shifted, rotated), and compares their cosine similarity with that of unrelated crops.

python · try it yourself
import numpy as np
import cv2
import torch
from torchvision.models import resnet18, ResNet18_Weights
from skimage import data

torch.manual_seed(0)
weights = ResNet18_Weights.IMAGENET1K_V1
net = resnet18(weights=weights).eval()
net.fc = torch.nn.Identity()                                  # keep the 512-d pooled features
mean, std = np.array([0.485, 0.456, 0.406]), np.array([0.229, 0.224, 0.225])

def embed(rgb_crops):
    x = np.stack([cv2.resize(c, (224, 224), interpolation=cv2.INTER_AREA) / 255.0 for c in rgb_crops])
    x = torch.tensor(((x - mean) / std).transpose(0, 3, 1, 2), dtype=torch.float32)
    with torch.no_grad():
        e = net(x).numpy()
    return e / np.linalg.norm(e, axis=1, keepdims=True)

astro = data.astronaut()
face = astro[46:181, 157:292]                                 # the face box with a 20 px margin
M = cv2.getRotationMatrix2D((67, 67), 15, 1.0)
variants = {"mirror": face[:, ::-1], "darker x0.6": (face * 0.6).astype(np.uint8),
            "shift 10 px": astro[56:191, 167:302], "rotate 15": cv2.warpAffine(face, M, (135, 135), borderMode=cv2.BORDER_REPLICATE)}
others = {"astronaut flag": astro[300:435, 350:485], "cat face": data.chelsea()[20:200, 90:270],
          "coffee cup": data.coffee()[50:300, 200:450], "rocket": data.rocket()[100:300, 250:450]}
E = embed([face] + list(variants.values()) + list(others.values()))
names = list(variants) + list(others)
for name, s in zip(names, E[1:] @ E[0]):
    print(f"{name:15s} cosine to the face crop: {s:.3f}")
mirror          cosine to the face crop: 0.975
darker x0.6     cosine to the face crop: 0.978
shift 10 px     cosine to the face crop: 0.951
rotate 15       cosine to the face crop: 0.927
astronaut flag  cosine to the face crop: 0.696
cat face        cosine to the face crop: 0.509
coffee cup      cosine to the face crop: 0.558
rocket          cosine to the face crop: 0.529

Every changed copy of the face scores between 0.927 (rotated by 15 degrees) and 0.978 (darker), and every unrelated crop scores 0.509 to 0.696, the highest being another part of the same photo (same light and colours). So the generic features are fairly invariant to small changes and separate a face from a cat or a cup. Whether they separate one person from another cannot be tested here (there is one face), and in practice they do not do it well: ImageNet never asked the network to tell people apart.

A real face model would have been trained so that photos of the same person taken years apart score higher than two different people photographed in the same light, which generic ImageNet features are not. Taking a model like that to production looks like this (OpenCV's SFace model, not run here):

python
# Not run here: needs the YuNet detector and SFace recogniser ONNX files (downloads from the OpenCV model zoo)
import cv2

detector = cv2.FaceDetectorYN.create("face_detection_yunet_2023mar.onnx", "", (0, 0))
recogniser = cv2.FaceRecognizerSF.create("face_recognition_sface_2021dec.onnx", "")

def template(bgr):
    detector.setInputSize((bgr.shape[1], bgr.shape[0]))
    _, faces = detector.detect(bgr)
    aligned = recogniser.alignCrop(bgr, faces[0])          # similarity transform from the 5 landmarks, 112 x 112
    return recogniser.feature(aligned)                     # 128-d embedding

score = recogniser.match(template(img1), template(img2), cv2.FaceRecognizerSF_FR_COSINE)
same_person = score >= 0.363       # the threshold suggested in OpenCV's sample; set your own from measured FAR

Bias, accuracy claims and the law

  • Demographic differentials. NIST's Face Recognition Vendor Test (FRVT, now FRTE) part 3 (2019) measured 189 algorithms from 99 developers and found demographic differentials in most of them: false match rates for some groups were often higher by factors of 10 to beyond 100 (NISTIR 8280), with large differences between vendors. A single global threshold therefore gives some groups far more false matches. Measure FAR and FRR per group on data that matches the deployment, and report the worst group, not the average.
  • Image quality dominates. Benchmark accuracies on frontal, well-lit photos (some above 99.8 % on LFW) do not transfer to CCTV frames at 30 pixels between the eyes.
  • Consent and purpose. Enrolment should be opt-in, with a simple way to withdraw and have the template deleted. Templates are not "anonymous": they can be matched against other databases.
  • The law. Under GDPR Art. 9 biometric data for identification is special-category data; the EU AI Act prohibits untargeted scraping of facial images, emotion recognition in workplaces and schools, and (with narrow exceptions) real-time remote biometric identification in publicly accessible spaces for law enforcement, and treats most other remote biometric identification as high-risk. Check the rules where you deploy; this paragraph is orientation, not legal advice.

Pitfalls

  • Skipping alignment, or aligning with a different template from the one the model was trained with. Embeddings of misaligned crops drift, and FRR rises sharply.
  • Comparing unnormalised embeddings with a dot product: scores then depend on image quality (vector length), not identity.
  • Choosing the threshold on the test set, or from a vendor datasheet. Set it on a validation set from your own cameras for a target FAR, then report FAR and FRR on a separate test set.
  • Quoting verification numbers for an identification system. With a gallery of NN people the false-match risk per search grows roughly NN-fold.
  • Identity leakage between splits. Photos of the same person must not appear in both training and test sets (split by identity, see split strategies).
  • Averages that hide groups. One EER for everyone can hide a tenfold FAR difference between groups.

Practice

  1. Two unit embeddings have cosine similarity 0.6. What is their Euclidean distance?
Answer

∥e1−e2∥2=2−2⋅0.6=0.8\lVert \mathbf{e}_1 - \mathbf{e}_2 \rVert^2 = 2 - 2 \cdot 0.6 = 0.8, so the distance is 0.8≈0.894\sqrt{0.8} \approx 0.894.

  1. In the identification example, why does DIR fall when tt rises, even for probes whose best match is correct?
Answer

DIR counts a probe only if the best match is correct and its score passes tt. A higher threshold rejects more correct but weak matches (bad photos), so DIR falls while FPIR falls too. The threshold is picked for an acceptable FPIR, and DIR is what you get there.

  1. A border e-gate checks 10,000 travellers a day against their own passport photo, at FAR 10−510^{-5} and FRR 0.02. How many impostors would get through per day if 10 impostors tried, and how many genuine travellers are sent to a human officer?
Answer

Impostors accepted: 10×10−5=10−410 \times 10^{-5} = 10^{-4} per day, about one every 27 years at that attack rate. Genuine travellers rejected: 10,000×0.02=20010{,}000 \times 0.02 = 200 per day, who need a manual check. The FRR is what drives staffing; the FAR what drives security.

Test yourself

Unlocking a phone with your face is ...

  1. identification (1:N)
  2. verification (1:1): the live face is compared with one enrolled template
  3. face detection only
  4. re-identification

Why is the alignment step a similarity transform rather than a full affine transform?

  1. Affine transforms are slower
  2. A similarity (rotation, uniform scale, shift) preserves the face's shape; shear or non-uniform scale would change the proportions that carry identity
  3. OpenCV has no affine warp
  4. Similarity transforms need no landmarks

A watch list holds 1,000 people and each comparison has FAR 10−410^{-4}. Roughly what share of strangers will be matched to someone?

  1. 0.01 %
  2. About 10 %
  3. 50 %
  4. None, the FAR is tiny

What does the ArcFace margin mm do during training?

  1. It normalises the images
  2. It makes the true class's logit scos⁡(θy+m)s \cos(\theta_y + m) smaller, so the network must pull each face closer to its own class to get the same loss
  3. It removes the softmax
  4. It sets the verification threshold

Your system's overall FAR is 10−410^{-4}, but for one demographic group it is 10−310^{-3}. What should you do?

  1. Report the overall number; it is the average
  2. Report per-group rates, set the threshold so the worst group meets the target, and investigate the data or model
  3. Remove the group from the test set
  4. Ignore it, FAR is small anyway