# Faster RCNN with PyTorch
**Note:** I re-implemented faster rcnn in this project when I started learning PyTorch. Then I use PyTorch in all of my projects. I still remember it costed one week for me to figure out how to build cuda code as a pytorch layer :).
But actually this is not a good implementation and I didn't achieve the same mIOU as the original caffe code.
**This project is no longer maintained. So I suggest:**
- You can still read and study this code if you want to re-implement faster rcnn by yourself;
- You can use the better PyTorch implementation by [ruotianluo](https://github.com/ruotianluo/pytorch-faster-rcnn) if you want to train faster rcnn with your own data;
This is a [PyTorch](https://github.com/pytorch/pytorch)
implementation of Faster RCNN.
This project is mainly based on [py-faster-rcnn](https://github.com/rbgirshick/py-faster-rcnn)
and [TFFRCNN](https://github.com/CharlesShang/TFFRCNN).
For details about R-CNN please refer to the [paper](https://arxiv.org/abs/1506.01497)
Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks
by Shaoqing Ren, Kaiming He, Ross Girshick, Jian Sun.
### Progress
- [x] Forward for detecting
- [x] RoI Pooling layer with C extensions on CPU (only forward)
- [x] RoI Pooling layer on GPU (forward and backward)
- [x] Training on VOC2007
- [x] TensroBoard support
- [x] Evaluation
### Installation and demo
0. Install the requirements (you can use pip or [Anaconda](https://www.continuum.io/downloads)):
```
conda install pip pyyaml sympy h5py cython numpy scipy
conda install -c menpo opencv3
pip install easydict
```
1. Clone the Faster R-CNN repository
```bash
git clone git@github.com:longcw/faster_rcnn_pytorch.git
```
2. Build the Cython modules for nms and the roi_pooling layer
```bash
cd faster_rcnn_pytorch/faster_rcnn
./make.sh
```
3. Download the trained model [VGGnet_fast_rcnn_iter_70000.h5](https://drive.google.com/open?id=0B4pXCfnYmG1WOXdpYVFybWxiZFE)
and set the model path in `demo.py`
3. Run demo `python demo.py`
### Training on Pascal VOC 2007
Follow [this project (TFFRCNN)](https://github.com/CharlesShang/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.
```bash
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.
### Training with TensorBoard
With the aid of [Crayon](https://github.com/torrvision/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`.
### Evaluation
Set the path of the trained model in `test.py`.
```bash
cd faster_rcnn_pytorch
mkdir output
python test.py
```
License: MIT license (MIT)
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
faster_rcnn_pytorch-master.zip (89个子文件)
faster_rcnn_pytorch-master
test.py 5KB
train.py 5KB
faster_rcnn
pycocotools
mask.py 4KB
coco.py 15KB
license.txt 1KB
cocoeval.py 19KB
_mask.c 584KB
_mask.pyx 10KB
UPSTREAM_REV 80B
__init__.py 21B
maskApi.h 2KB
maskApi.c 8KB
nms
py_cpu_nms.py 1KB
gpu_nms.pyx 1KB
__init__.py 0B
.gitignore 15B
gpu_nms.hpp 146B
cpu_nms.pyx 2KB
nms_kernel.cu 5KB
fast_rcnn
config2.py 11KB
bbox_transform.py 3KB
nms_wrapper.py 714B
__init__.py 325B
config.py 11KB
vgg16.py 3KB
__init__.py 0B
setup.py 6KB
roi_data_layer
minibatch2.py 13KB
layer.py 3KB
roidb.py 6KB
minibatch.py 9KB
roidb2.py 5KB
__init__.py 260B
roi_pooling
functions
__init__.py 0B
roi_pool.py 2KB
build.py 815B
src
cuda
roi_pooling_kernel.cu 8KB
roi_pooling_kernel.h 767B
roi_pooling_cuda.h 420B
roi_pooling.c 4KB
roi_pooling.h 178B
roi_pooling_cuda.c 3KB
__init__.py 0B
_ext
__init__.py 0B
roi_pooling
__init__.py 310B
modules
roi_pool_py.py 2KB
__init__.py 0B
roi_pool.py 516B
rpn_msr
generate_anchors.py 3KB
anchor_target_layer.py 12KB
proposal_target_layer.py 10KB
generate.py 4KB
__init__.py 262B
proposal_layer.py 7KB
faster_rcnn.py 16KB
utils
nms.py 1008B
timer.py 948B
__init__.py 334B
nms.pyx 4KB
bbox.pyx 3KB
.gitignore 15B
boxes_grid.py 3KB
blob.py 1KB
network.py 4KB
make.sh 434B
datasets
imdb2.py 16KB
pascal_voc.py 14KB
nthu.py 10KB
coco.py 16KB
kitti_tracking.py 22KB
pascal_voc2.py 29KB
imagenet3d.py 22KB
__init__.py 1KB
factory.py 2KB
voc_eval.py 7KB
ds_utils.py 1KB
kittivoc.py 15KB
pascal3d.py 30KB
kitti.py 31KB
nissan.py 10KB
imdb.py 10KB
demo.py 2KB
LICENSE 1KB
__init__.py 0B
experiments
cfgs
faster_rcnn_end2end.yml 690B
.gitignore 1KB
demo
out.jpg 126KB
004545.jpg 120KB
README.md 3KB
共 89 条
- 1
资源评论
Alvin2AI
- 粉丝: 3
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功