• Stars
    star
    113
  • Rank 310,115 (Top 7 %)
  • Language
    Python
  • License
    MIT License
  • Created about 5 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Face2Data: Extract meaningful information from a person face in less than a second. Powered by Keras and Flask.

Face2Data

Python 3.6 Build Status Coverage Status GitHub license

Deploy

Extract information from a person face in less than a second

This project is intended to showcase the usage of a Keras multi-output model to predict age, gender and ethnicity from a given persons face. The generated model is served through a REST API provided by Flask running on Python 3.6.

Running the project

Using Docker

If you want to quickly build and run the server, you can use Docker. First, install docker for your architecture. Then build the container:

$ docker build -t face2data .

The container will use gunicorn to deploy the application on port 5000. You thus should run the container and map this port to your host:

$ docker run -p 5000:5000 face2data

You can then open your browser to http://127.0.0.1:5000/ to see the interface.

static/docker-server.png

From Source

A live demo of application is available on the https://face2data.herokuapp.com/ address (it may take some time to load due to Heroku's free plan), but if you instead would like to run it locally, below are the needed steps:

In order to run this project locally, you first need to clone this repository into our machine and then install the required dependencies. The project dependencies are located in the requirements.txt file. You can install them by using PiP, as below:

pip install -r requirements.txt

After this, navigate to the project root directory and run the following command on the terminal to start the application:

flask run

This should start a new server on the port 5000. You can then access the applicaton by opening the address http://localhost:5000/ on the browser.

The dataset

The UTKFace dataset is a large dataset composed of over 20 thousand face images with their respective annotations of age, gender and ethnicity. The images are properly cropped into the face region, but display some variations in pose, illumination, resolution, etc. If you want to know more about this dataset, please check their website.


Training phase

Our Neural Network is composed of three major branches, one for each of the features we are trying to predict. We have used a default set of hidden layers, based on the stacking of several Conv2D with ReLU activation, followed by a Batch Normalization, then a MaxPooling and finally a Dropout layer.

We performed our training phase by adopting an Adam optimizer with a learning rate of 1e-4 and a decay based on the initial learning rate divided by the number of epochs. A hundred epochs were used to train our model, in which we have seen that we had an efficient learning process, asserted by plotting both the accuracy and loss curves, as shown below:

Accuracy for gender feature

Accuracy for race feature

Mean Absolute Error for age feature

Overall loss

TODO

  • Add unit tests for both Flask application and model predictions
  • Setup Continuous Integration and Deployment to automatically deploy on Heroku upon a new commit
  • Add SHAP model explanations

References

UTK Face Dataset: http://aicip.eecs.utk.edu/wiki/UTKFace

Keras Multi-output documentation: https://keras.io/getting-started/functional-api-guide/

SanjayaSubedi post on multi-output model: https://sanjayasubedi.com.np/deeplearning/multioutput-keras/

PyImageSearch post on FashionNet: https://www.pyimagesearch.com/2018/06/04/keras-multiple-outputs-and-multiple-losses/

Plotly: https://plot.ly/

More Repositories

1

entity_embeddings_categorical

Discover relevant information about categorical data with entity embeddings using Neural Networks (powered by Keras)
Python
70
star
2

android_tmdb_clean_architecture

Showcase of clean architecture concepts along with Continuous Integration and Development for modular Android applications. Includes test suits (functional and unit tests) along with code coverage.
Kotlin
66
star
3

digipathos

Brazilian Agricultural Research Corporation (EMBRAPA) fully annotated dataset for plant diseases. Plug and play installation over PiP.
Python
42
star
4

keras-multi-output-model-utk-face

Exploring Keras functional API to build a multi-output model to predict race, gender and sex on UTK Face dataset.
Jupyter Notebook
24
star
5

PADify

Framework to perform PAD (Presentation Attack Detection) on Facial Recognition systems through intrinsic properties and Deep Neural Networks - Still Under Development
Python
18
star
6

keras_boston_housing_price

Keras 101: A simple Neural Network for House Pricing regression
Jupyter Notebook
15
star
7

android_background_youtube_player

Play youtube videos on background with ExoPlayer
Java
13
star
8

testing-ML-models-with-pytest

Software Engineering for Data Scientists 01 - Testing Machine Learning models with PyTest
Python
4
star
9

android_github_mvvm

Demo project to showcase the MVVM (Model-View-ViewModel) Architecture by consuming the GitHub API
Java
3
star
10

ServletsLearning

This is a repo for learning the basics of Java Servlets. It includes a few examples using sessions and some usage of taglibs.
Java
2
star
11

android-filemanager

Simple File Manager for Android
Java
1
star
12

sample_android_architecture_components

Project showcasing the usage of Android Architecture Components
Kotlin
1
star
13

meu_candidato

Projeto para Desenvolvimento Web 2
JavaScript
1
star
14

react_native_apod

NASA APOD (Astronomic Picture of the Day) with React Native
JavaScript
1
star