face7 / README.md
Mahir1426's picture
Upload 13 files
fe047f5 verified
---
title: Face Shape Detection
emoji: 👤
colorFrom: blue
colorTo: purple
sdk: docker
pinned: false
license: mit
app_port: 7860
short_description: AI face shape detection with MediaPipe & ML
---
# Face Shape Detection
An AI-powered application that analyzes facial features to determine face shape using MediaPipe landmarks and machine learning.
## Features
- **Real-time face shape detection** from uploaded images
- **5 face shape categories**: Heart, Oval, Round, Square, Oblong
- **Facial measurements** with confidence scores
- **Interactive web interface** with image upload
- **RESTful API** for integration
## How it Works
1. **Face Detection**: Uses MediaPipe to detect and extract facial landmarks
2. **Feature Extraction**: Calculates key facial measurements and ratios
3. **ML Classification**: Uses a trained Random Forest model to predict face shape
4. **Results**: Returns face shape, confidence scores, and facial measurements
## API Endpoints
- `POST /analyze` - Upload an image for face shape analysis
- `GET /` - Web interface for image upload
- `GET /video_feed` - Real-time video feed (if camera available)
## Usage
1. Upload an image using the web interface
2. The system will analyze the face and return:
- Detected face shape
- Confidence scores for all categories
- Facial measurements (length, width, etc.)
- Annotated image with landmarks
## Technical Details
- **Framework**: Flask
- **Computer Vision**: MediaPipe, OpenCV
- **ML Model**: Random Forest (scikit-learn)
- **Image Processing**: Smart preprocessing with face detection
- **Deployment**: Docker container optimized for Hugging Face Spaces
## Model Performance
The model uses optimized features extracted from 468 facial landmarks and achieves high accuracy in face shape classification across diverse face types.
## Requirements
- Python 3.10+
- MediaPipe
- OpenCV
- scikit-learn
- Flask
- NumPy
## License
MIT License - feel free to use and modify for your projects.