CaffeModel
Run caffenet on this data
http://caffe.berkeleyvision.org/tutorial https://github.com/philipperemy/yolo-9000 https://github.com/C-Aniruddh/realtime_object_recognition http://caffe.berkeleyvision.org/gathered/examples/mnist.html
Setup ProtoBuf
Download Protobuf
cd /home/mamun/Development/environment
wget https://github.com/google/protobuf/releases/download/v3.5.1/protobuf-all-3.5.1.tar.gz
tar -xvf protobuf-all-3.5.1.tar.gz
mv protobuf-3.5.1 protobuf
cd protobuf
Install Protobuf
./configure
make
make check
sudo make install
sudo ldconfig # refresh shared library cache
For use in python
cd python
python setup.py install
export PROTO_ROOT=/home/mamun/Development/environment/protobuf
Make Caffe
cd /home/mamun/Development/environment
git clone https://github.com/BVLC/caffe
cp Makefile.config.example Makefile.config
Note: Adjust Makefile.config (for example, if using Anaconda Python, or if cuDNN is desired)
For CPU-only Caffe, uncomment CPU_ONLY := 1 in Makefile.config.
make clean
make all
make test
make runtest
To compile the Python and MATLAB wrappers do
make pycaffe
To MATLAB wrappers do
make matcaffe
Note: Be sure to set your MATLAB and Python paths in Makefile.config first!
Export CaffeRoot
export CAFFE_ROOT=/home/mamun/Development/environment/caffe
Export PythonPath
export PYTHONPATH=$CAFFE_ROOT/python:$PROTO_ROOT/python:$PYTHONPATH
1st change dogvscat.sh file
#!/bin/bash
export CAFFE_ROOT=/home/mamun/Development/environment/caffe
export PROTO_ROOT=/home/mamun/Development/environment/protobuf
DOG_VS_CAT_FOLDER=$(pwd)
## Download datasets (requires first a login)
#wget https://www.kaggle.com/c/dogs-vs-cats/download/train.zip
#wget https://www.kaggle.com/c/dogs-vs-cats/download/test1.zip
# Unzip train and test data
# sudo apt-get -y install unzip
# unzip train -d .
# unzip test1 -d .
# Format data
# python create_label_file.py # creates 2 text files with labels for training and validation
# bash build_datasets.sh # build lmdbs
# Download ImageNet pretrained weights (takes ~20 min)
$CAFFE_ROOT/scripts/download_model_binary.py $CAFFE_ROOT/models/bvlc_reference_caffenet
# Fine-tune AlexNet architecture (takes ~60 min)
$CAFFE_ROOT/build/tools/caffe train -solver $DOG_VS_CAT_FOLDER/dogvscat_solver.prototxt -weights #$CAFFE_ROOT/models/bvlc_reference_caffenet/bvlc_reference_caffenet.caffemodel
# Classify test dataset
#export PYTHONPATH=$CAFFE_ROOT/python:$PROTO_ROOT/python:$PYTHONPATH
#python convert_binaryproto2npy.py
#python dogvscat_classify.py # Returns prediction.txt (takes ~20 min)
# A better approach is to train five AlexNets w/init parameters from the same distribution,
# fine-tuned those five, and compute the average of the five networks
#!/bin/bash
export CAFFE_ROOT=/home/mamun/Development/environment/caffe
export PROTO_ROOT=/home/mamun/Development/environment/protobuf
DOG_VS_CAT_FOLDER=$(pwd)
## Download datasets (requires first a login)
#wget https://www.kaggle.com/c/dogs-vs-cats/download/train.zip
#wget https://www.kaggle.com/c/dogs-vs-cats/download/test1.zip
# Unzip train and test data
# sudo apt-get -y install unzip
# unzip train -d .
# unzip test1 -d .
# Format data
# python create_label_file.py # creates 2 text files with labels for training and validation
# bash build_datasets.sh # build lmdbs
# Download ImageNet pretrained weights (takes ~20 min)
$CAFFE_ROOT/scripts/download_model_binary.py $CAFFE_ROOT/models/bvlc_reference_caffenet
# Fine-tune AlexNet architecture (takes ~60 min)
$CAFFE_ROOT/build/tools/caffe train -solver $DOG_VS_CAT_FOLDER/dogvscat_solver.prototxt -weights #$CAFFE_ROOT/models/bvlc_reference_caffenet/bvlc_reference_caffenet.caffemodel
# Classify test dataset
#export PYTHONPATH=$CAFFE_ROOT/python:$PROTO_ROOT/python:$PYTHONPATH
#python convert_binaryproto2npy.py
#python dogvscat_classify.py # Returns prediction.txt (takes ~20 min)
# A better approach is to train five AlexNets w/init parameters from the same distribution,
# fine-tuned those five, and compute the average of the five networks
Execute
bash dogvscat.sh
Comments
Post a Comment