--- title: AIFaceShapeDetector emoji: ⚡ colorFrom: blue colorTo: gray sdk: gradio sdk_version: 6.5.1 app_file: app.py pinned: false license: cc-by-nc-4.0 short_description: Smple Face Shape Detection using Mediapipe and ML --- ## AI Face Shape Detector (Hugging Face Space) Upload a front-facing photo (or use your webcam) and this Space predicts your **face shape** and shows a **MediaPipe face-mesh overlay** plus **confidence scores**. Full app available at [attractivenesstest.com/face_shape](https://attractivenesstest.com/face_shape). ### Supported face shapes - **Oval** - **Round** - **Square** - **Heart** - **Oblong** ### How it works (from `app.py`) - **Face landmark extraction**: Uses **MediaPipe Face Mesh** (up to **478 landmarks**) to detect a single face. - **Landmark normalization**: Centers landmarks using the eye/iris center, applies roll correction, and scales by inter-eye distance. - **Classification**: Flattens normalized landmark coordinates and runs a **pickled scikit-learn classifier** (loaded from `face_shape_model.pkl`) with a label encoder (`label_encoder_rf.pkl`). - **Outputs**: - An image with a face mesh/contour overlay - A formatted result card (shape + description + styling tip) - Per-class confidence scores ### Tips for best results - Use a **front-facing** photo with good lighting - Ensure your **entire face** is visible - Remove glasses if possible - Avoid tilting your head ### Run locally ```bash python -m venv .venv source .venv/bin/activate pip install -r requirements.txt python app.py ``` Then open the Gradio URL printed in your terminal. ### Notes / limitations - This demo expects **one clear, visible face** in the image (`max_num_faces=1`). - If no face is detected, the app will return an error message asking for a clearer photo. - Uploaded images are processed in-memory by the app; the code does not intentionally save uploads to disk. ---