This project aims to classify images of men and women using Deep Learning techniques. By leveraging the power of Convolutional Neural Networks (CNNs) and the pre-trained VGG16 architecture (originally trained on the ImageNet dataset), the model extracts meaningful features from input images. The model is then fine-tuned on a custom dataset to achieve high accuracy in distinguishing between male and female images.
The project uses the Men-Women Classification dataset from Kaggle. To download the dataset in your Google Colab environment, run the following command:
!kaggle datasets download -d saadpd/menwomen-classification!unzip menwomen-classification.zip -d ./dataAfter downloading, unzip the dataset and organize it into appropriate folders for training, validation, and testing.
The dataset is organized into three subsets:
- Training Set: 1598 images
- Validation Set: 400 images
- Test Set: 800 images
men_vs_women_small/
├── train/
│ ├── men/
│ └── women/
├── validation/
│ ├── men/
│ └── women/
└── test/
├── men/
└── women/
Before running this project, ensure you have the following installed:
- Python 3.x
- TensorFlow (>= 2.0)
- Keras
- NumPy
- pandas
- Matplotlib
- Kaggle API (optional, for downloading the dataset)
You can install these dependencies using pip:
pip install tensorflow numpy matplotlib pandasThe model is based on VGG16 (pre-trained on ImageNet). It consists of the following components:
-
Frozen convolutional base for feature extraction
-
Dense layer (256 units, ReLU) + Dropout (0.5)
-
Final sigmoid output for binary classification
-
VGG16 convolutional base frozen
-
Only top classifier layers trained
-
Last 4 convolutional blocks of VGG16 unfrozen
-
Optimizer: Adam (learning_rate = 1e-5)
-
Callbacks used to save the best-performing model
-
Transfer learning with pre-trained CNNs significantly improves accuracy on small datasets.
-
Fine-tuning only a subset of convolutional layers avoids overfitting.
-
Data augmentation is essential for robustness.
This project is licensed under the MIT License - see the LICENSE file for details.
Developed by Zahra Sahranavard
For inquiries: zahra.sahranavard7622@iau.ir
