Skip to content

ak-abdullah/Digital-Image-Processing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Pedestrian Gender Classification

Python scikit-learn OpenCV TensorFlow Jupyter

Binary image classification project for pedestrian gender detection. Combines hand-crafted low-level features (HOG, LBP, GLCM) with deep features extracted from VGG19's FC2 layer, fuses them, reduces dimensionality with PCA, and classifies using a Linear SVM evaluated across 10-fold cross-validation.

Dataset: MIT Pedestrian dataset with 600 male and 600 female images (female class augmented from 288 to balance the dataset).


⚡ Pipeline

  1. Data preparation — loaded 600 male and 288 female pedestrian images from the MIT dataset. Augmented the female class using flip, rotation, and scaling to balance it to 600 images.
  2. Preprocessing — resized all images to 224x224, converted to grayscale, applied CLAHE contrast enhancement.
  3. Low-level features — extracted HOG, LBP, and GLCM features from preprocessed grayscale images.
  4. Deep features — extracted 4096-dimensional features from VGG19 FC2 layer using the original RGB images.
  5. Feature fusion — concatenated low-level and deep features into a single vector per image.
  6. PCA — reduced dimensionality while retaining 95% of variance.
  7. Classification — trained Linear SVM evaluated with 10-fold stratified cross-validation.

🛠️ Stack

Layer Technology
Image Processing OpenCV, CLAHE
Low-Level Features HOG, LBP, GLCM (skimage)
Deep Features VGG19 FC2 layer (TensorFlow/Keras)
Dimensionality Reduction PCA, 95% variance threshold
Classification Linear SVM (scikit-learn)
Evaluation 10-fold Stratified K-Fold
Visualization Matplotlib, Seaborn

📊 Results

Metric Score
Accuracy evaluated via 10-fold CV
Precision evaluated via 10-fold CV
Recall evaluated via 10-fold CV
F1 Score evaluated via 10-fold CV

Confusion matrix:

Confusion Matrix


📁 Project structure

digital-image-processing/
├── Pedestrian Gender Classification.ipynb   # full pipeline
├── MIT-IB.rar                               # dataset
├── output.png                               # confusion matrix
└── README.md

🚀 Running locally

pip install opencv-python scikit-learn scikit-image tensorflow numpy pandas matplotlib seaborn

Open the notebook and update the folder path in section 1.1 to point to your local MIT-IB dataset directory. Run cells in order.

folder_path = 'your/path/to/MIT-IB'

💡 What I learned building this

The dataset was imbalanced — 600 male images and only 288 female. Training on this directly biases the classifier toward the majority class. I used flip, rotation, and scale augmentation to bring the female class up to 600 before training.

Combining low-level and deep features gave better results than either alone. HOG captures shape and edge information, LBP captures texture, GLCM captures spatial relationships between pixels. VGG19 FC2 adds 4096 semantic features learned from ImageNet. Serial fusion of all of these gives the classifier a richer representation to work with.

PCA with 95% variance retention was necessary. The fused feature vector before reduction was very high dimensional. Without PCA the SVM training was slow and prone to overfitting on this dataset size.

Stratified K-Fold instead of regular K-Fold matters for imbalanced datasets. It makes sure each fold has the same class ratio as the full dataset, which gives a more honest evaluation of model performance.


📬 Contact

Built by Abdullah Khalid

LinkedIn Email Portfolio

About

Binary image classification for pedestrian gender detection using HOG, LBP, GLCM and VGG19 deep features. PCA dimensionality reduction with Linear SVM evaluated via 10-fold cross-validation.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors