人脸识别:相似度很高,不等于确认身份
Face recognition
实现小型嵌入CNN及完整梯度,比较三元组与角度损失,检查验证阈值和未知身份拒绝。
face-recognition最像的那张脸,也可能认错了人
假设图库里只有两个人,现在来了第三个人的查询照片。最近邻搜索总能选出一个赢家。它回答的是“哪个已存向量最近”,并不能证明查询属于这两个人中的任何一个。
因此,人脸识别包含几个不同任务。验证围绕声明的身份比较一对样本:它们是不是同一个人?识别则搜索已经录入的图库。闭集测试中,每个查询都对应一个已录入身份;开放集测试必须允许回答“未录入”。在图像中找到脸属于检测,预测某种属性又是另一个任务。识别与错误类型
实际流程通常包括拍摄、检测人脸、检查图像是否可用、规范化裁剪、提取嵌入,再与注册模板比较。每一环都可能独立出错。人框检测准确率不等于身份识别准确率,较高的比较分数也不能证明摄像头拍到的是活体本人。
下面用合成图案实现完整的小型嵌入网络及其梯度,再用独立构造的分数例子演示阈值选择和未知身份拒绝。这些结果都不作为人脸识别性能报告。
先学习表示,再评估决策
从特征脸到学习嵌入,改变了什么?
Turk与Pentland在1991年的特征脸系统中,把已对齐图像表示为低维主成分空间中的坐标。若平均图像为μ,U的列为正交归一基,则表示为:
保留的方向解释训练图像的变化,不一定专门解释身份差异。光照变化也可能占据很大一部分变化量。原论文区分图像到人脸子空间的距离与到已知人脸表示的距离,并明确提到Sirovich和Kirby更早的人脸编码工作。若说“特征脸发明了所有人脸识别”,就抹去了这段历史。原始扫描论文
CVPR 2014发表的DeepFace把对齐与监督特征学习结合起来。其流程利用通用三维模型进行正面化,并使用不同位置不共享滤波器的局部连接层。训练时预测已知身份类别,前面的一个全连接层提供表示。这种设计利用了对齐后不同脸部区域具有不同局部统计特征这一条件。对齐与表示
FaceNet改为用三元组目标直接训练紧凑、单位归一化的嵌入。CVPR 2015论文描述的是紧密人脸裁剪以及尺度、平移处理,而不是DeepFace式三维正面化。其128维表示与ArcFace会议论文中的512维表示,分别是具体系统的选择,不是所有嵌入必须满足的要求。FaceNet方法、ArcFace归一化
归一化同时改变分数和梯度
设网络输出非零向量h,单位归一化得到e,此时余弦相似度就是点积。对单位向量e与g,平方欧氏距离和相似度具有精确关系:
在这些假设下,按平方距离从小到大排序,等价于按余弦相似度从大到小排序。余弦阈值t对应平方距离阈值2−2t。若偷偷换成未归一化向量,却不调整度量,这个等价关系就不成立。它也没有把相似度变成“同一身份的概率”。
若关于e的上游梯度为q,对归一化求导得:
径向分量被去掉了:给h乘一个正数不会改变方向。零向量没有方向;本例拒绝接近零的向量,而不是为它返回一个容易误解的分数。
三元组表达相对约束
三元组由锚点a、同身份正样本p和不同身份负样本n组成。使用平方欧氏距离、间隔α时:
hinge被激活时,锚点、正样本、负样本的梯度分别为2(en−ep)、2(ep−ea)、2(ea−en)。不激活的三元组贡献为零。本例批次损失对全部传入三元组取平均,包括未激活项,并在hinge边界选择零次梯度。
大部分可能的三元组会逐渐失去训练信息。FaceNet的半困难负样本离锚点比正样本更远,但仍落在间隔之内;原论文也提醒,训练早期一味选择最困难负样本可能损害训练。本例的确定性小批次挖掘器选择最近的合格负样本,找不到就跳过该正样本对。这是明确限定的策略,不是原训练系统的完整复现。损失与样本挖掘
ArcFace把训练间隔加到角度上
把嵌入和类别权重都归一化,每个权重便成为学习到的类别方向,但不一定等于该类样本的经验均值。令cj为嵌入与类别方向的余弦,y为训练类别,s为正缩放系数,m为以弧度表示的角度间隔。ArcFace在交叉熵之前修改目标类别的logit:
目标类别需要克服额外的角度惩罚。在角度上加m,与从余弦中减m不是同一种操作。标签用于训练;比较两张新面孔时,并不知道它们的目标训练标签,也不会把这种针对目标类别的间隔直接塞进样本对分数。角度目标与伪代码
在余弦取值区间内部,展开目标变换并求导:
本例沿着该目标向特征网络和归一化类别权重反传。代码把目标余弦截到±(1−10⁻⁷),截断区间外导数取零;若目标角度θ+m达到或超过π,则拒绝该输入。这是在明确数值与定义域选择,没有悄悄给不再单调的尾段换上另一种损失。
所读固定InsightFace损失文件把角度变换放在torch.no_grad中。因此,本例的解析反向不声称复现该文件的训练行为。损失名称、数学目标与某个仓库实现,应当拿来逐项比较,不能相互代替证据。本次没有运行上游模型。固定实现
选阈值时,不要偷看答案
本例对相似度分数采用score≥t即接受的规则。设I为不同身份的比较,G为同身份的比较:
FMR衡量错误匹配,FNMR衡量未能匹配同一个人。报告时要给出分母;如果某一类比较不存在,该错误率未定义,不能当作零。这些定义针对已经成功生成的比较分数,拍摄失败和无法注册需要另行统计。指标定义
在验证集上选阈值,冻结之后再评估独立测试集。根据部署目标按人员或独立采集会话划分;随机划分图片可能泄漏近重复样本。本例选择满足经验验证FMR要求的最小“下一个可表示分数边界”。若验证集不同身份分数为[0.1,0.2,0.4,0.4,0.6],且不允许任何误匹配,t必须略大于0.6。若保存时把它四舍五入回0.6,按照已声明的规则,相等的分数就会被接受。
独立测试例子包含不同身份分数0.65和0.7。冻结阈值会接受它们:验证集成功没有保证测试集成功。若根据这些测试答案重新调阈值,就破坏了所报告测试的独立性。
图库变大,问题也变了
开放集识别应按未知查询统计错误识别率,并在指定候选排名下统计已知查询失败率。样本对FMR采用不同的分母。本例对同一身份的多份模板取最大相似度,再仅在最高身份分数达到阈值时返回该身份。换一种模板聚合方式,就改变了决策规则。图库与识别
做一个思想实验:图库有N次相互独立、错误率相同的不同身份比较,每次误匹配概率为p,则至少一次误报的概率是:
若p=0.0001、N=1000,结果约为9.52%,不是0.01%。这不是部署系统FPIR的估计值:针对同一查询的多个分数往往相互依赖,搜索算法也未必执行独立的逐对比较。应该实际测量图库搜索过程。
即使没有观察到错误,也不能证明真实错误率为零。在n次独立伯努利试验中观察到零错误,单侧95%上界满足(1−p)^n=0.05:
n=100时,上界约为2.95%。反复使用相同身份组成几千对,并不会创造几千次独立试验。代码实现的是上述二项式计算,不是为存在依赖的生物识别数据自动认证置信区间。
运行完整的小型嵌入网络
使用Python 3.12和NumPy 1.26.4。将代码保存为face_embedding.py,运行python face_embedding.py。网络包含3×3卷积、tanh、全局平均池化、线性嵌入投影和归一化类别权重,合计64个可训练参数。输入是带噪声的8×8条纹和对角线,不是人脸图像。
程序提供所有参数梯度、输入梯度、一次角度损失更新、独立三元组损失及挖掘器,以及验证/开放集评测函数。手工构造的评测分数是独立例子,并非来自已经训练的合成网络。没有通过某个API暗中引入人脸检测、对齐、预训练骨干或呈现攻击检测器。
"""Original synthetic-pattern embedding, angular loss and evaluation operators.
Complete small CNN forward/backward; no real faces, detector, alignment,
pretrained recognition model, anti-spoofing system or benchmark reproduction.
"""
import json
import numpy as np
def finite(value, rank):
x = np.asarray(value, float)
if x.ndim != rank or not np.isfinite(x).all():
raise ValueError('finite array of specified rank required')
return x
def normalize(x, epsilon=1e-12):
x = finite(x, 2)
if min(x.shape) < 1 or not np.isfinite(epsilon) or epsilon <= 0:
raise ValueError('nonempty row vectors and positive epsilon required')
length = np.linalg.norm(x, axis=1, keepdims=True)
if np.any(length <= epsilon):
raise ValueError('zero or near-zero vectors have no usable direction')
return x/length, length
def normalize_backward(gradient, unit, length):
return (gradient-unit*(gradient*unit).sum(axis=1, keepdims=True))/length
def cosine_matrix(a, b):
a, _ = normalize(a); b, _ = normalize(b)
if a.shape[1] != b.shape[1]:
raise ValueError('matching embedding dimensions required')
return np.clip(a @ b.T, -1, 1)
def labels_of(labels, count, classes):
y = np.asarray(labels)
if y.shape != (count,) or y.dtype.kind not in 'iu' or np.any(y < 0) or np.any(y >= classes):
raise ValueError('one valid integer class per sample required')
return y
def angular_loss(features, weights, labels, scale=4., margin=.2):
"""Exact analytic gradient on the smooth interior of this angular objective.
Target cosines are clipped to +/- (1-1e-7), with zero clip derivative outside.
Require theta+margin<pi; reject the nonmonotonic tail instead of silently
adding a fallback branch. This is not fixed InsightFace detached backward.
"""
e, er = normalize(features); w, wr = normalize(weights)
if e.shape[1] != w.shape[1] or len(w) < 2 or not np.isfinite(scale) or scale <= 0:
raise ValueError('matching dimensions, >=2 classes and positive scale required')
if not np.isfinite(margin) or not 0 <= margin < np.pi/2:
raise ValueError('margin in [0,pi/2) required')
y = labels_of(labels, len(e), len(w)); row = np.arange(len(e))
cosine = e @ w.T
raw = cosine[row, y]
c = np.clip(raw, -1+1e-7, 1-1e-7)
if np.any(np.arccos(c)+margin >= np.pi):
raise ValueError('target angle outside the declared monotonic margin domain')
sine = np.sqrt(1-c*c)
target = c*np.cos(margin)-sine*np.sin(margin)
logits = scale*cosine.copy(); logits[row, y] = scale*target
shifted = logits-logits.max(axis=1, keepdims=True)
probability = np.exp(shifted); probability /= probability.sum(axis=1, keepdims=True)
loss = float(np.mean(np.log(np.exp(shifted).sum(axis=1))-shifted[row, y]))
dc = probability.copy(); dc[row, y] -= 1; dc *= scale/len(e)
derivative = np.cos(margin)+c/sine*np.sin(margin)
derivative *= (raw > -1+1e-7) & (raw < 1-1e-7)
dc[row, y] *= derivative
de = normalize_backward(dc @ w, e, er)
dw = normalize_backward(dc.T @ e, w, wr)
return loss, de, dw, logits
def triplet_loss(embedding, triplets, margin=.2):
"""Mean squared-distance hinge; caller may supply unit-normalized embeddings."""
e = finite(embedding, 2); t = np.asarray(triplets)
if min(e.shape) < 1 or t.ndim != 2 or t.shape[1] != 3 or t.dtype.kind not in 'iu' or np.any(t < 0) or np.any(t >= len(e)):
raise ValueError('embeddings and integer anchor/positive/negative indices required')
if not np.isfinite(margin) or margin < 0:
raise ValueError('nonnegative margin required')
grad = np.zeros_like(e)
if len(t) == 0:
return 0., grad
value = 0.
for a, p, n in t:
hinge = np.sum((e[a]-e[p])**2)-np.sum((e[a]-e[n])**2)+margin
if hinge > 0:
value += hinge
grad[a] += 2*(e[n]-e[p])/len(t)
grad[p] += 2*(e[p]-e[a])/len(t)
grad[n] += 2*(e[a]-e[n])/len(t)
return float(value/len(t)), grad
def semi_hard(embedding, labels, margin=.2):
"""Deterministic nearest eligible negative per ordered anchor-positive pair.
Strict d_ap < d_an < d_ap+margin. No eligible negative means skip, not an
automatic hardest-negative fallback; this is a declared small-batch policy.
"""
e = finite(embedding, 2); y = np.asarray(labels)
if min(e.shape) < 1 or y.shape != (len(e),) or not np.isfinite(margin) or margin <= 0:
raise ValueError('nonempty embeddings, labels and positive margin required')
dist = ((e[:, None]-e[None])**2).sum(axis=-1)
chosen = []
for a in range(len(e)):
for p in range(len(e)):
if a == p or y[a] != y[p]:
continue
possible = np.flatnonzero((y != y[a]) & (dist[a] > dist[a,p]) & (dist[a] < dist[a,p]+margin))
if len(possible):
n = possible[np.argmin(dist[a,possible])]
chosen.append((a,p,int(n)))
return np.asarray(chosen, dtype=int).reshape(-1,3)
def verification(genuine, impostor, threshold):
g, i = finite(genuine,1), finite(impostor,1)
if not np.isfinite(threshold):
raise ValueError('finite threshold required')
false_match, false_nonmatch = int((i >= threshold).sum()), int((g < threshold).sum())
return {'genuine':len(g),'impostor':len(i),'falseMatches':false_match,
'falseNonmatches':false_nonmatch,'FMR':false_match/len(i) if len(i) else None,
'FNMR':false_nonmatch/len(g) if len(g) else None}
def choose_threshold(validation_impostor, max_fmr=0.):
"""Smallest next-representable score boundary meeting empirical validation FMR.
Accept score>=threshold. Fits validation impostors only; it is not a
confidence guarantee and must never be refitted on the reported test set.
"""
scores = finite(validation_impostor,1)
if len(scores) == 0 or not np.isfinite(max_fmr) or not 0 <= max_fmr < 1:
raise ValueError('nonempty validation scores and FMR in [0,1) required')
for threshold in np.nextafter(np.unique(scores), np.inf):
if np.isfinite(threshold) and float((scores >= threshold).mean()) <= max_fmr:
return float(threshold)
raise ValueError('no finite threshold can reject the highest score')
def identify(probes, gallery, identity_labels, threshold):
"""One best-template score per identity (max aggregation), then top1 or reject.
Ties choose the first enrolled identity. No candidate from an empty gallery.
This is exhaustive search with explicit unknown handling, not a full NIST evaluator.
"""
p = finite(probes,2); g = finite(gallery,2)
ids = np.asarray(identity_labels)
if p.shape[1] != g.shape[1] or p.shape[1] == 0 or ids.shape != (len(g),) or ids.dtype.kind not in 'iu' or np.any(ids < 0) or not np.isfinite(threshold):
raise ValueError('matching dimensions, nonnegative integer identities and finite threshold required')
if len(g) == 0:
return [None]*len(p), [None]*len(p)
normalize(g)
if len(p) == 0:
return [], []
scores = cosine_matrix(p,g)
unique = list(dict.fromkeys(ids.tolist()))
grouped = np.stack([scores[:,ids==label].max(axis=1) for label in unique],axis=1)
best = grouped.argmax(axis=1); value = grouped[np.arange(len(p)),best]
result = [unique[k] if score >= threshold else None for k,score in zip(best,value)]
return result, value.tolist()
def identification_rates(predicted, truth, enrolled_ids):
"""Top1 thresholded identification: FPIR on unknown probes, misses on known probes."""
if len(predicted) != len(truth):
raise ValueError('one result per probe required')
enrolled = set(enrolled_ids)
if any(y is not None and y not in enrolled for y in predicted):
raise ValueError('accepted identities must be enrolled')
unknown = [i for i,y in enumerate(truth) if y not in enrolled]
known = [i for i,y in enumerate(truth) if y in enrolled]
false = sum(predicted[i] is not None for i in unknown)
misses = sum(predicted[i] != truth[i] for i in known)
return {'unknownProbes':len(unknown),'knownProbes':len(known),'falseIdentifications':false,
'knownMisses':misses,'FPIR':false/len(unknown) if unknown else None,
'top1FNIR':misses/len(known) if known else None}
def zero_error_upper(n, alpha=.05):
"""One-sided exact binomial upper bound ONLY for zero errors in n iid trials."""
if type(n) is not int or n < 1 or not 0 < alpha < 1:
raise ValueError('positive independent trial count and alpha in (0,1) required')
return float(-np.expm1(np.log(alpha)/n))
def gallery_false_alarm(pair_fmr, size):
"""Illustration under independent equal-rate nonmate comparisons, not measured FPIR."""
if not np.isfinite(pair_fmr) or not 0 <= pair_fmr <= 1 or type(size) is not int or size < 0:
raise ValueError('probability and nonnegative integer gallery size required')
if size == 0 or pair_fmr == 0: return 0.
if pair_fmr == 1: return 1.
return float(-np.expm1(size*np.log1p(-pair_fmr)))
def conv(x,k,b):
n,h,w,_=x.shape;size=k.shape[0];pad=size//2
padded=np.pad(x,((0,0),(pad,pad),(pad,pad),(0,0)))
out=np.broadcast_to(b,(n,h,w,len(b))).copy()
for y in range(size):
for z in range(size):out += padded[:,y:y+h,z:z+w] @ k[y,z]
return out
def conv_backward(x,k,gradient):
n,h,w,_=x.shape;size=k.shape[0];pad=size//2
padded=np.pad(x,((0,0),(pad,pad),(pad,pad),(0,0)))
dx,dk=np.zeros_like(padded),np.zeros_like(k)
for y in range(size):
for z in range(size):
dk[y,z]=np.einsum('nhwc,nhwf->cf',padded[:,y:y+h,z:z+w],gradient)
dx[:,y:y+h,z:z+w] += gradient @ k[y,z].T
return dx[:,pad:pad+h,pad:pad+w],dk,gradient.sum(axis=(0,1,2))
def parameters(seed=12):
rng=np.random.default_rng(seed)
return [rng.normal(0,.2,(3,3,1,4)),np.full(4,.1),rng.normal(0,.3,(4,3)),
np.array([.2,-.1,.3]),rng.normal(0,1,(3,3))]
def forward(images,p):
x=finite(images,4)
if min(x.shape)<1 or x.shape[3]!=1:raise ValueError('nonempty N,H,W,1 images required')
hidden=np.tanh(conv(x,p[0],p[1]));pooled=hidden.mean(axis=(1,2))
features=pooled @ p[2]+p[3]
unit,_=normalize(features)
return features,unit,(x,hidden,pooled)
def backward(p,cache,feature_gradient,weight_gradient):
x,h,pool=cache;df=finite(feature_gradient,2)
if df.shape!=(len(x),3) or np.shape(weight_gradient)!=p[4].shape:raise ValueError('matching head gradients required')
dk2=pool.T @ df;db2=df.sum(axis=0);dp=df @ p[2].T
dh=np.broadcast_to(dp[:,None,None,:]/(x.shape[1]*x.shape[2]),h.shape)*(1-h*h)
dx,dk,db=conv_backward(x,p[0],dh)
return [dk,db,dk2,db2,weight_gradient],dx
def demo():
rng=np.random.default_rng(31);y,x=np.indices((8,8))
bases=np.stack([(x<3).astype(float),(y<3).astype(float),(x==y).astype(float)])
images=np.stack([base+rng.normal(0,.05,base.shape) for base in bases for _ in range(2)])[...,None]
labels=np.repeat(np.arange(3),2);p=parameters()
features,embedding,cache=forward(images,p)
before,df,dw,_=angular_loss(features,p[4],labels)
gradients,dx=backward(p,cache,df,dw)
for value,grad in zip(p,gradients):value -= .01*grad
after=angular_loss(forward(images,p)[0],p[4],labels)[0]
assert after < before
threshold=choose_threshold([.1,.2,.4,.4,.6],max_fmr=0.)
validation=verification([.7,.8,.9],[.1,.2,.4,.4,.6],threshold)
test=verification([.55,.75,.85],[.2,.5,.65,.7],threshold)
chosen,scores=identify([[1,0],[0,1],[-1,0]],[[1,0],[0,1]],[10,20],threshold=.8)
rates=identification_rates(chosen,[10,20,99],[10,20])
return {'parameters':sum(v.size for v in p),'lossBefore':before,'lossAfterOneStep':after,
'inputGradientNorm':float(np.linalg.norm(dx)),'validationThreshold':threshold,
'validation':validation,'test':test,'openSetPredictions':chosen,'openSetScores':scores,
'openSetRates':rates,'zeroErrors100Upper95':zero_error_upper(100),
'independentGallery1000AtPairFMR1e4':gallery_false_alarm(.0001,1000),
'scope':'synthetic pattern CNN and separate score fixtures; no face-recognition accuracy claim'}
if __name__=='__main__':
print(json.dumps(demo(),indent=2))
已记录的输出如下,不同平台的浮点末位可能略有差别:
{
"parameters": 64,
"lossBefore": 3.0453347419335475,
"lossAfterOneStep": 2.809598287411779,
"inputGradientNorm": 0.04141402825974086,
"validationThreshold": 0.6000000000000001,
"validation": {
"genuine": 3,
"impostor": 5,
"falseMatches": 0,
"falseNonmatches": 0,
"FMR": 0.0,
"FNMR": 0.0
},
"test": {
"genuine": 3,
"impostor": 4,
"falseMatches": 2,
"falseNonmatches": 1,
"FMR": 0.5,
"FNMR": 0.3333333333333333
},
"openSetPredictions": [
10,
20,
null
],
"openSetScores": [
1.0,
1.0,
0.0
],
"openSetRates": {
"unknownProbes": 1,
"knownProbes": 2,
"falseIdentifications": 0,
"knownMisses": 0,
"FPIR": 0.0,
"top1FNIR": 0.0
},
"zeroErrors100Upper95": 0.029513049607039932,
"independentGallery1000AtPairFMR1e4": 0.09516710644145375,
"scope": "synthetic pattern CNN and separate score fixtures; no face-recognition accuracy claim"
}
一次更新使网络损失从3.04533降到2.80960,证明的是玩具样本上的优化计算,不是识别质量。分数例子保留了四次不同身份测试比较中的两次误匹配,以及三次同身份比较中的一次未匹配。图库第三个查询返回None,演示的是拒绝,而不是强行报出某个人。
卷积计算量为O(BHWk²CinCout)。对于C个类别、D维嵌入,稠密归一化分类器计算量为O(BCD),类别权重存储为O(CD)。这些训练类别不是推理时使用的注册图库。Q个查询与G份模板进行穷举比较,计算量为O(QGD),显式分数矩阵需要O(QG)存储。本例半困难挖掘器计算O(B²D)的距离,但对每个有序正样本对扫描负样本,最坏搜索量为O(B³)。生产系统需要更仔细地设计批处理、索引与采样。
分数只是决策的一部分
拍摄与攻击。 模糊、遮挡、光照、姿态和年龄变化都可能改变表示。匹配身份,与判断摄像头看到的是真实拍摄、重放还是被操纵图像,并不是同一任务。拍摄和呈现攻击组件需要单独测试;余弦相似度和训练成功都不能证明系统能抵抗这些失败。
错误代价不相同。 被拒绝进入与被错误关联到另一个身份,后果不同。应报告实际工作阈值下的错误率、样本数和相关拍摄条件,保留拒绝不可用样本或未知身份的路径,不强迫输出标签。
人群与证据。 NIST在2019年的研究记录了随算法和评测条件变化的人群差异。它没有训练送测系统、确定差异的成因,也没有评估互联网图片和监控视频图像。不能把这些结果改写为所有当前模型的普遍结论,更不能与属性分类研究混为一谈。研究范围与未回答的问题
模板与版本。 嵌入仍是与身份有关的数据,换成向量不等于保证匿名。访问、保留和使用范围应限于任务的实际需要。模型更新可能改变嵌入几何和阈值,因此混用版本之前,要先检查它与已有注册模板的兼容性。
复用权利。 所读InsightFace README区分代码许可与所提供训练数据、模型的使用限制。代码公开不自动意味着权重和图像具有相同复用权利。本例使用原创代码和生成图案,不再分发上游权重或人脸数据集。固定仓库说明
把四个决定说清楚
1. 换算分数阈值
两个嵌入都是单位向量,余弦相似度0.8。平方欧氏距离是多少?这个分数意味着同一身份的概率为80%吗?
答案:平方距离为2−2×0.8=0.4。相似度不是经过校准的后验概率。它的含义取决于训练表示、比较人群与决策规则;单位归一化只提供了上述几何关系。
2. 解释阈值相等
验证集不同身份分数为[0.1,0.2,0.4,0.4,0.6],规则为score≥t时接受,目标为零经验误匹配。为什么程序返回略大于0.6的值?不同身份测试分数0.65与0.7会怎样?
答案:阈值恰为0.6时,最大的验证分数会被接受,所以选择器返回它上方下一个可表示值。两个测试分数仍高于该阈值,都会误匹配。正确做法是报告测试错误,而不是偷偷利用测试标签移动阈值。
3. 找出未知身份的失败
图库保存单位向量(1,0)、(0,1),身份标签分别为10、20。查询(−1,0)到来,比较无条件最近邻识别与接受阈值0.8的做法。
答案:相似度分别为−1与0。无条件top1会返回身份20,尽管两个向量都不近。带阈值的规则返回None;若查询身份没有注册,这就是正确拒绝。这个例子并不证明所有未知查询都会被拒绝。
4. 审查性能结论
某团队在100次独立不同身份比较中发现零误匹配,想据此声称1000人图库的错误率为零。报告应怎样修改?
答案:报告观察到0/100错误,而非证明了零错误率。在上述独立二项式假设下,单侧95%上界约为2.95%。1000人图库需要单独进行未知查询评测;思想实验中的1−(1−p)^N还额外假定比较独立且错误率相同。重复身份和相关样本需要适当的不确定性分析。
把方法版本和测量日期分开
1991年的特征脸论文与DeepFace的CVPR 2014论文代表了不同的表示路线。FaceNet首个arXiv提交为2015年3月12日;ArcFace为2018年1月23日,早于其CVPR 2019论文。当前ArcFace的arXiv条目包含后续期刊扩展,作者列表也不同,不能把新增材料悄悄归到四位作者的会议论文中。特征脸、DeepFace、FaceNet历史、ArcFace历史
NIST于2019年12月19日发布8280号报告。阅读结论时,也要一起读任务定义与测试边界。稿件提交日期、会议年份、仓库提交和基准测量日期,描述的是不同事件。发布记录
有用的复现报告应说明裁剪/对齐规则、架构与权重、训练身份、标签清理、损失与采样、比较度量、注册流程、验证阈值和测试协议。任何一项变化都可能影响结果。本例让自身选择可检查,不宣称复现这些代表系统的准确率。
先判断,再看解释
未知查询有一个最近的图库模板,但分数低于阈值。该开放集系统应返回什么?
学习目标
- 区分检测、验证、闭集识别和开放集拒绝。
- 对归一化嵌入与角度间隔训练目标求导。
- 避免测试泄漏地选择阈值,并解释正确的错误率分母。
- 评估图库规模、样本依赖、拍摄条件和版本兼容。
先修与延伸
查看知识关联图 →参考文献
- FaceNet: A Unified Embedding for Face Recognition and Clustering
Florian Schroff; Dmitry Kalenichenko; James Philbin · 2015 - ArcFace: Additive Angular Margin Loss for Deep Face Recognition
Jiankang Deng; Jia Guo; Niannan Xue; Stefanos Zafeiriou · 2019 - DeepFace: Closing the Gap to Human-Level Performance in Face Verification
Yaniv Taigman; Ming Yang; Marc’Aurelio Ranzato; Lior Wolf · 2014 - Face Recognition Vendor Test Part 3: Demographic Effects
Patrick Grother; Mei Ngan; Kayee Hanaoka · 2019 - Eigenfaces for Recognition
Matthew Turk; Alex Pentland · 1991 - InsightFace fixed angular loss implementation
InsightFace contributors · 2026 - InsightFace fixed code/data/model license notice
InsightFace contributors · 2026 - FaceNet: A Unified Embedding for Face Recognition and Clustering — submission history
Florian Schroff; Dmitry Kalenichenko; James Philbin · 2015 - ArcFace: Additive Angular Margin Loss for Deep Face Recognition — submission history
Jiankang Deng; Jia Guo; Jing Yang; Niannan Xue; Irene Kotsia; Stefanos Zafeiriou (current journal record) · 2018 - NISTIR8280 publication record
National Institute of Standards and Technology · 2019
版本1 · 编写状态: 已完成记录中的技术复核
查看技术检查记录(AI)
Codex · 2026-09-07 · Codex single-AI-author technical check: scoped original conference papers, scanned historical paper, fixed InsightFace source and NIST report; complete small-CNN/angular gradients, independent threshold/open-set tests, bilingual comparison and computed diagram binding. Not human peer review or biometric benchmark reproduction.
- 十九项数值加四项双语/输出/元数据/图示检查;全部64参数和48输入中心差分,归一化/角度/三元组梯度、严格挖掘、阈值相等、验证测试分离、开放集分母和置信假设。
- 逐节核对完整双语、九组公式、完整代码/输出、四组解释答案和十项限定来源;保留训练/评测夹具区别、会议/期刊版本、no_grad实现/解析目标区别、未知拒绝和数据权利边界。
核对的来源位置:
- FaceNet: A Unified Embedding for Face Recognition and Clustering · Physical pages2–4 complete: unit128D embedding, squared-distance triplet hinge, online anchor-positive pairs, semi-hard negative selection, crop/scale/translation only versus 3D alignment, two architecture families and training context. Benchmark/results pages5–9 not audited. No quoted accuracy or compute reproduction.
- ArcFace: Additive Angular Margin Loss for Deep Face Recognition · Physical pages2–4 complete; page3 visually inspected: normalized features/class weights, target angular margin and scale, Eq3/pseudocode, comparison with cosine/multiplicative margins, opening experiment context. Later results not audited. CVPR2019 paper has four authors; arXiv2022 journal version is distinct.
- DeepFace: Closing the Gap to Human-Level Performance in Face Verification · Physical pages2–4 complete: iterative2D alignment, generic3D frontalization, locally connected layers without weight sharing, classification training and F7 representation, component scaling thenL2. No benchmark results or end-to-end reproduction; apparent C3 channel description not used.
- Face Recognition Vendor Test Part 3: Demographic Effects · Physical pages4,5,7,8,12,15 complete: study scope/results overview, verification versus identification, genuine/nonmate and FMR/FNMR definitions, gallery/unknown behavior, omitted causal/training/wild-image questions. Pages1–16 opening snippets located sections only. No exhaustive demographic tables or modern model benchmark audited.
- Eigenfaces for Recognition · Scanned PDF has no extracted text. Physical pages1,3,4 visually read: title/authors/copyright1991; PCA face-space/known-unknown decisions, Sirovich/Kirby antecedents, centered covariance and small Gram-matrix idea. Other pages not read; no performance numbers adopted.
- InsightFace fixed angular loss implementation · Complete loss file read: CombinedMarginLoss, ArcFace and CosFace, including no_grad angular transforms. Not executed.
- InsightFace fixed code/data/model license notice · License section lines29–41 and recognition project index lines141–148 read; other README content not audited.
- FaceNet: A Unified Embedding for Face Recognition and Clustering — submission history · Actual v1 submission history read; CVPR2015 PDF used for method reading. First submission 2015-03-12.
- ArcFace: Additive Angular Margin Loss for Deep Face Recognition — submission history · Actual v1 submission history read; current page v4 is2022 journal expansion with6authors. Original CVPR2019 four-author PDF used for method reading. First submission 2018-01-23.
- NISTIR8280 publication record · Official title, Published19December2019, authors and Created/Updated footer read.
相关主题