My way to implement and train CNN classifiers both from scratch and use PyTorch's implementations of popular CNNs for transfer learning. Inspired from task from Udacity Deep Learning Nano Degree Program (see original task in original_task/dog_app_orig.ipynb
, the original repo where you can find this task and more).
It is my own learning process of training convolution neural networks using PyTorch framework, from very beginning
- The code is well structured, scripts for training and evaluation are provided with wide range of input parameters
- A series of experiments are provided, well documented, see
experiments_part_1.ipynb
- The tensorboard logs are provided, for each experiment you can see plots of train loss, validation loss, test loss and test accuracy. The logs are in
tensorboard_logs
directory - You can view step-by-step on model's improvements and finetuning
- You can repeat all experiments
- The original task you can read in
original_task/dog_app_orig.ipynb
. You can also get links to dog breed dataset there - To see experiments description (from 1 to 25), run
experiments_part_1.ipynb
. For next serie of experiments (from 26 to 51) seeexperiments_part_2.ipynb
. Also, you can find conclusions and future work in there notebooks. - To run specific experiment, go to
train_run.sh
bash script, find experiment you are interested in, copy command and run in terminal (to see available input parameters fortrain.py
, runpython3 train.py -h
) - To evaluate model from specific experiment, go to
evaluate_run.sh
orevaluate_run_2.sh
bash script, find experiment you are interested in, copy command and run in terminal
The dog breed dataset is used. Summary:
- 133 classes
- 6680 train images
- 835 valid images
- 836 test images
Checkpoints are not provided in this repo, but you can run all experiments using bash scripts:
train_run.sh
- bash script for running experiments 1-25train_run_p2.sh
- bash script for running experiments 26-50
Tensorboard logs for all experiments are provided. To run tensorboard locally, run:
tensorboard -logdir tensorboard_logs/
or
tensorboard -logdir tensorboard_logs_p2/
To run tensorboard to get access from remote server, run (change [port] to your value):
tensorboard -logdir tensorboard_logs/ --port [port] --host 0.0.0.0
Also, you can merge all logs to same directory to view all experiments on same plot
Models are described in experiments_part_1.ipynb
and experiments_part_2.ipynb
. Brief info:
- Three implementations of AlexNet from original paper (
Base_fix
andBase_1_fix
andBase_2
), which are training from scratch - AlexNet from torchvision's implementation, which is training both from scratch and using transfer learning
- VGG16 from torchvision's implementation, which is training both from scratch and using transfer learning
- VGG16 with batch normalization from torchvision's implementation, which is training both from scratch and using transfer learning
A lot of experiments are dedicated to train models from scratch. More detail information see in experiments_part_1.ipynb
and experiments_part_2.ipynb
Transfer learning are implemented for pretrained torchvision's models AlexNet and VGG16, with unfreezing from 1 to 3 last fully connected layers (unfreezing of convolution layers will be implemented in future)
To calculate mean and std for dog breed dataset, run utils/mean_std_calculate.py
See examples in evaluate_run.sh
and evaluate_run_2.sh