Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Transfer Learning - Gender Classifier

This repository contains the code to perform experiments with Transfer Learning.

As an example task I took Gender Classification. This kind of neural network might be interesting for e.g. retail analytics to get customer insights such as understanding gender demographics of in-store visitors; for monitoring public spaces for safety by analyzing gender distribution in crowds or analyzing user demographics for better content strategy.

Input Data

The input data is taken from the MMLAB - CelebA Dataset.

This dataset contains 202,599 face images of celebrities and corresponding annotations including landmarks and dozens of binary attribute's annotations per image such as gender, face type, etc.

You can download the dataset and annotations through the provided links.

Input data examples:

Exploratory Data Analysis

EDA is available in Jupyter Notebook: data/Gender_Classifier_EDA.ipynb

Requirements

  • python: 3.8
  • pandas: 2.1.4
  • mlflow: 2.10.2
  • torch: 1.12.1
  • torchvision: 0.13.1
  • cv2: 4.6.0
  • seaborn: 0.12.1
  • matplotlib: 3.8.3

Install dependencies: pip install requirements.txt

Run the training script

To run train script it is necessary to have input data folders: data/input/train and data/input/val containing a folder with images per each class. (see the Data Splitting part in Gender_Classifier_EDA.ipynb)

Similarly for inference script: it is necessary to have test image data folders: data/input/test and data/input/test_arbitrary.

Run the train script

python train.py

Run the inference script

python inference.py

Parameters

Use utils.constant module to modify training parameters such as:

  • Number of epochs
  • Model Learning Rate
  • Momentum of Optimizer
  • Random seed for reproducibility
  • Device, e.g. cpu or gpu

and others:

  • Input data path
  • Run name for mlflow tracking
  • Checkpoints output path

Checkpoints

Model checkpoints for ResNet-18 is available in checkpoints

About

This repository contains the code to perform experiments with Transfer Learning.

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages