ohjho / starter_guide_face_recog

A Starter Guide to Face Detection & Recognition in Python/ Jupyter Notebook

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

πŸš€ A Starter Guide to Face Detection & Recognition in Python

made-with-python MIT license tested-on-osx

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

  1. Clone this repo:
$ git clone https://github.com/ohjho/starter_guide_img_recog.git
$ cd start_guide_img_recog
  1. 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.

  1. Start Jupyter notebook
$ cd _templates
$ jupyter notebook
  1. 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

Open CV

Dlib

YOLO

Libraries

Documentations


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:

  1. Darknet: The 'offical' implementation written in C
  2. AlexeyAB/ Darknet: a fork of Darknet to support Windows and Linux
  3. 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

About

A Starter Guide to Face Detection & Recognition in Python/ Jupyter Notebook


Languages

Language:Jupyter Notebook 100.0%