This is a Flask-based API for detecting face shapes from images using OpenCV and a pre-trained landmark model. The API accepts an image URL, processes the image, and returns the detected face shape.
- Face Shape Detection: Identifies the face shape (Round, Oval, Rectangle, Square, Heart-Shaped, Diamond Shaped) based on facial landmarks.
- Authorization: API requires an API key for access.
- Error Handling: Handles cases like missing images, failed downloads, and unauthorized access.
- Python 3.x
- Flask
- OpenCV
- NumPy
- Requests
-
Clone the repository:
git clone https://github.com/hirunaofficial/Face-Shape-Detection-API.git cd Face-Shape-Detection-API
-
Install the required packages:
pip install -r requirements.txt
-
Run the application:
python main.py
-
Test the API:
- Use a tool like Postman or
curl
to send a POST request tohttp://127.0.0.1:5000/detect_face_shape
with a JSON payload containing theimage_url
.
- Use a tool like Postman or
POST /detect_face_shape
Authorization: Bearer <your_api_key>
{
"image_url": "https://example.com/path/to/your/image.jpg"
}
{
"status": "success",
"shape": "Round Face",
"cheek_ratio": 0.85,
"jaw_ratio": 0.75,
"forehead_ratio": 0.80,
"chin_ratio": 0.35,
"head_ratio": 1.20,
"jaw_angle": 45.0
}
{
"status": "error",
"status_code": "no_face_detect",
"message": "No face detected"
}
This project is licensed under the GPL-3.0 License. See the LICENSE file for details.
- Author: Hiruna Gallage
- Website: hiruna.dev
- Email: hello@hiruna.dev