This guide walks you through the process of setting up, running, and evaluating the skin tone detection project that combines DeepGaze and a custom CNN model.
- Ensure you have Python 3.7+ installed on your system.
- Clone the project repository to your local machine.
- Navigate to the project directory in your terminal.
- Create a virtual environment:
python -m venv venv
- Activate the virtual environment:
- On Windows:
venv\Scripts\activate
- On macOS and Linux:
source venv/bin/activate
- On Windows:
- Install the required packages:
pip install -r requirements.txt
- Create a
data/raw
directory in your project folder if it doesn't exist. - Collect images for each skin tone category (black, brown, white).
- Organize your dataset in the
data/raw
directory as follows:data/raw/ ├── black/ │ ├── image1.jpg │ ├── image2.jpg │ └── ... ├── brown/ │ ├── image1.jpg │ ├── image2.jpg │ └── ... └── white/ ├── image1.jpg ├── image2.jpg └── ...
- Review and adjust the skin detection parameters in
config.py
if necessary. - Run the data preprocessing script:
python data/data_preprocessing.py
- This script will:
- Load images from the raw data directory
- Use DeepGaze to detect skin areas in each image
- Preprocess the skin-detected areas for CNN input
- Split the data into training, validation, and test sets
- Verify that the script runs without errors and prints the shapes of the datasets.
- Manually inspect some preprocessed images to ensure correct skin detection.
- Review the CNN model architecture in
models/cnn_model.py
. - Consider starting with a simpler architecture if facing performance issues.
- Implement data augmentation techniques in the model or data loading process.
- Adjust hyperparameters in
config.py
if needed (learning rates, batch size, epochs). - Start the model training process:
python train.py
- Monitor the console output for training progress, including loss and accuracy for each epoch.
- After training, examine the generated training history plot.
- Run the evaluation script:
python evaluate.py
- Review the printed classification report, which includes precision, recall, and F1-score for each class.
- Examine the confusion matrix visualization to understand the model's performance across different skin tones.
- If the model shows poor performance (e.g., heavy bias towards one class):
- Check for class imbalance in your dataset
- Review preprocessing steps for potential biases
- Consider implementing class weighting or oversampling techniques
If the model's performance is unsatisfactory:
-
Data Quality:
- Ensure your dataset is diverse and correctly labeled
- Add more varied samples if certain classes are underrepresented
-
Preprocessing:
- Fine-tune the skin detection algorithm to reduce potential biases
- Implement additional data augmentation techniques
-
Model Architecture:
- Experiment with different CNN architectures
- Consider using transfer learning with pre-trained models
-
Training Process:
- Adjust learning rates, potentially using learning rate schedules
- Implement regularization techniques (e.g., dropout, L2 regularization)
- Use techniques like gradient clipping to handle potential instability
-
Balanced Learning:
- Implement class weighting in the loss function
- Use oversampling or undersampling techniques for imbalanced classes
-
Feature Visualization:
- Implement techniques like activation maximization or Grad-CAM to understand what features the model is learning
Once the model's performance has improved:
- Develop a prediction script (
predict.py
) to use the trained model on new images. - Ensure the prediction process includes the same preprocessing steps used during training.
- Implement a user-friendly interface for making predictions, if desired.
Repeat steps 4-8 as necessary, making incremental improvements and re-evaluating performance until satisfactory results are achieved.
Remember to document changes, findings, and results throughout the process. This will help in understanding what works best for your specific skin tone detection task.