Face Recognition 제작기 -2단계 이미지 추론결과 다루기
https://hansonminlearning.tistory.com/90
Face Recognition Custom 제작기-초간단[1/2]
회사와서 별에별거를 접해보게된다. 얼굴인식기를 만들어볼껀데. FaceNet으로 사용해볼꺼다. 참고 https://github.com/arsfutura/face-recognition GitHub - arsfutura/face-recognition: A framework for creatin..
hansonminlearning.tistory.com
얼굴에 바운딩박스까지 잘 나온다면, 이제 탐지결과를 다루는 방법에 대해서 궁금해할것이다.
classifier.py 에 들어가서 main함수를 보면 아래와 같다. faces 라는 변수에 모든 탐지결과가 담겨있는데.
출력하면 아래와 같다.
Face(top_prediction=Prediction(label='person1', confidence=0.9091296813269149), bb=BoundingBox(left=604.2071414589882, top=930.4850389361382, right=1625.1759132742882, bottom=2052.0600162148476), all_predictions=[Prediction(label='person1', confidence=0.9091296813269149), Prediction(label='person2', confidence=0.049479137263095004), Prediction(label='person3', confidence=0.01914071424027673), Prediction(label='person4', confidence=0.022250467169713326)])
나는 탐지결과(클래스), 정확도 만 궁금하다 하면
print('Who is it?: ', faces[0][0][0], ' | ', 'Confidence: ', round((faces[0][0][1]),3)) 를 찍어보면 된다.
def main():
args = parse_args()
preprocess = preprocessing.ExifOrientationNormalize()
img = Image.open(args.image_path)
filename = img.filename
img = preprocess(img)
img = img.convert('RGB')
faces, img = recognise_faces(img)
print('Who is it?: ', faces[0][0][0], ' | ', 'Confidence: ', round((faces[0][0][1]),3))
if not faces:
print('No faces found in this image.')
if args.save_dir:
basename = os.path.basename(filename)
name = basename.split('.')[0]
ext = basename.split('.')[1]
img.save('{}_tagged.{}'.format(name, ext))
img.show()
추후 결과 및 탐지결과 이미지를 변경하고 싶다면, main함수를 수정하면 된다.