Face Recognition Service with Python Dlib Flask

Written by tabvn | Published 2017/12/21
Tech Story Tags: python | flask | face-recognition | facedetection | face-recognition-service

TLDRvia the TL;DR App

While working on Camera Live Stream Service i decided will add machine learning in to this project. That mean our camera can be learn to know who is family member, during stream video and send warning to the owner if someone in the camera is not family members. that is just idea you may have more idea to use this for other devices maybe Door open …

IDE for Python Development Pycharm

I recommend download Pycharm tool for Python development.

Python Virtual environment Installation

sudo pip install virtualenv

Create new python project

mkdir project

cd project

virtualenv venv

Setup Boost Python

We need boost python when compile Dlib c++ for Python module

To compile Boost.Python yourself download boost from http://boost.org and then go into the boost root folder

./bootstrap.sh --with-libraries=python./b2sudo ./b2 install

Setup dlib C++ library

Dlib is a modern C++ toolkit containing machine learning algorithms and tools for creating complex software in C++ to solve real world problems. https://github.com/davisking/dlib

brew install cmake

git clone https://github.com/davisking/dlib.git

cd dlibmkdir build; cd build; cmake .. -DDLIB_USE_CUDA=0 -DUSE_AVX_INSTRUCTIONS=1; cmake --build .

Activate Python Virtual Environment in our Python project

cd /PATH-OUR-PROJECTcd venvsource bin/activate

python setup.py install --yes USE_AVX_INSTRUCTIONS --no DLIB_USE_CUDA

Flask

Use flask as Python framework build api service. Api http://flask.pocoo.org/docs/0.12/api

from flask import Flask,Response,jsonapp = Flask(__name__)

@app route('/', methods=['GET'])def home():return Response(json.dumps({"api": "1.0"}), status=200, mimetype='application/json')

if __name__ == "__main__":

app.run()

Database

we can use any database to store users info. in this project i just use sqlite3 default support by Python. Tool for design slqlite http://sqlitebrowser.org/

Video

Part 1: Setup and begin with Flask

Part 2:Face Recognition

Part 3: Basic Front-End

Please Subscribe me on Youtube for next part.

Github: https://github.com/tabvn/face-recognition-service


Published by HackerNoon on 2017/12/21