|
| 1 | +### Hair Type Classification Model using Deep Learning ### |
| 2 | + |
| 3 | + |
| 4 | +## Goal |
| 5 | +The main objective of this project is to develop a deep learning-based hair type classification system that can accurately classify hair into five categories: Kinky, Dreadlocks, Straight, Curly, and Wavy. This project aims to enhance automated hair classification accuracy using an ensemble of three powerful deep learning models. |
| 6 | + |
| 7 | +## Overview |
| 8 | +Hair type classification is a crucial aspect in various domains, including cosmetics, fashion, and dermatology. The goal of this project is to build an **AI-powered hair type classification system** that can categorize hair into five types: |
| 9 | +- **Kinky** |
| 10 | +- **Dreadlocks** |
| 11 | +- **Straight** |
| 12 | +- **Curly** |
| 13 | +- **Wavy** |
| 14 | +## Objectives |
| 15 | +- Develop a **deep learning-based model** for hair type classification. |
| 16 | +- Train and evaluate multiple models, then combine them using an **ensemble approach**. |
| 17 | +- Achieve **higher accuracy** through a hybrid model combining **ResNet50, VGG16, and ConvNeXt-Tiny**. |
| 18 | + |
| 19 | +## Dataset |
| 20 | +Here is the dataset link : [Link to the dataset](https://www.kaggle.com/datasets/kavyasreeb/hair-type-dataset) |
| 21 | +## Data Distrubution |
| 22 | +| Hair Type | Training Images | Testing Images | |
| 23 | +|------------|----------------|---------------| |
| 24 | +| Kinky | 173 | 44 | |
| 25 | +| Dreadlocks | 354 | 89 | |
| 26 | +| Straight | 390 | 98 | |
| 27 | +| Curly | 411 | 103 | |
| 28 | +| Wavy | 264 | 66 | |
| 29 | + |
| 30 | + |
| 31 | + |
| 32 | +--- |
| 33 | +## Methodology |
| 34 | +- **Image Resizing**: All images resized to **224x224** for model compatibility. |
| 35 | +- **Normalization**: Applied using **ImageNet statistics**. |
| 36 | +- **Data Augmentation**: Used **Albumentations** for better generalization. |
| 37 | + |
| 38 | +## Model Selection & Training |
| 39 | +I implemented and trained following three models: |
| 40 | +1. **ResNet50** – A deep residual network for effective feature extraction. |
| 41 | +2. **VGG16** – A deep CNN with uniform kernel sizes. |
| 42 | +3. **ConvNeXt-Tiny** – A modern CNN inspired by Vision Transformers. |
| 43 | +### Ensemble Learning Approach |
| 44 | +The **final model** is an **ensemble of all three models**, using a **weighted averaging technique** to achieve **higher accuracy**. |
| 45 | +## Results |
| 46 | +### Classification Report for **Hair-ResNet50**: |
| 47 | + |
| 48 | +| Class | Precision | Recall | F1-Score | Support | |
| 49 | +|-------------|-----------|--------|----------|---------| |
| 50 | +| Straight | 0.92 | 0.92 | 0.92 | 195 | |
| 51 | +| Wavy | 0.82 | 0.81 | 0.82 | 126 | |
| 52 | +| Curly | 0.86 | 0.92 | 0.89 | 186 | |
| 53 | +| Dreadlocks | 0.97 | 0.99 | 0.98 | 193 | |
| 54 | +| Kinky | 0.91 | 0.77 | 0.83 | 95 | |
| 55 | + |
| 56 | +- **Accuracy**: 0.90 (795 samples) |
| 57 | +- **Macro Average**: Precision 0.90, Recall 0.88, F1-Score 0.89 |
| 58 | +- **Weighted Average**: Precision 0.90, Recall 0.90, F1-Score 0.90 |
| 59 | +### Classification Report for Hair-VGG16: |
| 60 | + |
| 61 | +| Class | Precision | Recall | F1-Score | Support | |
| 62 | +|-------------|-----------|--------|----------|---------| |
| 63 | +| Straight | 0.88 | 0.94 | 0.91 | 195 | |
| 64 | +| Wavy | 0.89 | 0.83 | 0.86 | 126 | |
| 65 | +| Curly | 0.91 | 0.92 | 0.91 | 186 | |
| 66 | +| Dreadlocks | 0.98 | 0.97 | 0.98 | 193 | |
| 67 | +| Kinky | 0.90 | 0.85 | 0.88 | 95 | |
| 68 | + |
| 69 | +- **Accuracy**: 0.92 (795 samples) |
| 70 | +- **Macro Average**: Precision 0.91, Recall 0.90, F1-Score 0.91 |
| 71 | +- **Weighted Average**: Precision 0.92, Recall 0.92, F1-Score 0.92 |
| 72 | +### Classification Report for hair-convnext-tiny: |
| 73 | + |
| 74 | +| Class | Precision | Recall | F1-Score | Support | |
| 75 | +|-------------|-----------|--------|----------|---------| |
| 76 | +| Straight | 0.92 | 0.96 | 0.94 | 195 | |
| 77 | +| Wavy | 0.87 | 0.82 | 0.84 | 126 | |
| 78 | +| Curly | 0.89 | 0.95 | 0.92 | 186 | |
| 79 | +| Dreadlocks | 0.98 | 0.98 | 0.98 | 193 | |
| 80 | +| Kinky | 0.94 | 0.80 | 0.86 | 95 | |
| 81 | + |
| 82 | +- **Accuracy**: 0.92 (795 samples) |
| 83 | +- **Macro Average**: Precision 0.92, Recall 0.90, F1-Score 0.91 |
| 84 | +- **Weighted Average**: Precision 0.92, Recall 0.92, F1-Score 0.92 |
| 85 | +### Ensemble Model Classification Report: |
| 86 | + |
| 87 | +| Class | Precision | Recall | F1-Score | Support | |
| 88 | +|-------------|-----------|--------|----------|---------| |
| 89 | +| Straight | 0.92 | 0.94 | 0.93 | 195 | |
| 90 | +| Wavy | 0.88 | 0.85 | 0.86 | 126 | |
| 91 | +| Curly | 0.91 | 0.93 | 0.92 | 186 | |
| 92 | +| Dreadlocks | 1.00 | 1.00 | 1.00 | 193 | |
| 93 | +| Kinky | 0.90 | 0.86 | 0.88 | 95 | |
| 94 | + |
| 95 | +- **Accuracy**: 0.93 (795 samples) |
| 96 | +- **Macro Average**: Precision 0.92, Recall 0.92, F1-Score 0.92 |
| 97 | +- **Weighted Average**: Precision 0.93, Recall 0.93, F1-Score 0.93 |
| 98 | +## Key Observations |
| 99 | +- **Ensemble Model** provided the best results (**93.7% accuracy**). |
| 100 | +- **ConvNeXt-Tiny** performed better than ResNet50 and VGG16. |
| 101 | +- **Data Augmentation** significantly improved model robustness. |
| 102 | +## Required Libraries |
| 103 | +- fastai |
| 104 | +- fastai.vision.all |
| 105 | +- fastai.callback.tracker |
| 106 | +- albumentations -- version 1.3.0 |
| 107 | +- sklearn.metrics |
| 108 | +- cv2 (OpenCV) |
| 109 | +- pathlib |
| 110 | +## Note |
| 111 | +Make sure the input and output directory paths and libraries are correctly set before running the code. |
| 112 | + |
| 113 | + |
| 114 | + |
| 115 | + |
0 commit comments