Home

Awesome

Feature Pyramid Networks for Object Detection

Note

A development version based on FPN.
Support multi-gpu training!

Abstract

This is a tensorflow re-implementation of Feature Pyramid Networks for Object Detection.

This project is based on Faster-RCNN, and completed by YangXue and YangJirui.

Train on VOC 2007 trainval and test on VOC 2007 test (PS. This project also support coco training.)

1

Comparison

use_voc2007_metric

ModelsmAPsheephorsebicyclebottlecowsofabusdogcatpersontraindiningtableaeroplanecarpottedplanttvmonitorchairbirdboatmotorbike
Faster-RCNN resnet50_v173.0972.1185.6377.7455.8281.1967.3482.4485.6687.3477.4979.1362.6576.5484.0147.9074.1350.0976.8160.3477.47
Faster-RCNN resnet101_v174.6376.3586.1879.8758.7383.474.7580.0385.486.5578.2476.0770.8978.5286.2647.8076.3452.1478.0658.9078.04
Faster-RCNN mobilenet_v250.3446.9968.4565.8928.1653.2146.9657.8038.6044.1266.2060.4952.4056.0672.6826.9149.9930.1839.3838.5464.74
FPN resnet50_v174.2673.2782.2382.9961.2780.5972.7381.3785.2684.7680.3377.4365.3179.1885.7846.4773.1055.9976.1159.8081.19
FPN resnet101_v176.1474.6385.1381.6763.7982.4377.8383.0786.4585.8281.0881.0171.2280.0186.3048.0573.8956.9978.3362.9182.24
FPN resnet101_v1+75.7174.8383.5582.4765.4977.8571.7480.9886.6187.1481.0277.7671.2679.8286.7851.6477.4556.1279.4460.5581.69
FPN resnet101_v1++75.8976.0584.2280.2963.2183.0478.6981.8186.6185.6179.7579.7871.2780.3386.2449.0376.8156.3278.5160.3779.91

+: SHARE_NET=False
++: SHORT_SIDE_LEN=800, FAST_RCNN_MINIBATCH_SIZE=512

COCO

ModelBackboneTrain ScheduleGPUImage/GPUFP16Box AP(Mask AP)
Faster (ours)R50v1-FPN1X1X TITAN Xp1no36.1
Faster (ours)R50v1-FPN1X4X TITAN Xp1no36.1
Faster (Face++ & Detectron)R50v1-FPN1X8X TITAN Xp2no36.4
Faster (SimpleDet)R50v1-FPN1X8X 1080Ti2no36.5

2

My Development Environment

1、python3.5 (anaconda recommend)
2、cuda9.0 (If you want to use cuda8, please set CUDA9 = False in the cfgs.py file.)
3、opencv(cv2)
4、tfplot
5、tensorflow == 1.10

Download Model

Please download resnet50_v1resnet101_v1 pre-trained models on Imagenet, put it to $PATH_ROOT/data/pretrained_weights.

Data Format

├── VOCdevkit
│   ├── VOCdevkit_train
│       ├── Annotation
│       ├── JPEGImages
│   ├── VOCdevkit_test
│       ├── Annotation
│       ├── JPEGImages

Compile

cd $PATH_ROOT/libs/box_utils/cython_utils
python setup.py build_ext --inplace

Demo(available)

Select a configuration file in the folder ($PATH_ROOT/libs/configs/) and copy its contents into cfgs.py, then download the corresponding weights.

cd $PATH_ROOT/tools
python inference.py --data_dir='/PATH/TO/IMAGES/' 
                    --save_dir='/PATH/TO/SAVE/RESULTS/' 
                    --GPU='0'

Eval

cd $PATH_ROOT/tools
python eval.py --eval_imgs='/PATH/TO/IMAGES/'  
               --annotation_dir='/PATH/TO/TEST/ANNOTATION/'
               --GPU='0'

Train

1、If you want to train your own data, please note:

(1) Modify parameters (such as CLASS_NUM, DATASET_NAME, VERSION, etc.) in $PATH_ROOT/libs/configs/cfgs.py
(2) Add category information in $PATH_ROOT/libs/label_name_dict/lable_dict.py     
(3) Add data_name to line 76 of $PATH_ROOT/data/io/read_tfrecord.py 

2、make tfrecord

cd $PATH_ROOT/data/io/  
python convert_data_to_tfrecord.py --VOC_dir='/PATH/TO/VOCdevkit/VOCdevkit_train/' 
                                   --xml_dir='Annotation'
                                   --image_dir='JPEGImages'
                                   --save_name='train' 
                                   --img_format='.jpg' 
                                   --dataset='pascal'

3、train

cd $PATH_ROOT/tools
python train.py

4、multi-gpu train

cd $PATH_ROOT/tools
python multi_gpu_train.py

Tensorboard

cd $PATH_ROOT/output/summary
tensorboard --logdir=.

3 4

Reference

1、https://github.com/endernewton/tf-faster-rcnn
2、https://github.com/zengarden/light_head_rcnn
3、https://github.com/tensorflow/models/tree/master/research/object_detection
4、https://github.com/CharlesShang/FastMaskRCNN
5、https://github.com/matterport/Mask_RCNN
6、https://github.com/msracver/Deformable-ConvNets