luckycallor / InsightFace-tensorflow

Tensoflow implementation of InsightFace (ArcFace: Additive Angular Margin Loss for Deep Face Recognition).
248 stars 112 forks source link

两张照片不同的人,距离也很小 #29

Open HandsLing opened 5 years ago

HandsLing commented 5 years ago

使用get_emb.py得到两张照片中的人脸embding,但是经过测试,两张照片同一个人和两张照片不同的人距离差别不大,请问如何来设置阈值呢?我使用的是欧氏距离计算 同一个人对应的距离: dist1 : [[0.23265116]] dist2 : 0.23265092 dist3 : 0.07422299692117233 simlarity : 0.9729368 不同人对应的距离:: dist1 : [[0.33493966]] dist2 : 0.33493972 dist3 : 0.1071193271412563 simlarity : 0.94390774 其中dist1是我自己写的计算欧氏距离的函数,dist2使用的是作者提供的计算欧氏距离的函数,dist3是使用作者提供的计算cos距离的函数得到的,simlarity计算的是相似度,计算方式是: def distance(embeddings1, embeddings2): dot = np.dot(embeddings1, embeddings2) norm = np.linalg.norm(embeddings1, ord=2) * np.linalg.norm(embeddings2, ord=2) similarity = dot / norm if similarity > 1: similarity = 1.0 return similarity 大家都有这种问题吗?

qwn19970728 commented 5 years ago

Change line102 in get_embd.py from:saver = tf.train.Saver(var_list=tf.trainable_variables()) --> saver = tf.train.Saver() to get the right embedding.

HandsLing commented 5 years ago

@qwn19970728 thx, but i did changed that before, and i can get the same embedding for one image twice. and the distance in this issue was calculated by these embeddings