繁体   English   中英

如何在人脸识别的KNN算法中获取匹配图像的百分比

[英]How to get percentage of matching image in KNN algorithm for face recognition

我目前正在关注这个 repo: https://github.com/ageitgey/face_recognition/blob/master/examples/face_recognition_knn.py使用 KNN 算法在 python 中进行人脸识别。 当我阅读代码时,我发现了这个

    # Find encodings for faces in the test iamge
    faces_encodings = face_recognition.face_encodings(X_img, known_face_locations=X_face_locations)

    # Use the KNN model to find the best matches for the test face
    closest_distances = knn_clf.kneighbors(faces_encodings, n_neighbors=1)

    are_matches = [closest_distances[0][i][0] <= distance_threshold for i in range(len(X_face_locations))]

    # Predict classes and remove classifications that aren't within the threshold
    return [(pred, loc) if rec else ("unknown", loc) for pred, loc, rec in zip(knn_clf.predict(faces_encodings), X_face_locations, are_matches)]

从上面的代码中,有没有办法获得匹配图像的百分比......例如:我想知道图像 X 与已经训练的图像相比的百分比

试着看看这个: github 的 %%% Adam Geitgey 解释说没有直接的方法可以将距离转换为百分比......但是“类似的东西”是。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM