# A *Faster* Pytorch Implementation of Faster R-CNN
## Write at the beginning
[05/29/2020] This repo was initaited about two years ago, developed as the first open-sourced object detection code which supports multi-gpu training. It has been integrating tremendous efforts from many people. However, we have seen many high-quality repos emerged in the last years, such as:
* [maskrcnn-benchmark](https://github.com/facebookresearch/maskrcnn-benchmark)
* [detectron2](https://github.com/facebookresearch/detectron2)
* [mmdetection](https://github.com/open-mmlab/mmdetection)
**At this point, I think this repo is out-of-data in terms of the pipeline and coding style, and will not maintain actively. Though you can still use this repo as a playground, I highly recommend you move to the above repos to delve into west world of object detection!**
## Introduction
### :boom: Good news! This repo supports pytorch-1.0 now!!! We borrowed some code and techniques from [maskrcnn-benchmark](https://github.com/facebookresearch/maskrcnn-benchmark). Just go to pytorch-1.0 branch!
This project is a *faster* pytorch implementation of faster R-CNN, aimed to accelerating the training of faster R-CNN object detection models. Recently, there are a number of good implementations:
* [rbgirshick/py-faster-rcnn](https://github.com/rbgirshick/py-faster-rcnn), developed based on Pycaffe + Numpy
* [longcw/faster_rcnn_pytorch](https://github.com/longcw/faster_rcnn_pytorch), developed based on Pytorch + Numpy
* [endernewton/tf-faster-rcnn](https://github.com/endernewton/tf-faster-rcnn), developed based on TensorFlow + Numpy
* [ruotianluo/pytorch-faster-rcnn](https://github.com/ruotianluo/pytorch-faster-rcnn), developed based on Pytorch + TensorFlow + Numpy
During our implementing, we referred the above implementations, especailly [longcw/faster_rcnn_pytorch](https://github.com/longcw/faster_rcnn_pytorch). However, our implementation has several unique and new features compared with the above implementations:
* **It is pure Pytorch code**. We convert all the numpy implementations to pytorch!
* **It supports multi-image batch training**. We revise all the layers, including dataloader, rpn, roi-pooling, etc., to support multiple images in each minibatch.
* **It supports multiple GPUs training**. We use a multiple GPU wrapper (nn.DataParallel here) to make it flexible to use one or more GPUs, as a merit of the above two features.
* **It supports three pooling methods**. We integrate three pooling methods: roi pooing, roi align and roi crop. More importantly, we modify all of them to support multi-image batch training.
* **It is memory efficient**. We limit the image aspect ratio, and group images with similar aspect ratios into a minibatch. As such, we can train resnet101 and VGG16 with batchsize = 4 (4 images) on a single Titan X (12 GB). When training with 8 GPU, the maximum batchsize for each GPU is 3 (Res101), totaling 24.
* **It is faster**. Based on the above modifications, the training is much faster. We report the training speed on NVIDIA TITAN Xp in the tables below.
### What we are doing and going to do
- [x] Support both python2 and python3 (great thanks to [cclauss](https://github.com/cclauss)).
- [x] Add deformable pooling layer (mainly supported by [Xander](https://github.com/xanderchf)).
- [x] Support pytorch-0.4.0 (this branch).
- [x] Support tensorboardX.
- [x] Support pytorch-1.0 (go to pytorch-1.0 branch).
## Other Implementations
* [Feature Pyramid Network (FPN)](https://github.com/jwyang/fpn.pytorch)
* [Mask R-CNN](https://github.com/roytseng-tw/mask-rcnn.pytorch) (~~ongoing~~ already implemented by [roytseng-tw](https://github.com/roytseng-tw))
* [Graph R-CNN](https://github.com/jwyang/graph-rcnn.pytorch) (extension to scene graph generation)
## Benchmarking
We benchmark our code thoroughly on three datasets: pascal voc, coco and visual genome, using two different network architectures: vgg16 and resnet101. Below are the results:
1). PASCAL VOC 2007 (Train/Test: 07trainval/07test, scale=600, ROI Align)
model | #GPUs | batch size | lr | lr_decay | max_epoch | time/epoch | mem/GPU | mAP
---------|--------|-----|--------|-----|-----|-------|--------|-----
[VGG-16](https://www.dropbox.com/s/6ief4w7qzka6083/faster_rcnn_1_6_10021.pth?dl=0) | 1 | 1 | 1e-3 | 5 | 6 | 0.76 hr | 3265MB | 70.1
[VGG-16](https://www.dropbox.com/s/cpj2nu35am0f9hp/faster_rcnn_1_9_2504.pth?dl=0) | 1 | 4 | 4e-3 | 8 | 9 | 0.50 hr | 9083MB | 69.6
[VGG-16](https://www.dropbox.com/s/1a31y7vicby0kvy/faster_rcnn_1_10_625.pth?dl=0) | 8 | 16| 1e-2 | 8 | 10 | 0.19 hr | 5291MB | 69.4
[VGG-16](https://www.dropbox.com/s/hkj7i6mbhw9tq4k/faster_rcnn_1_11_416.pth?dl=0) | 8 | 24| 1e-2 | 10 | 11 | 0.16 hr | 11303MB | 69.2
[Res-101](https://www.dropbox.com/s/4v3or0054kzl19q/faster_rcnn_1_7_10021.pth?dl=0) | 1 | 1 | 1e-3 | 5 | 7 | 0.88 hr | 3200 MB | 75.2
[Res-101](https://www.dropbox.com/s/8bhldrds3mf0yuj/faster_rcnn_1_10_2504.pth?dl=0) | 1 | 4 | 4e-3 | 8 | 10 | 0.60 hr | 9700 MB | 74.9
[Res-101](https://www.dropbox.com/s/5is50y01m1l9hbu/faster_rcnn_1_10_625.pth?dl=0) | 8 | 16| 1e-2 | 8 | 10 | 0.23 hr | 8400 MB | 75.2
[Res-101](https://www.dropbox.com/s/cn8gneumg4gjo9i/faster_rcnn_1_12_416.pth?dl=0) | 8 | 24| 1e-2 | 10 | 12 | 0.17 hr | 10327MB | 75.1
2). COCO (Train/Test: coco_train+coco_val-minival/minival, scale=800, max_size=1200, ROI Align)
model | #GPUs | batch size |lr | lr_decay | max_epoch | time/epoch | mem/GPU | mAP
---------|--------|-----|--------|-----|-----|-------|--------|-----
VGG-16 | 8 | 16 |1e-2| 4 | 6 | 4.9 hr | 7192 MB | 29.2
[Res-101](https://www.dropbox.com/s/5if6l7mqsi4rfk9/faster_rcnn_1_6_14657.pth?dl=0) | 8 | 16 |1e-2| 4 | 6 | 6.0 hr |10956 MB | 36.2
[Res-101](https://www.dropbox.com/s/be0isevd22eikqb/faster_rcnn_1_10_14657.pth?dl=0) | 8 | 16 |1e-2| 4 | 10 | 6.0 hr |10956 MB | 37.0
**NOTE**. Since the above models use scale=800, you need add "--ls" at the end of test command.
3). COCO (Train/Test: coco_train+coco_val-minival/minival, scale=600, max_size=1000, ROI Align)
model | #GPUs | batch size |lr | lr_decay | max_epoch | time/epoch | mem/GPU | mAP
---------|--------|-----|--------|-----|-----|-------|--------|-----
[Res-101](https://www.dropbox.com/s/y171ze1sdw1o2ph/faster_rcnn_1_6_9771.pth?dl=0) | 8 | 24 |1e-2| 4 | 6 | 5.4 hr |10659 MB | 33.9
[Res-101](https://www.dropbox.com/s/dpq6qv0efspelr3/faster_rcnn_1_10_9771.pth?dl=0) | 8 | 24 |1e-2| 4 | 10 | 5.4 hr |10659 MB | 34.5
4). Visual Genome (Train/Test: vg_train/vg_test, scale=600, max_size=1000, ROI Align, category=2500)
model | #GPUs | batch size |lr | lr_decay | max_epoch | time/epoch | mem/GPU | mAP
---------|--------|-----|--------|-----|-----|-------|--------|-----
[VGG-16](http://data.lip6.fr/cadene/faster-rcnn.pytorch/faster_rcnn_1_19_48611.pth) | 1 P100 | 4 |1e-3| 5 | 20 | 3.7 hr |12707 MB | 4.4
Thanks to [Remi](https://github.com/Cadene) for providing the pretrained detection model on visual genome!
* Click the links in the above tables to download our pre-trained faster r-cnn models.
* If not mentioned, the GPU we used is NVIDIA Titan X Pascal (12GB).
## Preparation
First of all, clone the code
```
mv 项目 faster-rcnn.pytorch
```
Then, create a folder:
```
cd faster-rcnn.pytorch && mkdir data
```
### prerequisites
* Python 2.7 or 3.6
* Pytorch 0.4.0 (**now it does not support 0.4.1 or higher**)
* CUDA 8.0 or higher
### Data Preparation
* **PASCAL_VOC 07+12**: Please follow the instructions in [py-faster-rcnn](https://github.com/rbgirshick/py-faster-rcnn#beyond-the-demo-installation-for-training-and-testing-models) to prepare VOC datasets. Actually, you can refer to any others. After downloading the data, create softlink
没有合适的资源?快使用搜索试试~ 我知道了~
pytorch-使用Pytorch实现的faster-rcnn目标检测算法.zip
共135个文件
py:77个
h:12个
jpg:12个
3 下载量 169 浏览量
2024-03-02
07:20:46
上传
评论
收藏 1.41MB ZIP 举报
温馨提示
pytorch_使用Pytorch实现的faster-rcnn目标检测算法
资源推荐
资源详情
资源评论
收起资源包目录
pytorch-使用Pytorch实现的faster-rcnn目标检测算法.zip (135个子文件)
_mask.c 584KB
roi_crop.c 23KB
maskApi.c 8KB
roi_align.c 7KB
roi_crop_cuda.c 5KB
roi_pooling.c 4KB
roi_pooling_cuda.c 3KB
roi_align_cuda.c 2KB
nms_cuda.c 608B
roi_crop_cuda_kernel.cu 17KB
roi_pooling_kernel.cu 9KB
roi_align_kernel.cu 8KB
nms_cuda_kernel.cu 5KB
nms_kernel.cu 5KB
.gitignore 15B
.gitignore 15B
roi_crop_cuda_kernel.h 3KB
maskApi.h 2KB
roi_align_kernel.h 1KB
roi_pooling_kernel.h 767B
roi_crop.h 659B
roi_crop_cuda.h 481B
roi_pooling_cuda.h 420B
roi_align_cuda.h 369B
roi_align.h 361B
nms_cuda.h 272B
nms_cuda_kernel.h 206B
roi_pooling.h 178B
img2_det.jpg 111KB
img2_det_res101.jpg 111KB
img2.jpg 111KB
img3_det.jpg 105KB
img3_det_res101.jpg 105KB
img3.jpg 100KB
img4_det_res101.jpg 89KB
img4_det.jpg 89KB
img1_det.jpg 84KB
img1_det_res101.jpg 84KB
img4.jpg 83KB
img1.jpg 77KB
voc_eval.m 1KB
xVOCap.m 258B
get_voc_opts.m 231B
README.md 14KB
cocoeval.py 19KB
vg.py 16KB
gridgen.py 16KB
coco.py 15KB
pascal_voc.py 15KB
trainval_net.py 14KB
demo.py 13KB
test_net.py 12KB
coco.py 12KB
config.py 12KB
pascal_voc_rbg.py 11KB
bbox_transform.py 9KB
proposal_target_layer_cascade.py 9KB
imdb.py 9KB
resnet.py 9KB
anchor_target_layer.py 9KB
roibatchLoader.py 9KB
imagenet.py 8KB
net_utils.py 7KB
proposal_layer.py 7KB
voc_eval.py 7KB
faster_rcnn.py 6KB
setup.py 5KB
roidb.py 4KB
rpn.py 4KB
vg_eval.py 4KB
mask.py 4KB
generate_anchors.py 3KB
minibatch.py 3KB
factory.py 3KB
logger.py 2KB
gridgen.py 2KB
vgg16.py 2KB
roi_align.py 2KB
roi_pool.py 2KB
roi_align.py 2KB
blob.py 2KB
crop_resize.py 2KB
mcg_munge.py 1KB
ds_utils.py 1KB
roi_crop.py 1002B
build.py 902B
build.py 881B
build.py 875B
nms_cpu.py 862B
build.py 850B
nms_wrapper.py 757B
roi_pool.py 524B
__init__.py 385B
__init__.py 383B
__init__.py 382B
__init__.py 377B
_init_paths.py 312B
__init__.py 310B
nms_gpu.py 299B
roi_crop.py 287B
共 135 条
- 1
- 2
资源评论
__AtYou__
- 粉丝: 1162
- 资源: 258
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功