얼굴 인식률 성능 개선


...

기존의 프로젝트는 등록되지 않는 사람이 얼굴을 인식하는 문제가 있었다.
등록되지 않은 사람이 인식되어 도어락이 열리면 안되기 때문에 인식률을 개선할 필요성을 느꼈다.

기존 얼굴 인식의 문제점

face_recognition.api.compare_face는 0.6 이하의 정확도가 나온 경우 일치한다고 본다.
하지만 한국 사람에 대한 데이터가 많이 부족한 탓인지 정확도가 낮았다.

face_recognition.api.compare_face를 사용하면 비교수치를 수정할 수 없기 때문에 다른 방법을 사용해야 했다.

해결 방안

face_recognition에서는 face_recognition.api.compare_face 메서드를 제공하는데 얼굴 인코딩 목록이 주어지면,
알려진 얼굴 인코딩과 비교하고 각 비교면에 대해 수치를 얻을 수 있다. 수치는 얼굴이 얼마나 비슷한지 알려준다.


Module contents

face_recognition.api.compare_face (face_encodings, face_to_compare)

ㆍface_encodings – 비교할 얼굴 인코딩 목록
ㆍface_to_compare – 비교할 얼굴 인코딩


이미지가 저장된 배열에 동일한 순서로 각 수치를 반환.


소스

**def**
face_distance(face_encodings, face_to_compare):
*"""*
*Given a list of face encodings, compare them to a known face encoding and get a euclidean distance*
*for each comparison face. The distance tells you how similar the faces are.*
*:param face_encodings: List of face encodings to compare*
*:param face_to_compare: A face encoding to compare against*
*:return: A numpy ndarray with the distance for each face in the same order as the 'faces' array*
*"""*
**if**
len(face_encodings) == 0:
**return**
np.empty((0))
**return**
np.linalg.norm(face_encodings - face_to_compare, axis=1)

적용


Distance 값을 받아 변수에 저장.



가장 적은 수치를 가진 수치를 저장



여러 테스트를 한 후 가장 적절한 수치를 찾아 기준을 잡아준다.