This is a PyTorch implementation of Faster RCNN. This project is mainly based on py-faster-rcnn and TFFRCNN.
For details about R-CNN please refer to the paper Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks by Shaoqing Ren, Kaiming He, Ross Girshick, Jian Sun.
- Forward for detecting
- RoI Pooling layer with C extensions on CPU (only forward)
- RoI Pooling layer on GPU (forward and backward)
- Training on VOC2007
- TensroBoard support
- Evaluation
-
Clone the Faster R-CNN repository
git clone [email protected]:longcw/faster_rcnn_pytorch.git
-
Build the Cython modules for nms and the roi_pooling layer
cd faster_rcnn_pytorch/faster_rcnn ./make.sh
-
Download the trained model VGGnet_fast_rcnn_iter_70000.h5 and set the model path in
demo.py
-
Run demo
python demo.py
Follow this project (TFFRCNN) to download and prepare the training, validation, test data and the VGG16 model pre-trained on ImageNet.
Since the program loading the data in faster_rcnn_pytorch/data
by default,
you can set the data path as following.
cd faster_rcnn_pytorch
mkdir data
cd data
ln -s $VOCdevkit VOCdevkit2007
Then you can set some hyper-parameters in train.py
and training parameters in the .yml
file.
Now I got a 0.661 mAP on VOC07 while the origin paper got a 0.699 mAP.
You may need to tune the loss function defined in faster_rcnn/faster_rcnn.py
by yourself.
Since the image sizes and bbox sizes in the Imagenet DB have conflicts with Pascal VOC DB, before training, we have to clean those images with conflicts first.
python image_preprocess.py
Then we can start training with the remaining images.
Since the program loading the data in faster_rcnn_pytorch/data
by default,
you can set the data path as following.
cd faster_rcnn_pytorch
mkdir data
cd data
ln -s $imagenetdevkit imagenetdevkit2015
Then you can set some hyper-parameters in train.py
and training parameters in the .yml
file.
With the aid of Crayon, we can access the visualisation power of TensorBoard for any deep learning framework.
To use the TensorBoard, install Crayon (https://github.com/torrvision/crayon)
and set use_tensorboard = True
in faster_rcnn/train.py
.
Set the path of the trained model in test.py
.
cd faster_rcnn_pytorch
mkdir output
python test.py