This project is a Python application designed for image processing with a focus on face feature extraction.
It uses libraries like dlib and mediapipe for advanced face detection and processing.
-
Clone the repository.
-
Navigate to the project directory.
-
Create a virtual environment:
python -m venv .venv- Activate the virtual environment:
- On Windows:
.venv\Scripts\activate- On Unix or MacOS:
source .venv/bin/activate- Install the dependencies:
pip install -r requirements.txtBefore running the application, download the shape_predictor_68_face_landmarks.dat file for dlib:
-
Download the model file from Dlib's model repository or a trusted source.
-
Unzip the file and place it in the
modelsdirectory at the root of the project. -
Ensure the
config.pyin thesettingsdirectory is set correctly:
APP_PATH_PARAMS_JSON_FILE = 'params.json'
APP_PATH_MODEL_DLIB_FILE = 'models/shape_predictor_68_face_landmarks.dat'Customize the application behavior by modifying the params.json file in the root directory:
{
"input_path": "",
"models": [
"dlib",
"mediapipe"
],
"images_format": [
".png",
".jpg",
".jpeg"
],
"keypoints_color": [255, 255, 255],
"margin_ratio": 0.1,
"num_threads": 8
}-
input_path: Path to the directory containing the images to be processed. -
models: List of models to use for face feature extraction. Supported models are dlib and mediapipe. -
images_format: List of image file formats to be processed. For example:.png,.jpg,.jpeg. -
keypoints_color: Color of the keypoints (in BGR format) to be drawn on the images. It's an array of three integers representing Blue, Green, and Red color values. -
margin_ratio: The margin ratio around the detected face for cropping. A smaller value results in a tighter crop around the face. -
num_threads: The number of threads to use for image processing. Increasing this number can speed up processing on multi-core systems.
To run the application, use the following command:
python run.py [--debug]The --debug argument is optional and enables the debug mode for additional logging and process details.
-
run.py: The entry point of the application. It parses command-line arguments and initializes the application with the given parameters. -
main.py: Contains the main logic for processing images using multithreading. -
extractor.py: Includes functions for face feature extraction usingdlibandmediapipe. -
utils.py: Provides utility functions used across the application. -
config.py: Contains configuration settings for the application.
This project is open-sourced and available to everyone under the MIT License.