π A Starter Guide to Face Detection & Recognition in Python
Table of Content
Intro
To understand what is Facial Detection and/or recognition, you can read our primer or checkout a the slides we made for our data science bootcamp presentation.
How to Use this repo
- Clone this repo:
$ git clone https://github.com/ohjho/starter_guide_img_recog.git
$ cd start_guide_img_recog
- install the requirements. We highly recommend doing this inside a virtualenv and avoid dependency hell.
#---------------- optional ------------------
$ mkvirtualenv --python=`which python3` NameOfYourEnv
$ workon NameOfYourEnv
(NameOfYourEnv) $ pip freeze > uninstall.txt
(NameOfYourEnv) $ pip uninstall -r uninstall.txt -y
(NameOfYourEnv) $ rm uninstall.txt
#--------------------------------------------
(NameOfYourEnv) $ pip install -r requirements.txt
and just check and resolve any packages dependency issues if they show up under pip check
. It should say No broken requirements found.
You are not done yet β If you are going to use the dlib or yolo templates in this guide, you will need to follow the installation notes.
- Start Jupyter notebook
$ cd _templates
$ jupyter notebook
- Have fun and go build some awesome projects! π
π Boilerplates
Want to start working on an Image Recognition project?!
Here are some templates to get yous started:
References
Tutorials
- History of Facial Recongition
- Advancements in Facial Recognition Systems
- An Intro video by YoutTube star Siraj Raval
- Face Detection for Beginners
- Face Recognition for Beginners
- Methods for Face Detection and Face Recognition - A Review
- Modern Face Recognition with Deep Learning
- Building a Face Detection Model from Video using Deep Learning
- A Github Repo on the recent development of face detection algorithm
Open CV
- Face Recognition with Python, in Under 25 Lines of Code
- Using OpenCV to play "Where's Waldo?"
- OpenCV Face Recognition
- Facial Recognition in OpenCV, Python, and Deep Learning
Dlib
- HOG as object detector explained
- Make your own object detector with HOG
- Understanding dlib's facial landmark detector
- HOG vs CNN based face detector from dlib
- Dlib's deep learning on facial recognition
YOLO
- A TED talk by one of the developer of YOLO
- A video about how YOLO works
- YOLO: Implementations and how to use them
- YOLOv2 object detection using Darkflow
- This repo has implementation of YOLO in several flavours
Libraries
Documentations
- OpenCV-Python
- dlib
- The Darknet's guide to YOLO
Installing the Required Packages
openCV
requirements.txt
will install opencv-contrib-python
for you. For more details, read this installation guide.
face_detection/dlib
dlib
is written in C++, so in order to use it we need to clone the dlib
repo and compile it in python per this instruction(make sure you satisfy the pre-requisite ). We highly recommend doing this inside a virtualenv:
$ cd to/your/git/dir
$ git clone https://github.com/davisking/dlib.git
$ cd dlib
$ mkdir build; cd build; cmake ..; cmake --build .
$ cd ..
$ python3 setup.py install
dlib Pre-requisite
- you need to have Python3 installed. To check, type
which python3
in your command-line - you need to have Homebrew. To install:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
- you need X11 to be installed before installing
dlib
, else you may experience AttributeError. To install: Head to XQuartz to download the latest version. - you need to have
cmake
. To install:brew install cmake
YOLO
There are currently three main implementations of YOLO:
- Darknet: The 'offical' implementation written in C
- AlexeyAB/ Darknet: a fork of Darknet to support Windows and Linux
- Darkflow: a port of Darknet over to TensorFlow. Note: the CPU-only Darkflow even runs faster than Darknet with the main drawback being the current Darkflow is not updated to YOLO3
Installing YOLOv2 (Darkflow)
In this guide, we will install the Darkflow flavor of YOLOv2. Again, we recommend the use of virtualenv:
$ cd to/your/git/dir
$ git clone https://github.com/thtrieu/darkflow.git
$ cd darkflow
$ python setup.py build_ext --inplace
$ pip install .
pip install .
basically install the package definitions from the current location i.e. darkflow.
Downloading Pre-trained Weights
Import the weights from Darknet into the weights _templates/weights directory.
wget https://pjreddie.com/media/files/yolov3.weights
mv yolov3.weights starter_guide_img_recog/_templates/weights/yolov3.weights
Alternatively, you can download the weights from the Darkflow's author Google Drive manually into _templates/weights.
π Credits
This project's main contributors are @youonf and @agsl0905.
Special Thanks to @samoshaughnessy for showing us how to use Git.
βοΈ License
The content of this project is licensed under the MIT license