Skip to content

Commit d66cc2b

Browse files
committed
MS COCO dataset support
1 parent 4520c19 commit d66cc2b

File tree

90 files changed

+4596
-205
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+4596
-205
lines changed

README.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ If you find Faster R-CNN useful in your research, please consider citing:
5555
```make
5656
# In your Makefile.config, make sure to have this line uncommented
5757
WITH_PYTHON_LAYER := 1
58+
# Unrelatedly, it's also recommended that you use CUDNN
59+
USE_CUDNN := 1
5860
```
5961

6062
You can download my [Makefile.config](http://www.cs.berkeley.edu/~rbg/fast-rcnn-data/Makefile.config) for reference.
@@ -115,8 +117,6 @@ If you find Faster R-CNN useful in your research, please consider citing:
115117

116118
*After successfully completing [basic installation](#installation-sufficient-for-the-demo)*, you'll be ready to run the demo.
117119

118-
**Python**
119-
120120
To run the demo
121121
```Shell
122122
cd $FRCN_ROOT
@@ -158,7 +158,8 @@ The demo performs detection using a VGG16 network trained for detection on PASCA
158158
```
159159
Using symlinks is a good idea because you will likely want to share the same PASCAL dataset installation between multiple projects.
160160
5. [Optional] follow similar steps to get PASCAL VOC 2010 and 2012
161-
6. Follow the next sections to download pre-trained ImageNet models
161+
6. [Optional] If you want to use COCO, please see some notes under `data/README.md`
162+
7. Follow the next sections to download pre-trained ImageNet models
162163

163164
### Download pre-trained ImageNet models
164165

@@ -200,3 +201,17 @@ cd $FRCN_ROOT
200201
```
201202

202203
This method trains the RPN module jointly with the Fast R-CNN network, rather than alternating between training the two. It results in faster (~ 1.5x speedup) training times and similar detection accuracy. See these [slides](https://www.dropbox.com/s/xtr4yd4i5e0vw8g/iccv15_tutorial_training_rbg.pdf?dl=0) for more details.
204+
205+
Artifacts generated by the scripts in `tools` are written in this directory.
206+
207+
Trained Fast R-CNN networks are saved under:
208+
209+
```
210+
output/<experiment directory>/<dataset name>/
211+
```
212+
213+
Test outputs are saved under:
214+
215+
```
216+
output/<experiment directory>/<dataset name>/<network snapshot name>/
217+
```

data/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,20 @@ ln -s /your/path/to/VOC2007/VOCdevkit VOCdevkit2007
3030
ln -s /your/path/to/VOC2012/VOCdevkit VOCdevkit2012
3131
```
3232

33+
Install the MS COCO dataset at /path/to/coco
34+
35+
```
36+
ln -s /path/to/coco coco
37+
```
38+
39+
For COCO with Fast R-CNN, place object proposals under `coco_proposals` (inside
40+
the `data` directory). You can obtain proposals on COCO from Jan Hosang at
41+
https://www.mpi-inf.mpg.de/departments/computer-vision-and-multimodal-computing/research/object-recognition-and-scene-understanding/how-good-are-detection-proposals-really/.
42+
For COCO, using MCG is recommended over selective search. MCG boxes can be downloaded
43+
from http://www.eecs.berkeley.edu/Research/Projects/CS/vision/grouping/mcg/.
44+
Use the tool `lib/datasets/tools/mcg_munge.py` to convert the downloaded MCG data
45+
into the same file layout as those from Jan Hosang.
46+
3347
Since you'll likely be experimenting with multiple installs of Fast/er R-CNN in
3448
parallel, you'll probably want to keep all of this data in a shared place and
3549
use symlinks. On my system I create the following symlinks inside `data`:
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
EXP_DIR: faster_rcnn_alt_opt
2+
TRAIN:
3+
BG_THRESH_LO: 0.0
24
TEST:
35
HAS_RPN: True

experiments/cfgs/faster_rcnn_end2end.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ TRAIN:
66
RPN_POSITIVE_OVERLAP: 0.7
77
RPN_BATCHSIZE: 256
88
PROPOSAL_METHOD: gt
9+
BG_THRESH_LO: 0.0
910
TEST:
1011
HAS_RPN: True

experiments/scripts/fast_rcnn.sh

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#!/bin/bash
22
# Usage:
3-
# ./experiments/scripts/default.sh GPU NET [options args to {train,test}_net.py]
3+
# ./experiments/scripts/fast_rcnn.sh GPU NET DATASET [options args to {train,test}_net.py]
4+
# DATASET is either pascal_voc or coco.
5+
#
46
# Example:
5-
# ./experiments/scripts/default.sh 0 CaffeNet \
7+
# ./experiments/scripts/fast_rcnn.sh 0 VGG_CNN_M_1024 pascal_voc \
68
# --set EXP_DIR foobar RNG_SEED 42 TRAIN.SCALES "[400, 500, 600, 700]"
79

810
set -x
@@ -13,28 +15,49 @@ export PYTHONUNBUFFERED="True"
1315
GPU_ID=$1
1416
NET=$2
1517
NET_lc=${NET,,}
18+
DATASET=$3
1619

1720
array=( $@ )
1821
len=${#array[@]}
19-
EXTRA_ARGS=${array[@]:2:$len}
22+
EXTRA_ARGS=${array[@]:3:$len}
2023
EXTRA_ARGS_SLUG=${EXTRA_ARGS// /_}
2124

22-
LOG="experiments/logs/default_${NET}_${EXTRA_ARGS_SLUG}.txt.`date +'%Y-%m-%d_%H-%M-%S'`"
25+
case $DATASET in
26+
pascal_voc)
27+
TRAIN_IMDB="voc_2007_trainval"
28+
TEST_IMDB="voc_2007_test"
29+
PT_DIR="pascal_voc"
30+
ITERS=40000
31+
;;
32+
coco)
33+
TRAIN_IMDB="coco_2014_train"
34+
TEST_IMDB="coco_2014_minival"
35+
PT_DIR="coco"
36+
ITERS=280000
37+
;;
38+
*)
39+
echo "No dataset given"
40+
exit
41+
;;
42+
esac
43+
44+
LOG="experiments/logs/fast_rcnn_${NET}_${EXTRA_ARGS_SLUG}.txt.`date +'%Y-%m-%d_%H-%M-%S'`"
2345
exec &> >(tee -a "$LOG")
2446
echo Logging output to "$LOG"
2547

2648
time ./tools/train_net.py --gpu ${GPU_ID} \
27-
--solver models/${NET}/fast_rcnn/solver.prototxt \
49+
--solver models/${PT_DIR}/${NET}/fast_rcnn/solver.prototxt \
2850
--weights data/imagenet_models/${NET}.v2.caffemodel \
29-
--imdb voc_2007_trainval \
51+
--imdb ${TRAIN_IMDB} \
52+
--iters ${ITERS} \
3053
${EXTRA_ARGS}
3154

3255
set +x
3356
NET_FINAL=`grep -B 1 "done solving" ${LOG} | grep "Wrote snapshot" | awk '{print $4}'`
3457
set -x
3558

3659
time ./tools/test_net.py --gpu ${GPU_ID} \
37-
--def models/${NET}/fast_rcnn/test.prototxt \
60+
--def models/${PT_DIR}/${NET}/fast_rcnn/test.prototxt \
3861
--net ${NET_FINAL} \
39-
--imdb voc_2007_test \
62+
--imdb ${TEST_IMDB} \
4063
${EXTRA_ARGS}
Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
#!/bin/bash
22
# Usage:
3-
# ./experiments/scripts/default_faster_rcnn_alt_opt.sh GPU NET [--set ...]
3+
# ./experiments/scripts/faster_rcnn_alt_opt.sh GPU NET DATASET [options args to {train,test}_net.py]
4+
# DATASET is only pascal_voc for now
5+
#
46
# Example:
5-
# ./experiments/scripts/default_faster_rcnn_alt_opt.sh 0 ZF \
6-
# --set EXP_DIR foobar RNG_SEED 42 TRAIN.SCALES "[400,500,600,700]"
7+
# ./experiments/scripts/faster_rcnn_alt_opt.sh 0 VGG_CNN_M_1024 pascal_voc \
8+
# --set EXP_DIR foobar RNG_SEED 42 TRAIN.SCALES "[400, 500, 600, 700]"
79

810
set -x
911
set -e
@@ -13,20 +15,38 @@ export PYTHONUNBUFFERED="True"
1315
GPU_ID=$1
1416
NET=$2
1517
NET_lc=${NET,,}
18+
DATASET=$3
1619

1720
array=( $@ )
1821
len=${#array[@]}
19-
EXTRA_ARGS=${array[@]:2:$len}
22+
EXTRA_ARGS=${array[@]:3:$len}
2023
EXTRA_ARGS_SLUG=${EXTRA_ARGS// /_}
2124

25+
case $DATASET in
26+
pascal_voc)
27+
TRAIN_IMDB="voc_2007_trainval"
28+
TEST_IMDB="voc_2007_test"
29+
PT_DIR="pascal_voc"
30+
ITERS=40000
31+
;;
32+
coco)
33+
echo "Not implemented: use experiments/scripts/faster_rcnn_end2end.sh for coco"
34+
exit
35+
;;
36+
*)
37+
echo "No dataset given"
38+
exit
39+
;;
40+
esac
41+
2242
LOG="experiments/logs/faster_rcnn_alt_opt_${NET}_${EXTRA_ARGS_SLUG}.txt.`date +'%Y-%m-%d_%H-%M-%S'`"
2343
exec &> >(tee -a "$LOG")
2444
echo Logging output to "$LOG"
2545

