- Follow Caffe instruction to install all necessary packages and build it.
Execute the command below to enable Python interface of Caffe.
export PYTHONPATH=$CAFFE_ROOT/python:$PYTHONPATH
- Get the code and store them under
$CAFFE_ROOT
.
git clone xxxx
dogsvscats/
is organized as follows.
+ dogsvscats/
+ data/
+ scripts/
+ models/
+ caffenet
+ resnet50
- Download
Dogs vs. Cats data from Kaggle.
Unzip the files and store them under$CAFFE_ROOT/dogsvccats/data/
.
data/
should be organized as follows.
+ data/
+ train
+ test1
- Create lmdb data and generate the mean file of training data.
create_lmdb_meanfile.sh
creates train, val, trainval data in lmdb format and generates meanfile for train and trainval, respectively.
bash create_lmdb_meanfile.sh
Two networks are provided: CaffeNet and ResNet50. The network definitions and training scripts are stored under $CAFFE_ROOT/dogsvscats/models/
.
- Download IMAGENET pretrained models and put them under corresponding directory.
- Finetune on dogsvscats data.
bash train.sh
or
bash trainval.sh
train.sh
will finetune the pretrained models on train and report accuracy on val. trainval.sh
will finetune the pretrained models on trainval (the whole training data).
Trained models will be stored under $CAFFE_ROOT/dogsvscats/moedels/caffnet/exp/
.
The logs generated during training can be exploited to plot training and testing curves.
python plot_learning_curve.py
This will generate curve.png
which visualizes the training process.
Finally we can predict on unseen data. Test dataset is provided under $CAFFE_ROOT/dogsvscats/data/test1
. We can predict on them based on trained models.
python make_predictions.py
make_predictions.py
will generate submission.csv
which can be submitted to Kaggle
Dogs vs. Cats challenge.