본문 바로가기
Google Machine Learning Bootcamp 2022/Convolutional Neural Networks

4. Special Applications: Face recognition & Neural Style Transfer #1

by 사향낭 2022. 8. 2.

Face Recognition

 

What is Face Recognition?

 

Face Verification: input으로 image와 name/ID를 받아 해당 사람이 맞는지를 판별해야 한다.

 

Face Recognition: database에 k명의 사람이 있다고 한다면 input으로 얼굴 image를 받아 이 사람이 database에 저장된 k명의 사람에 속하는지를 확인할 수 있어야 한다.

 

 

One Shot Learning

 

Learning from one example to recognize the person again

 

데이터가 별로 없는 대상을 상대로 recognition을 하기는 어렵다, class가 인식해야 하는 사람이 많아질수록 늘어난다.

 

=> Learning a "similarity" function

 

d(img1, img2) = degree of difference between images (threshold 이상이면 same, otherwise different)

 

 

Siamese Network

 

Image를 vector형태로 representation 한다. (encoding)

 

Encoding 한 vector representation을 바탕으로 L2 norm으로 두 얼굴의 유사도를 계산한다.

 

vector representation이 그 image를 잘 나타낼 것이라는 가정이 밑바닥에 깔려있다.

 

 

Triplet Loss

 

3개의 image(anchor, positive, negative)가 있다고 하자.

 

anchor와 positive는 동일 인물의 사진이고 anchor와 negative는 서로 다른 얼굴이다.

 

정말 당연하게도 우리는 anchor와 positive의 vector representation을 가깝게, anchor와 negative의 vector representation은 멀게 만들고 싶을 것이다.

 

따라서 이러한 loss를 정의한다.

 

\( L(A, P, N) = \max (|| f(A) - f(P) ||^2 - || f(A) - f(N) ||^2 + \alpha, 0 ) \) ( alpha는 margin )

 

우리는 max의 왼쪽 term은 0보다 작기를 원한다. 따라서 0보다 클 때 penelization을 해준다. (loss 정의에 따라)

 

A, P, N을 random 하게 고르면 조건을 만족하기가 쉽다고 한다.

 

따라서 anchor과 거리가 비슷한 positive와 negative를 학습에 선택하는 것이 좋다.

 

 

Face Verification and Binary Classification

 

위의 방식으로 image embedding을 잘 학습시켰다고 한다면, 같은 사람인지 아닌지를 판별하는 것은 두 vector representation에 sigmoid 같은 함수를 사용해서 binary classification을 하면 된다.

 

학습이 완료된 후에는 verification의 대상이 되는 경우 database에 image의 vector representation만 저장해놓으면 된다.

댓글