📌 This repository is for the moment only for dev, please do not put this version in production.
✅ App tested on macOS 13.1 (M1 Pro), Ubuntu 22.04 LTS (Intel Core i7) : Google Chrome
🚀 This project is a facial recognition app. It detects in real time faces present in a database on a live stream from the webcam. The good point of the MVC architechture implemented is that this facial recognition framework can be implemented in all type of device by using API endpoints.
- Back-end : django + django REST Framework
- Front-end : ReactJS
- Database : PostgreSQL
📰 Face recognition framework is adapted from DeepFace. It is a hybrid face recognition framework wrapping state-of-the-art models: VGG-Face
, Google FaceNet
, OpenFace
, Facebook DeepFace
, DeepID
, ArcFace
, Dlib
and SFace
.
The model to be used as well as the distancing method can be directly selected from the file .env file
First, clone the project by executing :
git clone git@github.com:sachabinder/faceRecognition.git
then, you can access the repository folder on your local machine by executing :
cd faceRecognition
You are now ready to go !
To build docker images of containers you should run :
docker-compose build
To run the app on local machine you should run :
docker-compose up
ℹ️ PLEASE WAIT THE COMPLETE STARTING OF THE SERVICES, it shoud take few minutes. In fact, front can take some time to build and back should dowload model weights. Everthing is started when you see :
facerecognition-front-1 | webpack 5.75.0 compiled successfully in 6159 ms
facerecognition-back-1 | Watching for file changes with StatReloader
facerecognition-back-1 | Performing system checks...
facerecognition-back-1 |
facerecognition-back-1 | System check identified no issues (0 silenced).
facerecognition-back-1 | March 06, 2023 - 23:14:51
facerecognition-back-1 | Django version 4.1.2, using settings 'back.settings'
facerecognition-back-1 | Starting development server at http://0.0.0.0:8000/
facerecognition-back-1 | Quit the server with CONTROL-C.
You can now access the app (on port 8000 for the back and 8080 for the front which can be change in env file ) by :
- localhost:8000 for the REST api
- localhost:8000/admin for the django admin
- localhost:8080 for the web app
You can access to the PostgreSQL database shell (in the assigned docker container) by running :
docker exec -it $(docker ps -f 'name=db' --format '{{.ID}}') psql -U name
You can access the prompt of back-end docker container by running :
docker-compose exec back /bin/bash
To create a super user from the back-end, you should run :
python manage.py createsuperuser
To create migration from the back-end (TO BE DONE AFTER MODEL MODIFICATIONS), you should run :
python manage.py makemigrations
To execute migrations, you shoud run (automaticly done at container starting) :
python manage.py migrate
To manage dependancy on the backend, we are using poetry. To add a Python module, you should add it on pyproject file and then re-build Docker containers.
You can access the shell of front-end docker container by running :
docker-compose exec front /bin/sh
To start/restart the webpack dev server, run on the container :
/usr/local/bin/npm run dev
To manage dependancy on the frontend, we are using npmJS. To add a Node module, you should add it on package.json and then re-build the back Docker container.
You can also execute in the front-end container :
/usr/local/bin/npm install [your-package-name] -D
Then, the package.json will be automatically update.
If you want to test the linting of your file before pushing it on the repo, you can install the eslint extension in VS Code, or just use the following lines if you have previously installed npm and the eslint dependency:
npm run lint
and if you think the errors can be corrected directly by the linter without problem:
npm run lint:fix
Variable | Description | Dev value |
---|---|---|
DB_HOST | Host name of the db | db |
DB_PORT | Port of the DB (in container). | 5432 |
DB_USER | User of the DB | user |
DB_NAME | Name of the DB | name |
DB_PASSWORD | Password of the DB | password |
BACK_PORT | External back port access | 8000 |
FRONT_PORT | External front port access | 8080 |
DEBUG | Debug mode execution | True |
DOMAIN_NAME | Domaine name to use in production. Requests from other domain will be rejected. | 127.0.0.1 |
SECURE_SSL_REDIRECT | Automaticly redirect non HTTPS requests in HTTPS. To be leave at False if an other proxy is already doing this work | False |
FACE_DETECTION_MODEL_NAME | Face recognition model name. Model available : VGG-Face , Facenet , OpenFace , DeepFace , DeepID |
VGG-Face |
FACE_DETECTION_DISTANCE_METRIC | Distance metric to compare embedings. Distance available : cosine , euclidean , euclidean_l2 |
cosine |
FACE_DETECTION_DETECTOR_BACKEND | face detector backend. backend available : opencv , retinaface , mtcnn , ssd , dlib , mediapipe |
opencv |
Command to run to generate a secret django key (you should get django installed)
python3 -c 'from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())'