The Face Alignment API is a web service that detects and aligns faces in images using dlib's face detection and facial landmark detection models. It can be used to process images from URLs, align detected faces, and return the aligned face as a base64-encoded string.
This tool can be particularly useful for scraping data when creating datasets.
Before you begin, ensure you have the following dependencies installed:
- Python 3.x
- Flask (for the web application)
- dlib (for face detection and facial landmark detection)
- OpenCV (for image processing)
- Requests (for making HTTP requests)
You can install these dependencies using pip
. For example:
pip install flask dlib opencv-python-headless requests
To get started with the Face Alignment API, follow these steps:
-
Clone the repository:
git clone https://github.com/yourusername/face-alignment-api.git
-
Start the application
python face-alignment-api/app.py
The API will be accessible at http://localhost:5000.
The API provides a single endpoint:
/detect_face (POST)
: Accepts a JSON request with an image URL and returns the aligned face as a base64-encoded string.
Send a POST request to the /detect_face
endpoint with the following JSON payload:
{
"image_url": "https://example.com/your_image.jpg"
}
Replace "https://example.com/your_image.jpg" with the URL of the image you want to process.
The API will respond with a JSON object containing the aligned face as a base64-encoded string:
{
"aligned_face_base64": "base64_encoded_string_here"
}
This project is licensed under the MIT License - see the LICENSE file for details.