2646
time ./tools/train_faster_rcnn_alt_opt.py --gpu ${GPU_ID} \
2747
--net_name ${NET} \
2848
--weights data/imagenet_models/${NET}.v2.caffemodel \
29-
--imdb voc_2007_trainval \
49+
--imdb ${TRAIN_IMDB} \
3050
--cfg experiments/cfgs/faster_rcnn_alt_opt.yml \
3151
${EXTRA_ARGS}
3252

@@ -35,8 +55,8 @@ NET_FINAL=`grep "Final model:" ${LOG} | awk '{print $3}'`
3555
set -x
3656

3757
time ./tools/test_net.py --gpu ${GPU_ID} \
38-
--def models/${NET}/faster_rcnn_alt_opt/faster_rcnn_test.pt \
58+
--def models/${PT_DIR}/${NET}/faster_rcnn_alt_opt/faster_rcnn_test.pt \
3959
--net ${NET_FINAL} \
40-
--imdb voc_2007_test \
60+
--imdb ${TEST_IMDB} \
4161
--cfg experiments/cfgs/faster_rcnn_alt_opt.yml \
4262
${EXTRA_ARGS}
Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
#!/bin/bash
22
# Usage:
3-
# ./experiments/scripts/default_faster_rcnn.sh GPU NET [--set ...]
3+
# ./experiments/scripts/faster_rcnn_end2end.sh GPU NET DATASET [options args to {train,test}_net.py]
4+
# DATASET is either pascal_voc or coco.
5+
#
46
# Example:
5-
# ./experiments/scripts/default_faster_rcnn.sh 0 ZF \
6-
# --set EXP_DIR foobar RNG_SEED 42 TRAIN.SCALES "[400,500,600,700]"
7+
# ./experiments/scripts/faster_rcnn_end2end.sh 0 VGG_CNN_M_1024 pascal_voc \
8+
# --set EXP_DIR foobar RNG_SEED 42 TRAIN.SCALES "[400, 500, 600, 700]"
79

