Skip to content

Cat-Dog Image Classification: training, evaluation and inference (98% accuracy on test set).

Notifications You must be signed in to change notification settings

hnthap/cat-dog-classification

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cat-Dog Image Classification

Requirements

  1. Create and activate a virtual environment that uses Python 3.12.
  2. Install PyTorch 2.5.1 (see this instruction).
  3. Install other dependencies with these versions: PIL 10.3.0, numpy 2.0.1, polars 1.21.0.

Inference

See this Jupyter Notebook for more.

Training

How to train from scratch:

  1. Download the dataset from Microsoft Download Center (select English).
  2. Extract and put the dataset folder under data/. If success, there should be two folders, data/PetImages/Cat/ for cat images and data/PetImages/Dog/ for dog images.
  3. Run the Jupyter Notebook that trains the model on the training set and validates on the validation set.
  4. Run the Jupyter Notebook that evaluates the model on the testing set.

Images need to be preprocessed before fed to the model (see the image below). See the transform functions in this notebook.

Preprocess

This is the plot of the losses and accuracy scores by epoch on the training and validation sets (see the image below).

By epoch

About

Cat-Dog Image Classification: training, evaluation and inference (98% accuracy on test set).

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published