This application is a desktop facial recognition system that utilizes a Flask API for handling facial recognition tasks. The system can add new individuals to the database, upload their images, and update the facial recognition model. It also recognizes individuals and retrieves their details from the database.
- Add new individuals to the database
- Upload images for new individuals
- Update the facial recognition model with new images
- Recognize individuals from images
- Retrieve recognized individuals' details from the database
- Python: Core language
- Flask: Web framework for the API
- OpenCV: Image processing
- dlib: Facial recognition
- scikit-learn: Machine learning (SVM classifier)
- pyodbc: Database connectivity
- SQL Server: Database management
- pickle: Model and data serialization
- Python 3.x
- SQL Server
- Required Python libraries (listed in
requirements.txt
)
- Clone the repository:
git clone https://github.com/ImenBenAmar/face_identification.git cd facial-recognition-app
- Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate
- Install the required libraries:
pip install -r requirements.txt
- Download dlib models and place them in the face_model directory:
- shape_predictor_68_face_landmarks.dat
- dlib_face_recognition_resnet_model_v1.dat
- Set up SQL Server:
- Create a database.
- Ensure the connection string in the code matches your SQL Server setup.
- Start the Flask API:
python API.py
Creates a new folder for a person and adds their details to the database.
POST /create_folder
- Request Body:
{
"name": "John",
"surname": "Doe",
"phone_number": "1234567890",
"cin": "ABC123"
}
- Response:
{
"message": "Person added successfully and folder created successfully.",
"id": 1,
"path_folder": "./face_model/data/1"
}
Uploads images to the person's folder.
POST /upload_images
-
Request Form:
- images: List of image files
- id: Person ID
-
Response
{
"message": "Images uploaded successfully to ./face_model/data/1."
}
Updates the facial recognition model with new images.
POST /update_model
- Request Body:
{
"id": 1
}
- Response:
{
"message": "Model updated successfully."
}
Recognizes a person from an image.
POST / recognize
- Request Body:
- Image file
- Response:
{
"id": "1",
"confidence": 0.95,
"name": "John",
"surname": "Doe",
"cin": "ABC123",
"phone_number": "1234567890"
}
- Add a new person: Use the /create_folder endpoint to add a new person's details and create a folder for their images.
- Upload images: Use the /upload_images endpoint to upload images of the new person.
- Update the model: Use the /update_model endpoint to update the facial recognition model with the new images.
- Recognize a person: Use the /recognize endpoint to recognize a person from an image and retrieve their details from the database.
The database contains a single table named Persons
with the following columns:
Column | Type | Description |
---|---|---|
id |
INT |
Primary Key. Unique identifier for each person |
nom |
VARCHAR |
First name of the person |
prenom |
VARCHAR |
Surname of the person |
numero_telephone |
VARCHAR |
Phone number of the person |
cin |
VARCHAR |
National identification number of the person |
folder_path |
VARCHAR |
Path to the folder containing the person's images |
Contributions are welcome! Please open an issue or submit a pull request with your changes.