"FaceFit Barber" is an application designed to help users find the perfect haircut style that fits their face shape. By utilizing camera integration and AI models, this app offers personalized hairstyle recommendations and enhances the barbershop experience for both customers and barbers.
- π· Face Capture: Utilizes webcam to capture and analyze the user's face shape.
- πΌοΈ Image Upload: Allows users to upload a face image from their local device.
- π§ AI Face Shape Analysis: Processes the captured or uploaded image using an AI model to determine the user's face shape.
- βοΈ Hairstyle Recommendations: Suggests suitable haircuts based on the detected face shape.
- π§ Interactive UI: Provides smooth routing and a user-friendly interface.
- π± Responsive Design: Optimized for various devices, including mobile and desktop screens.
- π Online Deployment: Frontend and AI backend services are deployed online.
Frontend:
- React + Vite
- Tailwind CSS
- React Router DOM
- React Webcam
- Axios
- Vercel
Backend:
- JavaScript
- Node.js
- Express.js
- FastAPI
- RESTful APIs
- Hugging Face Spaces
AI Model:
- Python
- TensorFlow / Keras
- NumPy
- Pillow
- Google Colab
- Jupyter Notebook
Data Science:
- Python
- Pandas
- NumPy
- Matplotlib
- Seaborn
- Streamlit
- Jupyter Notebook
FaceFit-Barber-Application/
βββ FaceFit-Barber-FrontEnd/
βββ FaceFit-Barber-BackEnd/
βββ FaceFit-Barber-Model-AI/
βββ FaceFit-Barber-Data-Science/
βββ README.md
This main repository is used to organize all FaceFit Barber project modules. Each module has a different responsibility in the project workflow.
The frontend repository contains the user interface of the FaceFit Barber web application.
Scope:
- Building the web interface using React + Vite.
- Handling page navigation using React Router DOM.
- Providing webcam-based face capture using React Webcam.
- Providing image upload functionality.
- Sending image data to the backend AI service.
- Displaying face shape analysis results.
- Displaying hairstyle recommendations.
- Deploying the frontend application using Vercel.
The backend repository contains API routing and AI service integration for the application.
Scope:
- Handling backend routes using Express.js.
- Receiving uploaded images from the frontend.
- Connecting the frontend with the AI model service.
- Managing local backend development.
- Providing FastAPI ML service for AI inference.
- Returning face shape prediction, confidence score, probabilities, and hairstyle recommendations.
- Deploying the AI backend service using Hugging Face Spaces.
The Model AI repository contains the AI model development process and exported model artifacts.
Scope:
- Building and training the face shape classification model.
- Preparing model input configuration.
- Saving class names and preprocessing configuration.
- Exporting the trained model in
.kerasand SavedModel formats. - Storing model evaluation results such as confusion matrix and training curves.
- Documenting the model development process using Jupyter Notebook.
- Providing the model used by the backend AI service.
The Data Science repository contains dataset preparation, data analysis, and supporting visualization.
Scope:
- Collecting and organizing datasets.
- Filtering and cleaning face image datasets.
- Preparing datasets before and after class balancing.
- Performing exploratory data analysis.
- Creating A/B testing analysis.
- Providing dashboard visualization using Streamlit.
- Supporting the Model AI repository with cleaned and structured datasets.
User opens the FaceFit Barber web application
β User captures or uploads a face image
β Frontend sends the image to the AI backend API
β Backend preprocesses the image
β AI model predicts the user's face shape
β Backend returns prediction result and hairstyle recommendations
β Frontend displays the result to the user
The AI model classifies user face images into the following face shape categories:
diamond
heart
oval
round
square
The AI model is built using TensorFlow/Keras and is used to classify face shape from an input image.
Input specification:
224 x 224 x 3
Preprocessing steps:
- Convert image to RGB format.
- Apply center crop with a crop ratio of 0.88.
- Resize image to 224 x 224 pixels.
- Convert image into a
float32array. - Pass the image into the trained model.
The model returns probability scores for each class. The class with the highest probability is selected as the final face shape prediction.
Example response:
{
"success": true,
"faceShape": "Heart",
"confidence": 0.637,
"hairstyle": [
"Textured Fringe",
"Side Part",
"Low Fade"
],
"message": "Foto berhasil dianalisis"
}The frontend application is deployed using Vercel.
Live Website:
https://facefit-barber.vercel.app/
Vercel is used to publish the React/Vite frontend application and connect it with the deployed AI backend service.
The AI backend service is deployed using Hugging Face Spaces.
Production AI Backend:
https://justblaisee-facefit-ml-service.hf.space
Main endpoint used by the frontend:
https://justblaisee-facefit-ml-service.hf.space/api/faces/analyze
git clone https://github.com/raphael707/FaceFit-Barber-Application.git
cd FaceFit-Barber-ApplicationIf the repository uses submodules, initialize and update them:
git submodule update --init --recursivecd FaceFit-Barber-BackEnd
npm installcd ../FaceFit-Barber-FrontEnd
npm installcd ../FaceFit-Barber-BackEnd/ml-service
pip install -r requirements.txtuvicorn main:app --reload --port 8000The FastAPI ML service will run at:
http://127.0.0.1:8000
FastAPI documentation:
http://127.0.0.1:8000/docs
Open a new terminal:
cd FaceFit-Barber-BackEnd
npm startThe Express backend will run at:
http://localhost:3000
Open another terminal:
cd FaceFit-Barber-FrontEnd
npm run devOpen the frontend URL shown in the terminal, usually:
http://localhost:5173
For frontend integration, create a .env file inside the FaceFit-Barber-FrontEnd folder.
For production AI backend:
VITE_API_URL=https://justblaisee-facefit-ml-service.hf.spaceFor local Express backend:
VITE_API_URL=http://localhost:3000For direct local FastAPI ML service:
VITE_API_URL=http://127.0.0.1:8000- This repository acts as the main project repository.
- Frontend, backend, model AI, and data science modules are separated into their own repositories or submodules.
- Large datasets and model files may require external storage or Git LFS.
- Environment variables such as
.envshould not be committed to GitHub. - The deployed Hugging Face Space may take longer on the first request if the service is inactive.
- Make sure each submodule is updated before committing changes to the main repository.
To update all submodules based on the commits recorded in this main repository:
git submodule update --init --recursiveTo update submodule references after changes are pushed inside each module:
git add FaceFit-Barber-FrontEnd FaceFit-Barber-BackEnd FaceFit-Barber-Model-AI FaceFit-Barber-Data-Science
git commit -m "Update project submodule references"
git push origin mainFeel free to fork this repository and submit a pull request.
For team collaboration, it is recommended to:
- Create a new branch.
- Commit changes clearly.
- Push the branch.
- Open a pull request.
- Merge after review.
MIT License - Use freely with attribution.
Developed as part of a Capstone Project to innovate the barbershop and grooming experience through AI-based face shape analysis and personalized hairstyle recommendation.
