(Research) Face_recognition (1) 프로젝트 소개

얼굴 인식 프로젝트에 대하여 알아 보겠습니다. ^^

이번 프로젝트는 Open Source 를 최대 활용 하여 1)주요 라이브러리와 Source Code 를 이해 하고  2) 요구되는 개발자 환경을 구축 하며 3)성능을 최적화 하는 방법을 고민하고 4)그 결과를 공유하고 개선 방안을 논의해 보는 것을 목적으로 합니다.


우선 GitHub 에서 성능 좋은 오픈 소스를 다운 받아 각자의 환경에 맞추어 설치해 보겠습니다. 무작정 pip install... 명령어를 사용하면 시작부터 삽질의 늪에 빠질 수 도 있으니 끝까지 내용을 잘 읽어 보시고 따라해 보시기 바랍니다.

[준비물: 자기 얼굴 사진 ^^]



Face_recognition (진행 중)

  • 목   표 : 간단한 얼굴 인식 라이브러리로, Python 또는 CLI 에서 얼굴을 인식하고 조작
  • 서비스
    • 얼굴 탐지
    • 얼굴의 특징
    • 얼굴 인식
  • 필수 라이브러리 소개  * 주의 사항: 관리자 권한,윈도우는 sudo 빼고~)
    • [opencv]
      • 설명
        • OpenCV는 공식적으로 pip 설치를 지원하진 않는데 github에서 pip 설치가 되도록 해주는 프로젝트를 하는 그룹이 있는 것 같습니다. 필요한 라이브러리를 전부 설치합니다. 
      • 다운로드 및 설치  * 반드시 관리자 권한으로 실행(이미지 참조)
        • pip install filterpy
        • pip install opencv-contrib-python
        • pip install opencv-python 
    • [dlib] (C++ Library) 
      • 설명
        • 딥러닝 기반으로 제작, 얼굴 인식 기능을 사용하여 구축 되었으며, 
        • Labeled Faces in the Wild 기준으로 99.38%의 정확도를 가짐
        • CLI 에서 이미지 폴더안에 있는 얼굴 인식 기능을 위한 간단한 face recognition 도구를 제공
      • 다운로드 : http://dlib.net/ 
        • 윈도우 환경의 경우 pip install 방식 (이 경우 아주 많은 삽질의 시작점이다.)이 아닌 최신 zip 파일을 다운 받아,
                                 
        • 아나콘다 환경 (본인의 경우 Anacoda 3 Powershell Prompt) 에서 다운 받은 폴더에 접근 하여 설치 방법에 따라 설치 하자!
      • 설치 방법 (약 10분 소요)
        • python setup.py build
      • 주의 사항
        • 제공 되는 Opensource 에서의 각 기능별 "xxx.py" 코드에서의 Path 와 실제 위치한 경로가 맞지 않아, 하나하나 맞춰주는 작업이 필요 함
          •  (예시) 원본 xxx_train("knn_examples/train")
          •  (예시) 수정본 xxx_train("./examples/knn_examples/train")
             
        • python setup.py install
      • 설치 확인
        • Python 실행 
          • >>> import dlib      #아무 오류 없으면 성공
          • >>> dlib.__version__ #버전 확인 가능
    • [face_recognition]
      • 설명
      • 다운로드 및 설치: pip install face_recognition
      • 설치 확인 
        •  Python 실행
          • >>> import face_recognition

  • Source Code 
    • 구성
    • 주요 기능

  • 작업자 환경  
    • OS : Window 10
    • IDE : VS Code
    • 추가 설치 : dlib , face_recognition , OpenVC 
    • Python Version  : Python 3.3+ or Python 2.7  

Features

Find faces in pictures

Find all the faces that appear in a picture:

                                                                 


import face_recognition
image = face_recognition.load_image_file("your_file.jpg")
face_locations = face_recognition.face_locations(image)

Find and manipulate facial features in pictures

Get the locations and outlines of each person's eyes, nose, mouth and chin.

import face_recognition
image = face_recognition.load_image_file("your_file.jpg")
face_landmarks_list = face_recognition.face_landmarks(image)

Finding facial features is super useful for lots of important stuff. But you can also use it for really stupid stuff like applying digital make-up (think 'Meitu'):

얼굴 특징 : 눈 , 코 , 입술 


얼굴 탐지



Identify faces in pictures

Recognize who appears in each photo.



import face_recognition
known_image = face_recognition.load_image_file("biden.jpg")
unknown_image = face_recognition.load_image_file("unknown.jpg")

biden_encoding = face_recognition.face_encodings(known_image)[0]
unknown_encoding = face_recognition.face_encodings(unknown_image)[0]

results = face_recognition.compare_faces([biden_encoding], unknown_encoding)

You can even use this library with other Python libraries to do real-time face recognition:

                               

See this example for the code.