- Create and activate a virtual environment that uses Python 3.12.
- Install PyTorch 2.5.1 (see this instruction).
- Install other dependencies with these versions: PIL 10.3.0, numpy 2.0.1, polars 1.21.0.
See this Jupyter Notebook for more.
How to train from scratch:
- Download the dataset from Microsoft Download Center (select English).
- Extract and put the dataset folder under
data/
. If success, there should be two folders,data/PetImages/Cat/
for cat images anddata/PetImages/Dog/
for dog images. - Run the Jupyter Notebook that trains the model on the training set and validates on the validation set.
- 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.
This is the plot of the losses and accuracy scores by epoch on the training and validation sets (see the image below).