{"id":18428382,"url":"https://github.com/rodrigobressan/face2data","last_synced_at":"2025-04-07T16:34:30.967Z","repository":{"id":39734563,"uuid":"221066742","full_name":"rodrigobressan/face2data","owner":"rodrigobressan","description":"Face2Data: Extract meaningful information from a person face in less than a second. Powered by Keras and Flask.","archived":false,"fork":false,"pushed_at":"2022-09-23T22:30:29.000Z","size":22891,"stargazers_count":110,"open_issues_count":8,"forks_count":11,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-11-05T16:00:25.582Z","etag":null,"topics":["face-recognition","flask","keras","multi-output-networks","utkface"],"latest_commit_sha":null,"homepage":"https://face2data.herokuapp.com/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rodrigobressan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-11-11T20:43:58.000Z","updated_at":"2023-10-08T17:29:37.000Z","dependencies_parsed_at":"2022-09-20T12:54:11.247Z","dependency_job_id":null,"html_url":"https://github.com/rodrigobressan/face2data","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodrigobressan%2Fface2data","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodrigobressan%2Fface2data/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodrigobressan%2Fface2data/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodrigobressan%2Fface2data/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rodrigobressan","download_url":"https://codeload.github.com/rodrigobressan/face2data/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223286369,"owners_count":17120000,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["face-recognition","flask","keras","multi-output-networks","utkface"],"created_at":"2024-11-06T05:13:35.737Z","updated_at":"2024-11-06T05:13:36.394Z","avatar_url":"https://github.com/rodrigobressan.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Face2Data](/static/face2data.png)\n\n[![Python 3.6](https://img.shields.io/badge/python-3.6-brightgreen)](https://www.python.org/)\n[![Build Status](https://travis-ci.org/rodrigobressan/face2data.svg?branch=master)](https://travis-ci.org/rodrigobressan/face2data)\n[![Coverage Status](https://coveralls.io/repos/github/rodrigobressan/face2data/badge.svg?branch=master)](https://coveralls.io/github/bresan/face2data?branch=master)\n[![GitHub license](https://img.shields.io/github/license/rodrigobressan/face2data)](https://github.com/rodrigobressan/face2data/blob/master/LICENSE.md)\n\n[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy)\n\n## Extract information from a person face in less than a second\n\nThis 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.\n\n## Running the project\n\n### Using Docker\n\nIf you want to quickly build and run the server, you can use Docker.\nFirst, install [docker](https://docs.docker.com/install/) for your architecture.\nThen build the container:\n\n\n```bash\n$ docker build -t face2data .\n```\n\nThe container will use gunicorn to deploy the application on port 5000. You\nthus should run the container and map this port to your host:\n\n\n```bash\n$ docker run -p 5000:5000 face2data\n```\n\nYou can then open your browser to [http://127.0.0.1:5000/](http://127.0.0.1:5000/)\nto see the interface.\n\n![static/docker-server.png](static/docker-server.png)\n\n### From Source\n\nA live demo of application is available on the [https://face2data.herokuapp.com/](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:\n\nIn 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](https://pip.pypa.io/en/stable/), as below:\n\n```bash\npip install -r requirements.txt\n```\n\nAfter this, navigate to the project root directory and run the following command on the terminal to start the application:\n\n```bash\nflask run\n```\n\nThis should start a new server on the port 5000. You can then access the applicaton by opening the address [http://localhost:5000/](http://localhost:5000/) on the browser.\n\n## The dataset\n\nThe 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](https://pip.pypa.io/en/stable/).\n\n\u003cbr/\u003e\n\n## Training phase\n\nOur 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.\n\nWe 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:\n\n### Accuracy for gender feature\n\n\u003cdiv style=\"width: 100%; text-align: center\"\u003e\n    \u003cimg style='width: 80%; object-fit: contain' src=\"/images/acc_gender.png\"/\u003e\n\u003c/div\u003e\n\n\n### Accuracy for race feature\n\n\u003cdiv style=\"width: 100%; text-align: center\"\u003e\n    \u003cimg style='width: 80%; object-fit: contain' src=\"/images/acc_race.png\"/\u003e\n\u003c/div\u003e\n\n\n### Mean Absolute Error for age feature\n\n\u003cdiv style=\"width: 100%; text-align: center\"\u003e\n    \u003cimg style='width: 80%; object-fit: contain' src=\"/images/mae_age.png\"/\u003e\n\u003c/div\u003e\n\n\n### Overall loss\n\n\u003cdiv style=\"width: 100%; text-align: center\"\u003e\n    \u003cimg style='width: 80%; object-fit: contain' src=\"/images/overall_loss.png\"/\u003e\n\u003c/div\u003e\n\n## TODO\n\n- Add unit tests for both Flask application and model predictions\n- Setup Continuous Integration and Deployment to automatically deploy on Heroku upon a new commit\n- Add SHAP model explanations\n\n## References\n\nUTK Face Dataset: [http://aicip.eecs.utk.edu/wiki/UTKFace](http://aicip.eecs.utk.edu/wiki/UTKFace)\n\nKeras Multi-output documentation: [https://keras.io/getting-started/functional-api-guide/](https://keras.io/getting-started/functional-api-guide/)\n\nSanjayaSubedi post on multi-output model: [https://sanjayasubedi.com.np/deeplearning/multioutput-keras/](https://sanjayasubedi.com.np/deeplearning/multioutput-keras/)\n\nPyImageSearch post on FashionNet: [https://www.pyimagesearch.com/2018/06/04/keras-multiple-outputs-and-multiple-losses/](https://www.pyimagesearch.com/2018/06/04/keras-multiple-outputs-and-multiple-losses/)\n\nPlotly: [https://plot.ly/](https://plot.ly/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frodrigobressan%2Fface2data","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frodrigobressan%2Fface2data","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frodrigobressan%2Fface2data/lists"}