This Streamlit app allows users to (naively) determine their face shape using a camera or uploaded image, and provides relevant measurements (e.g., jawline width, cheekbone width, forehead width, face length). Users can either upload an image or take a photo using their webcam. The app also provides a reset button to clear previous inputs and results for a fresh start. My son and I built this so he could determine what haircut would fit will with his faceshape. Suffice it to say, he's skeptical of the results and would prefer I train an SVM next.
- Upload Image or Take Photo: Users can upload a photo or take one directly with their webcam.
- Face Shape Analysis: The app detects facial landmarks using a 68-point face landmark model and calculates measurements such as:
- Jawline width
- Cheekbone width
- Forehead width
- Face length
- Facial Landmarks Visualization: Draws lines over facial landmarks on the image to illustrate the detected features.
- Results Table: Displays a table of facial measurements calculated from the image.
- Reset Functionality: The reset button clears the current image and measurements and resets the app for a new input.
Before running the app, make sure you have Python installed along with the required libraries:
- Python 3.7+
- Pip (Python package manager)
-
Clone the repository:
git clone https://github.com/your-repo/face-shape-app.git cd face-shape-app -
Install the dependencies:
pip install -r requirements.txt
-
Run the Streamlit app:
streamlit run app.py
The following Python packages are required and listed in requirements.txt:
streamlitopencv-pythonpillowdlibnumpypandasimutilscv2matplotlib
To install them manually, run: ```bash pip install streamlit opencv-python pillow face-alignment numpy pandas ```
-
Upload an image:
- Click on the "Choose an image..." button and select an image file (JPEG, JPG, PNG).
-
Take a photo:
- If you prefer to use the webcam, click the "Take a photo" button to capture a photo directly in the app.
-
View results:
- Once the image is processed, the app will display the following:
- The original image with facial landmarks overlaid.
- A table with the calculated measurements for jawline width, cheekbone width, forehead width, and face length.
- Once the image is processed, the app will display the following:
-
Reset:
- To reset the app, click the Reset button. This will clear the current input and results, allowing you to upload a new image or take another photo.
The app uses the 68-point face landmark model for analysis:
- Jawline (Points 0-16)
- Cheekbones (Approximated)
- Forehead (Approximated using vertical shift)
- Chin (Point 8)
- Upload an image of yourself or take a photo using your webcam.
- The app will detect your face, overlay key facial landmarks, and display the measurements of your facial features.
- Use the measurements for understanding your face shape and finding hairstyle recommendations that suit your face shape.
The app provides a reset button that allows you to clear all previously uploaded images or taken photos and reset all results. This is helpful when switching between images or when you want to start over with a new input.
- Currently, the app is designed for single-face detection. It might not work correctly if multiple faces are present in the uploaded image or photo.
- Face detection depends on lighting conditions and image quality. Ensure your image or webcam photo is well-lit for the best results.
- Rule-based classification is so 1950s. An SVM brings us into the 1960s at least.
This project is licensed under the MIT License. See the LICENSE file for details.