Skip to content
Light-Head R-CNN
Branch: master
Clone or download
Latest commit 790f94e Jul 18, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
experiments/lizeming use tf nms Jul 18, 2018
lib Update Jul 18, 2018
tools light-head r-cnn born Apr 3, 2018
.gitignore light-head r-cnn born Apr 3, 2018 use tf nms Jul 18, 2018

Light-head R-CNN


We release code for Light-Head R-CNN.

This is my best practice for my research.

This repo is organized as follows:

    |    |->user
    |    |    |->your_models

Main Results

  1. We train on COCO trainval which includes 80k training and 35k validation images. Test on minival which is a 5k subset in validation datasets. Noticing test-dev should be little higher than minival.
  2. We provide some crutial ablation experiments details, and it is easy to diff the difference.
  3. We share our training logs in GoogleDrive output folder, which contains dump models, training loss and speed of each steps. (experiments are done on 8 titan xp, and 2batches/per_gpu. Training should be within one day.)
  4. Because the limitation of the time, extra experiments are comming soon.
Model Name mAP@all mAP@0.5 mAP@0.75 mAP@S mAP@M mAP@L
R-FCN, ResNet-v1-101
our reproduce baseline
35.5 54.3 33.8 12.8 34.9 46.1
Light-Head R-CNN
38.2 60.9 41.0 20.9 42.2 52.8
+align pooling
39.3 61.0 42.4 22.2 43.8 53.2
+align pooling + nms0.5
40.0 62.1 42.9 22.5 44.6 54.0

Experiments path related to model:



  1. tensorflow-gpu==1.5.0 (We only test on tensorflow 1.5.0, early tensorflow is not supported because of our gpu nms implementation)
  2. python3. We recommend using Anaconda as it already includes many common packages. (python2 is not tested)
  3. Python packages might missing. pls fix it according to the error message.

Installation, Prepare data, Testing, Training


  1. Clone the Light-Head R-CNN repository, and we'll call the directory that you cloned Light-Head R-CNNN as ${lighthead_ROOT}.
git clone
  1. Compiling
cd ${lighthead_ROOT}/lib;

Make sure all of your compiling is successful. It may arise some errors, it is useful to find some common compile errors in FAQ

  1. Create log dump directory, data directory.
cd ${lighthead_ROOT};
mkdir output
mkdir data

Prepare data

data should be organized as follows:

    |    |->odformat
    |    |->instances_xxx.json
    |    |train2014
    |    |val2014

Download res101 basemodel:

wget -v
tar -xzvf resnet_v1_101_2016_08_28.tar.gz
mv resnet_v1_101.ckpt res101.ckpt

We transfer instances_xxx.json to odformat(object detection format), each line in odformat is an annotation(json) for one image. Our transformed odformat is shared in GoogleDrive .


  1. Using -d to assign gpu_id for testing. (e.g. -d 0,1,2,3 or -d 0-3 )
  2. Using -s to visualize the results.
  3. Using '-se' to specify start_epoch for testing.

We share our experiments output(logs) folder in GoogleDrive. Download it and place it to ${lighthead_ROOT}, then test our release model.


cd experiments/lizeming/light_head_rcnn.ori_res101.coco.ps_roialign
python3 -d 0-7 -se 26


We provide common used in tools, which can be linked to experiments folder.


cd experiments/lizeming/light_head_rcnn.ori_res101.coco.ps_roialign
python3 -tool
cp tools/ .
python3 -d 0-7


This repo is designed be fast and simple for research. There are still some can be improved: anchor_target and proposal_target layer are tf.py_func, which means it will run on cpu.


This is an implementation for Light-Head R-CNN, it is worth noting that:

  • The original implementation is based on our internal Platform used in Megvii. There are slight differences in the final accuracy and running time due to the plenty details in platform switch.
  • The code is tested on a server with 8 Pascal Titian XP gpu, 188.00 GB memory, and 40 core cpu.
  • We rewrite a faster nms in our inner platform, while hear we use tf.nms instead.

Citing Light-Head R-CNN

If you find Light-Head R-CNN is useful in your research, pls consider citing:

  title={Light-Head R-CNN: In Defense of Two-Stage Object Detector},
  author={Li, Zeming and Peng, Chao and Yu, Gang and Zhang, Xiangyu and Deng, Yangdong and Sun, Jian},
  journal={arXiv preprint arXiv:1711.07264},


  • fatal error: cuda/cuda_config.h: No such file or directory

First, find where is cuda_config.h.


find /usr/local/lib/ | grep cuda_config.h

then export your cpath, like:

export CPATH=$CPATH:/usr/local/lib/python3.5/dist-packages/external/local_config_cuda/cuda/
You can’t perform that action at this time.