Hey there! This project is all about classifying hair types. The big dream is to sort hair by specific types from 1a to 4c, but for now, we're keeping it simple with just three main types: Curly, Straight, and Wavy.
Finding hairstyles that work for my hair type has always been a struggle. Which is when I had the idea to make something to help others who face the same problem. So, here we are, with this hair-type classifier!
First things first, grab the code:
git clone https://github.com/USERNAME/REPO_NAME.git
Go to the project directory:
cd HairTypeClassifier
Set up a virtual environment and activate it:
python -m venv .venv
.\.venv\Scripts\activate # On Windows
source .venv/bin/activate # On macOS/Linux
install all the stuff you need:
pip install numpy opencv-python scikit-learn tensorflow kaggle
This option uses web scraping to generate a dataset of images from hair-types 1a-4c. Naturally, you will need to edit the train_model.py and predict_hair_type.py to support 1a-4c instead of curly, wavy and straight. Instructions on editing the two Python files will be added to a future commit.
Find documentation for making your own dataset here.
To use this option before you can train the model, you need to download the dataset from Kaggle. We've provided a script to do this automatically
- Set Up Kaggle API: Make sure you have your Kaggle API key. You can get it from your Kaggle account settings.
- Make a .Kaggle in C:\Users\YOURNAME and put the .json file/ Kaggle API Key in that folder
- Download the Dataset: Run the downloadDataset.py script to download and unzip the dataset. (MAKE SURE TO CHANGE FILE PATHS)
python downloadDataset.py
This will download the dataset into the 'data/' directory.
To train the mode, just run:
python train_model.py
This will load the dataset, do some magic with the images, train the model, and save it as hair_classification_model.keras.
To predict the hair type of a new image, edit the predict_hair_type.py to the location of the image you want to predict and then run the predict_hair_type.py.
python predict_hair_type.py
- As we said at the start, this project was originally aimed to sort hair by more specific types such as 1a-4c. Right now we wanted to start with the basics.
- Future versions will get more detailed, cover all hair types and hopefully be more accurate :)
- We might even add a front end to the project so stay tuned :D
This project is under the MIT License. Check the LICENSE file for more info.