Home

Awesome

Faster-RCNN_Tensorflow

Abstract

This is a tensorflow re-implementation of Faster R-CNN: Towards Real-Time ObjectDetection with Region Proposal Networks.

This project is completed by YangXue and YangJirui. Some relevant projects (R<sup>2</sup>CNN) and (RRPN) based on this code.

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

1

Comparison

use_voc2012_metric

ModelsmAPsheephorsebicyclebottlecowsofabusdogcatpersontraindiningtableaeroplanecarpottedplanttvmonitorchairbirdboatmotorbike
resnet50_v175.1674.0889.2780.2755.7483.3869.3585.1388.8091.4281.1781.7162.7478.6586.8647.0076.7150.2979.0560.5180.96
resnet101_v177.0379.6889.3383.8959.4185.6876.5984.2388.5088.5081.5479.1672.6680.2688.4247.5079.8152.8580.7059.9481.87
mobilenet_v250.3646.6870.4567.4325.6953.6046.2658.9537.6243.9767.6761.3552.1456.5475.0224.4749.8927.7638.0438.2065.46

use_voc2007_metric

ModelsmAPsheephorsebicyclebottlecowsofabusdogcatpersontraindiningtableaeroplanecarpottedplanttvmonitorchairbirdboatmotorbike
resnet50_v173.0972.1185.6377.7455.8281.1967.3482.4485.6687.3477.4979.1362.6576.5484.0147.9074.1350.0976.8160.3477.47
resnet101_v174.6376.3586.1879.8758.7383.474.7580.0385.486.5578.2476.0770.8978.5286.2647.8076.3452.1478.0658.9078.04
mobilenet_v250.3446.9968.4565.8928.1653.2146.9657.8038.6044.1266.2060.4952.4056.0672.6826.9149.9930.1839.3838.5464.74

Requirements

1、tensorflow >= 1.2
2、cuda8.0
3、python2.7 (anaconda2 recommend)
4、opencv(cv2)

Download Model

1、please download resnet50_v1resnet101_v1 pre-trained models on Imagenet, put it to $PATH_ROOT/data/pretrained_weights.
2、please download mobilenet_v2 pre-trained model on Imagenet, put it to $PATH_ROOT/data/pretrained_weights/mobilenet.
3、please download trained model by this project, put it to $PATH_ROOT/output/trained_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

Tensorboard

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

2 1

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