This project aims to develop a machine learning model for classifying gender based on facial images. The dataset used for this project is the UTKFace dataset, which contains a large collection of images labeled with gender, age, and ethnicity. The primary goal of this project is to build a model that can accurately distinguish between male and female faces.
The dataset is sourced from Kaggle and includes over 20,000 images of faces with the following attributes:
- Gender: Male or Female
- Age: From 0 to 116 years
- Ethnicity: White, Black, Asian, Indian, and Others
The dataset can be found here.
The model is built using convolutional neural networks (CNNs) to capture the spatial hierarchies in the facial images. The architecture includes:
- Input Layer: Accepts 48x48 pixel grayscale images.
- Convolutional Layers: Extracts features through a series of convolutional operations.
- Pooling Layers: Reduces the spatial dimensions of the feature maps.
- Fully Connected Layers: Combines the extracted features to predict the gender.
The implementation is done in Python using the following libraries:
- TensorFlow/Keras for building and training the neural network.
- OpenCV for image preprocessing.
- NumPy and Pandas for data manipulation.
The model is trained on 80% of the dataset, with the remaining 20% used for validation and testing. Various data augmentation techniques, such as rotation, flipping, and scaling, are applied to increase the robustness of the model.
- Accuracy: The primary metric for evaluating the model's performance.
- Precision, Recall, and F1-Score: Additional metrics for assessing the model's classification abilities.
The model achieves an accuracy of over 78.73% on the validation set, demonstrating its effectiveness in gender classification. Further improvements could involve fine-tuning the model architecture or experimenting with more complex neural networks.
To use the model, follow these steps:
- Clone the repository.
- Install the necessary dependencies, like tensorflow, opencv-python
- load the models using keras.model.load_model
Contributions are welcome! Please fork the repository and submit a pull request.
This project is licensed under the MIT License - see the LICENSE.md file for details.