1) Get the files from Ruotian Luo's github repository.
git clone https://github.com/ruotianluo/pytorch-faster-rcnn.git
2) Get into the faster rcnn directory
cd pytorch-faster-rcnn/
3) Determine your achitecture. My GPU model is nVidia Tesla P100 and so the corresponding architecture according to this website is sm_60. The architecture will be provided to set the Nvidia Cuda Compiler's(nvcc) -arch flag in the 4th step below.
4) Compile and Build RoI Pooling module
cd lib/layer_utils/roi_pooling/src/cuda
nvcc -c -o roi_pooling_kernel.cu.o roi_pooling_kernel.cu -x cu -Xcompiler -fPIC -arch=sm_60
cd ../../
python build.py
cd ../../../
5) Compile and Build Non-maximum Suppression(NMS) module
cd lib/nms/src/cuda
nvcc -c -o nms_kernel.cu.o nms_kernel.cu -x cu -Xcompiler -fPIC -arch=sm_60
cd ../../
python build.py
cd ../../
6) Install python COCO API under data folder.
cd data
git clone https://github.com/pdollar/coco.git
cd coco/PythonAPI
make
cd ../../..
7) (OPTIONAL) In case your COCO data set(images and annotation) have to reside under a different directory you can create a symbolic link to it under data folder.
#move all files under coco (obtained after 6th step above) to shared coco folder
mv data/coco/* /YOURSHAREDDATASETS/coco
#create symbolic link to that coco folder
cd data
rm -rf coco
ln -s /YOURSHAREDDATASETS/coco coco
8) Download proposals and annotation json files from here.
9) After you downloaded annotations, place them under coco/annotations folder. The coco folder structure should look like below. To download default COCO images and annotations please check here.
coco/
annotations/
instances_minival2014.json
instances_valminusminival2014.json
...(default coco json files)
images/
train2014/...
val2014/...
test2014/...
PythonAPI/...
10) Create imagenet_weights folder under data. A pre-trained model on ImageNet dataset will reside here.
mkdir -p data/imagenet_weights
11) Download the pre-trained ResNet model(the resnet101-caffe one) model from here into the imagenet_weights folder and rename it.
cd data/imagenet_weights
mv resnet101-caffe.pth res101.pth
cd ../..
12)Run training script
GPU_ID=0
DATASET=coco
MODEL=res101
./experiments/scripts/train_faster_rcnn.sh $GPU_ID $DATASET $MODEL
13) Test your model upon successful trainig.
#change the iteration number in test_faster_rcnn.sh to
#the number of iterations you made. I made 460000 iterations the default is 490000.
GPU_ID=0
DATASET=coco
MODEL=res101
./experiments/scripts/test_faster_rcnn.sh $GPU_ID $DATASET $MODEL
git clone https://github.com/ruotianluo/pytorch-faster-rcnn.git
2) Get into the faster rcnn directory
cd pytorch-faster-rcnn/
3) Determine your achitecture. My GPU model is nVidia Tesla P100 and so the corresponding architecture according to this website is sm_60. The architecture will be provided to set the Nvidia Cuda Compiler's(nvcc) -arch flag in the 4th step below.
4) Compile and Build RoI Pooling module
cd lib/layer_utils/roi_pooling/src/cuda
nvcc -c -o roi_pooling_kernel.cu.o roi_pooling_kernel.cu -x cu -Xcompiler -fPIC -arch=sm_60
cd ../../
python build.py
cd ../../../
5) Compile and Build Non-maximum Suppression(NMS) module
cd lib/nms/src/cuda
nvcc -c -o nms_kernel.cu.o nms_kernel.cu -x cu -Xcompiler -fPIC -arch=sm_60
cd ../../
python build.py
cd ../../
6) Install python COCO API under data folder.
cd data
git clone https://github.com/pdollar/coco.git
cd coco/PythonAPI
make
cd ../../..
7) (OPTIONAL) In case your COCO data set(images and annotation) have to reside under a different directory you can create a symbolic link to it under data folder.
#move all files under coco (obtained after 6th step above) to shared coco folder
mv data/coco/* /YOURSHAREDDATASETS/coco
#create symbolic link to that coco folder
cd data
rm -rf coco
ln -s /YOURSHAREDDATASETS/coco coco
8) Download proposals and annotation json files from here.
9) After you downloaded annotations, place them under coco/annotations folder. The coco folder structure should look like below. To download default COCO images and annotations please check here.
coco/
annotations/
instances_minival2014.json
instances_valminusminival2014.json
...(default coco json files)
images/
train2014/...
val2014/...
test2014/...
PythonAPI/...
10) Create imagenet_weights folder under data. A pre-trained model on ImageNet dataset will reside here.
mkdir -p data/imagenet_weights
11) Download the pre-trained ResNet model(the resnet101-caffe one) model from here into the imagenet_weights folder and rename it.
cd data/imagenet_weights
mv resnet101-caffe.pth res101.pth
cd ../..
12)Run training script
GPU_ID=0
DATASET=coco
MODEL=res101
./experiments/scripts/train_faster_rcnn.sh $GPU_ID $DATASET $MODEL
13) Test your model upon successful trainig.
#change the iteration number in test_faster_rcnn.sh to
#the number of iterations you made. I made 460000 iterations the default is 490000.
GPU_ID=0
DATASET=coco
MODEL=res101
./experiments/scripts/test_faster_rcnn.sh $GPU_ID $DATASET $MODEL