This project is a real-time face recognition system built with the power of MTCNN (Multi-task Cascaded Convolutional Networks) for accurate face detection and ArcFace for highly discriminative face recognition.
The system is capable of detecting faces from images or live video streams and recognizing individuals with high precision, even under challenging conditions such as varying lighting, angles, and facial expressions.
By combining MTCNN’s robust face localization with ArcFace’s state-of-the-art feature embeddings, this project achieves:
- Accurate face detection with bounding boxes and facial landmarks.
- Discriminative face recognition using deep feature embeddings.
- Real-time performance for practical applications.
Python 3.8.0- Dependencies are listed in
requirements.txt
git clone https://github.com/salauddintapu/face_recognition.git
cd face_recognition
⚠️ Note: It is recommended to use a virtual environment (venvorconda). After creating the environment, install bcolz first:
conda create -n myenv python==3.8.0
conda install -c conda-forge bcolz
pip install -r requirements.txtThis section provides step-by-step instructions on how to use the face recognition api.
Prepare the environment by following the steps described in Getting Started section. Keep in mind that after setting up the venv, you must install bcolz first. Installing Python 3.8.0 and bcolz may take some time. Then install the dependencies listed in requirements.txt
- In the
app.py, changelocalhostto machine's IP address if you are using a remote server. - If
cudais avaiable the api will use your machine's GPU otherwise it will run oncpu.
To run the API, open your terminal and run,
conda activate myenv
python app.pyTo prepare your facebank you have to collect face data and store them in arcface/data/facebank directory. You must follow the following structure while storing data:
facebank/
├── name-of-person1/images of person1
├── name-of-person2/images of person2
├── name-of-person3/images of person3
⚠️ Note: Use cropped faces of the persons you want to recognize. Name the folder after the name of the person and store images of that person in the named folder.
The api currently uses the
Flasklibrary. In the next update,Flaskwill be removed andFastAPIwill be adopted.
curl --location 'http://localhost:5000/rec' \
--header 'Content-Type: application/json' \
--data '{
"file": "image in base64 format"
}'| Parameter | Type | Description |
|---|---|---|
file |
base64 |
Convert your image to base64 format. API uses opencv to process it. |
{
"names": "None or list of names",
"bboxes": "None or list of bbox of face coordinates",
"scores": "None or list of confidence scores"
}I would like to acknowledge the following resources and works that made this project possible:
- MTCNN Face Detector
- MTCNN Implementation
- ArcFace: Additive Angular Margin Loss for Deep Face Recognition
- InsightFace Implementation
- OpenCV
- The open-source community for providing accessible libraries and frameworks that accelerate research and development in computer vision.