[PYTHON] I tried using face_recognition

I found a face recognition article and tried it, but it didn't go smoothly, so I'll write it down.

Face recognition can be performed using Python. Moreover, the library is open to the public. Moreover, it seems easy. First article I saw: https://www.cresco.co.jp/blog/entry/9468/

I was wondering if face recognition could be used for things that are just a problem in my work. I first saw it with a light feeling like "just install it with pip".

>pip3 install face_recognition

I got an error during installation and couldn't proceed at all ... I googled while looking at the unreadable English

I was angry because I didn't have a wheel. what is that? It seems to be a zip for python distribution.

>pip install -U wheel

Still more errors dlib

In the first place, face_recognition seems to be for using a face recognition library called dlib. Is it a wrapper for python? Reference: https://qiita.com/nonbiri15/items/f95b5fb01ae38980c9ce

It seems that you need to install dlib.

>pip3 install dlib

After all error rolls out

It seems that dlib is made in C It seems that CMAKE is necessary. cmake-3.18.0-rc2-win64-x64.msi ↑ DL and install

Still more ~ It seems to build with VC ++ (that's right) Reference: https://qiita.com/strv13570/items/a0542600532deee61391 I had Visual studio 2017, but I didn't want to touch VC ++, so I didn't. Since there is no help for it, change it to use VC ++ and install it

As mentioned above, set the path etc. as appropriate (confirmation)

>pip3 install dlib
 ・
 ・
 ・
Successfully installed dlib-19.20.0

Finally, I passed dlib.

pip3 install face_recognition
 ・
 ・
 ・
 Successfully installed Pillow-7.1.2 face-recognition-1.3.0 numpy-1.19.0

It was a long way to finally install it ... I thought Gugu, why did everyone put in anacondas? ?? Is it business?

For the time being, create two folders with reference to the site and put photos in it. How to use it like creating a face folder you know and a face folder you don't know, putting them in each, and taking a diff. I tried each below. face.png

face2.png

As mentioned above, the intention of the usage review has become an installation memo ...

I plan to try various other things Reference: https://www.kkaneko.jp/dblab/dlib/facerec.html

Postscript: ↑ I looked at the site and tried it

import face_recognition

src_img = face_recognition.load_image_file("./face/obama.png ")
src_img_encoding = face_recognition.face_encodings(src_img)[0]
 print(src_img_encoding)

img1="./face2/tosi.png "
img2="./face2/tosi2.png "
img3="./face2/tosi3.png "

dest_img1 = face_recognition.load_image_file(img1)
dest_img_encoding1 = face_recognition.face_encodings(dest_img1)[0]

dest_img_encoding2 = face_recognition.face_encodings(face_recognition.load_image_file(img2))[0]
dest_img_encoding3 = face_recognition.face_encodings(face_recognition.load_image_file(img3))[0]

results = face_recognition.compare_faces([src_img_encoding], dest_img_encoding1)
print(img1 , results)
results = face_recognition.compare_faces([src_img_encoding], dest_img_encoding2)
print(img2 , results)
results = face_recognition.compare_faces([src_img_encoding], dest_img_encoding3)
print(img3 , results)
>test_face.py
./face2/tosi.png [False]
./face2/tosi2.png [False]
./face2/tosi3.png [True]

Process finished with exit code 0

Facial features can be quantified and compared It ’s really easy! !!

Recommended Posts

I tried using face_recognition
I tried using parameterized
I tried using argparse
I tried using mimesis
I tried using anytree
I tried using aiomysql
I tried using Summpy
I tried using coturn
I tried using Pipenv
I tried using matplotlib
I tried using "Anvil".
I tried using Hubot
I tried using ESPCN
I tried using openpyxl
I tried using Ipython
I tried using PyCaret
I tried using cron
I tried using ngrok
I tried using Jupyter
I tried using PyCaret
I tried using Heapq
I tried using doctest
I tried using folium
I tried using jinja2
I tried using folium
I tried using time-window
[I tried using Pythonista 3] Introduction
I tried using easydict (memo).
I tried face recognition using Face ++
I tried using Random Forest
I tried using BigQuery ML
I tried using Amazon Glacier
I tried using git inspector
[Python] I tried using OpenPose
I tried using magenta / TensorFlow
I tried using AWS Chalice
I tried using Slack emojinator
I tried using Rotrics Dex Arm # 2
I tried using Rotrics Dex Arm
I tried using GrabCut of OpenCV
I tried using Thonny (Python / IDE)
I tried server-client communication using tmux
I tried reinforcement learning using PyBrain
I tried deep learning using Theano
Somehow I tried using jupyter notebook
[Kaggle] I tried undersampling using imbalanced-learn
I tried shooting Kamehameha using OpenPose
I tried using the checkio API
[Python] I tried using YOLO v3
I tried asynchronous processing using asyncio
I tried scraping
I tried PyQ
I tried AutoKeras
I tried papermill
I tried django-slack
I tried Django
I tried spleeter
I tried cgo
I tried using Amazon SQS with django-celery
I tried using Azure Speech to Text.
I tried using Twitter api and Line api