Skip to content

Commit b4f802e

Browse files
authored
Merge pull request #901 from ZhangHandi/my_branch
add 3d detection case
2 parents 75278f9 + 0c27ab1 commit b4f802e

File tree

48,774 files changed

+120510
-0
lines changed

Some content is hidden

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

48,774 files changed

+120510
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# M3D-RPN: Monocular 3D Region Proposal Network for Object Detection
2+
3+
4+
5+
## Introduction
6+
7+
8+
Monocular 3D region proposal network for object detection accepted to ICCV 2019 (Oral), detailed in [arXiv report](https://arxiv.org/abs/1907.06038).
9+
10+
11+
12+
13+
## Setup
14+
15+
- **Cuda & Python**
16+
17+
In this project we utilize PaddlePaddle1.8 with Python 3, Cuda 9, and a few Anaconda packages.
18+
19+
- **Data**
20+
21+
Download the full [KITTI](http://www.cvlibs.net/datasets/kitti/eval_object.php?obj_benchmark=3d) detection dataset. Then place a softlink (or the actual data) in *M3D-RPN/data/kitti*.
22+
23+
```
24+
cd M3D-RPN
25+
ln -s /path/to/kitti dataset/kitti
26+
```
27+
28+
Then use the following scripts to extract the data splits, which use softlinks to the above directory for efficient storage.
29+
30+
```
31+
python dataset/kitti_split1/setup_split.py
32+
python dataset/kitti_split2/setup_split.py
33+
```
34+
35+
Next, build the KITTI devkit eval for each split.
36+
37+
```
38+
sh dataset/kitti_split1/devkit/cpp/build.sh
39+
sh dataset/kitti_split2/devkit/cpp/build.sh
40+
```
41+
42+
Lastly, build the nms modules
43+
44+
```
45+
cd lib/nms
46+
make
47+
```
48+
49+
## Training
50+
51+
52+
Training is split into a warmup and main configurations. Review the configurations in *config* for details.
53+
54+
```
55+
// First train the warmup (without depth-aware)
56+
python train.py --config=kitti_3d_multi_warmup
57+
58+
// Then train the main experiment (with depth-aware)
59+
python train.py --config=kitti_3d_multi_main
60+
```
61+
62+
63+
64+
## Testing
65+
66+
We provide models for the main experiments on val1 data splits available to download here [M3D-RPN-release.tar](https://pan.baidu.com/s/1VQa5hGzIbauLOQi-0kR9Hg), passward:ls39.
67+
68+
Testing requires paths to the configuration file and model weights, exposed variables near the top *test.py*. To test a configuration and model, simply update the variables and run the test file as below.
69+
70+
```
71+
python test.py --conf_path M3D-RPN-release/conf.pkl --weights_path M3D-RPN-release/iter50000.0_params.pdparams
72+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
"""
2+
config of warmup
3+
"""
4+
5+
from easydict import EasyDict as edict
6+
import numpy as np
7+
8+
9+
def Config():
10+
"""
11+
config
12+
"""
13+
conf = edict()
14+
15+
# ----------------------------------------
16+
# general
17+
# ----------------------------------------
18+
19+
conf.model = 'model_3d_dilate'
20+
# solver settings
21+
conf.solver_type = 'sgd'
22+
conf.lr = 0.004
23+
conf.momentum = 0.9
24+
conf.weight_decay = 0.0005
25+
conf.max_iter = 50000
26+
conf.snapshot_iter = 10000
27+
conf.display = 20
28+
conf.do_test = True
29+
30+
# sgd parameters
31+
conf.lr_policy = 'poly'
32+
conf.lr_steps = None
33+
conf.lr_target = conf.lr * 0.00001
34+
35+
# random
36+
conf.rng_seed = 2
37+
conf.cuda_seed = 2
38+
39+
# misc network
40+
conf.image_means = [0.485, 0.456, 0.406]
41+
conf.image_stds = [0.229, 0.224, 0.225]
42+
conf.feat_stride = 16
43+
44+
conf.has_3d = True
45+
46+
# ----------------------------------------
47+
# image sampling and datasets
48+
# ----------------------------------------
49+
50+
# scale sampling
51+
conf.test_scale = 512
52+
conf.crop_size = [512, 1760]
53+
conf.mirror_prob = 0.50
54+
conf.distort_prob = -1
55+
56+
# datasets
57+
conf.dataset_test = 'kitti_split1'
58+
conf.datasets_train = [{
59+
'name': 'kitti_split1',
60+
'anno_fmt': 'kitti_det',
61+
'im_ext': '.png',
62+
'scale': 1
63+
}]
64+
conf.use_3d_for_2d = True
65+
66+
# percent expected height ranges based on test_scale
67+
# used for anchor selection
68+
conf.percent_anc_h = [0.0625, 0.75]
69+
70+
# labels settings
71+
conf.min_gt_h = conf.test_scale * conf.percent_anc_h[0]
72+
conf.max_gt_h = conf.test_scale * conf.percent_anc_h[1]
73+
conf.min_gt_vis = 0.65
74+
conf.ilbls = ['Van', 'ignore']
75+
conf.lbls = ['Car', 'Pedestrian', 'Cyclist']
76+
77+
# ----------------------------------------
78+
# detection sampling
79+
# ----------------------------------------
80+
81+
# detection sampling
82+
conf.batch_size = 2
83+
conf.fg_image_ratio = 1.0
84+
conf.box_samples = 0.20
85+
conf.fg_fraction = 0.20
86+
conf.bg_thresh_lo = 0
87+
conf.bg_thresh_hi = 0.5
88+
conf.fg_thresh = 0.5
89+
conf.ign_thresh = 0.5
90+
conf.best_thresh = 0.35
91+
92+
# ----------------------------------------
93+
# inference and testing
94+
# ----------------------------------------
95+
96+
# nms
97+
conf.nms_topN_pre = 3000
98+
conf.nms_topN_post = 40
99+
conf.nms_thres = 0.4
100+
conf.clip_boxes = False
101+
102+
conf.test_protocol = 'kitti'
103+
conf.test_db = 'kitti'
104+
conf.test_min_h = 0
105+
conf.min_det_scales = [0, 0]
106+
107+
# ----------------------------------------
108+
# anchor settings
109+
# ----------------------------------------
110+
111+
# clustering settings
112+
conf.cluster_anchors = 0
113+
conf.even_anchors = 0
114+
conf.expand_anchors = 0
115+
116+
conf.anchors = None
117+
118+
conf.bbox_means = None
119+
conf.bbox_stds = None
120+
121+
# initialize anchors
122+
base = (conf.max_gt_h / conf.min_gt_h)**(1 / (12 - 1))
123+
conf.anchor_scales = np.array(
124+
[conf.min_gt_h * (base**i) for i in range(0, 12)])
125+
conf.anchor_ratios = np.array([0.5, 1.0, 1.5])
126+
127+
# loss logic
128+
conf.hard_negatives = True
129+
conf.focal_loss = 0
130+
conf.cls_2d_lambda = 1
131+
conf.iou_2d_lambda = 1
132+
conf.bbox_2d_lambda = 0
133+
conf.bbox_3d_lambda = 1
134+
conf.bbox_3d_proj_lambda = 0.0
135+
136+
conf.hill_climbing = True
137+
138+
conf.pretrained = 'pretrained_model/densenet.pdparams'
139+
# visdom
140+
conf.visdom_port = 8100
141+
142+
return conf
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
"""
15+
init
16+
"""
17+
from . import m3drpn_reader
18+
#from .m3drpn_reader import *
19+
20+
#__all__ = m3drpn_reader.__all__

0 commit comments

Comments
 (0)