810
set -x
911
set -e
@@ -13,25 +15,43 @@ export PYTHONUNBUFFERED="True"
1315
GPU_ID=$1
1416
NET=$2
1517
NET_lc=${NET,,}
16-
ITERS=70000
17-
DATASET_TRAIN=voc_2007_trainval
18-
DATASET_TEST=voc_2007_test
18+
DATASET=$3
1919

2020
array=( $@ )
2121
len=${#array[@]}
22-
EXTRA_ARGS=${array[@]:2:$len}
22+
EXTRA_ARGS=${array[@]:3:$len}
2323
EXTRA_ARGS_SLUG=${EXTRA_ARGS// /_}
2424

25-
LOG="experiments/logs/faster_rcnn_${NET}_${EXTRA_ARGS_SLUG}.txt.`date +'%Y-%m-%d_%H-%M-%S'`"
25+
case $DATASET in
26+
pascal_voc)
27+
TRAIN_IMDB="voc_2007_trainval"
28+
TEST_IMDB="voc_2007_test"
29+
PT_DIR="pascal_voc"
30+
ITERS=70000
31+
;;
32+
coco)
33+
# This is a very long and slow training schedule
34+
# You can probably use fewer iterations and reduce the
35+
# time to the LR drop (set in the solver to 350,000 iterations).
36+
TRAIN_IMDB="coco_2014_train"
37+
TEST_IMDB="coco_2014_minival"
38+
PT_DIR="coco"
39+
ITERS=490000
40+
;;
41+
*)
42+
echo "No dataset given"
43+
exit
44+
;;
45+
esac
46+
47+
LOG="experiments/logs/faster_rcnn_end2end_${NET}_${EXTRA_ARGS_SLUG}.txt.`date +'%Y-%m-%d_%H-%M-%S'`"
2648
exec &> >(tee -a "$LOG")
2749
echo Logging output to "$LOG"
2850

29-
NET_INIT=data/imagenet_models/${NET}.v2.caffemodel
30-
3151
time ./tools/train_net.py --gpu ${GPU_ID} \
32-
--solver models/${NET}/faster_rcnn_end2end/solver.prototxt \
33-
--weights ${NET_INIT} \
34-
--imdb ${DATASET_TRAIN} \
52+
--solver models/${PT_DIR}/${NET}/faster_rcnn_end2end/solver.prototxt \
53+
--weights data/imagenet_models/${NET}.v2.caffemodel \
54+
--imdb ${TRAIN_IMDB} \
3555
--iters ${ITERS} \
3656
--cfg experiments/cfgs/faster_rcnn_end2end.yml \
3757
${EXTRA_ARGS}
@@ -41,8 +61,8 @@ NET_FINAL=`grep -B 1 "done solving" ${LOG} | grep "Wrote snapshot" | awk '{print
4161
set -x
4262

4363
time ./tools/test_net.py --gpu ${GPU_ID} \
44-
--def models/${NET}/faster_rcnn_end2end/test.prototxt \
64+
--def models/${PT_DIR}/${NET}/faster_rcnn_end2end/test.prototxt \
4565
--net ${NET_FINAL} \
46-
--imdb ${DATASET_TEST} \
66+
--imdb ${TEST_IMDB} \
4767
--cfg experiments/cfgs/faster_rcnn_end2end.yml \
4868
${EXTRA_ARGS}

0 commit comments

Comments
 (0)