Skip to content

Commit 4886e3a

Browse files
author
yanwei-li
committed
init commit
0 parents  commit 4886e3a

Some content is hidden

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

58 files changed

+10342
-0
lines changed

.gitignore

+134
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
*.ipynb
6+
7+
# C extensions
8+
*.so
9+
10+
# Distribution / packaging
11+
.Python
12+
build/
13+
develop-eggs/
14+
dist/
15+
downloads/
16+
eggs/
17+
.eggs/
18+
lib/
19+
lib64/
20+
parts/
21+
sdist/
22+
var/
23+
wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
MANIFEST
28+
29+
# PyInstaller
30+
# Usually these files are written by a python script from a template
31+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
32+
*.manifest
33+
*.spec
34+
35+
# Installer logs
36+
pip-log.txt
37+
pip-delete-this-directory.txt
38+
39+
# Unit test / coverage reports
40+
htmlcov/
41+
.tox/
42+
.coverage
43+
.coverage.*
44+
.cache
45+
nosetests.xml
46+
coverage.xml
47+
*.cover
48+
.hypothesis/
49+
.pytest_cache/
50+
51+
# Translations
52+
*.mo
53+
*.pot
54+
55+
# Django stuff:
56+
*.log
57+
local_settings.py
58+
db.sqlite3
59+
60+
# Flask stuff:
61+
instance/
62+
.webassets-cache
63+
64+
# Scrapy stuff:
65+
.scrapy
66+
67+
# Sphinx documentation
68+
docs/_build/
69+
70+
# PyBuilder
71+
target/
72+
73+
# Jupyter Notebook
74+
.ipynb_checkpoints
75+
76+
# pyenv
77+
.python-version
78+
79+
# celery beat schedule file
80+
celerybeat-schedule
81+
82+
# SageMath parsed files
83+
*.sage.py
84+
85+
# Environments
86+
.env
87+
.venv
88+
env/
89+
venv/
90+
ENV/
91+
env.bak/
92+
venv.bak/
93+
94+
# Spyder project settings
95+
.spyderproject
96+
.spyproject
97+
98+
# Rope project settings
99+
.ropeproject
100+
101+
# mkdocs documentation
102+
/site
103+
104+
# mypy
105+
.mypy_cache/
106+
107+
# cython generated cpp
108+
data
109+
.vscode
110+
.idea
111+
112+
# custom
113+
*.pkl
114+
*.pkl.json
115+
*.log.json
116+
work_dirs/
117+
exps/
118+
*~
119+
mmdet3d/.mim
120+
121+
# Pytorch
122+
*.pth
123+
124+
# demo
125+
*.jpg
126+
*.png
127+
data/s3dis/Stanford3dDataset_v1.2_Aligned_Version/
128+
data/scannet/scans/
129+
data/sunrgbd/OFFICIAL_SUNRGBD/
130+
*.obj
131+
*.ply
132+
133+
# Waymo evaluation
134+
mmdet3d/core/evaluation/waymo_utils/compute_detection_metrics_main

README.md

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
2+
# UVTR
3+
[![arXiv](https://img.shields.io/badge/arXiv-Paper-<COLOR>.svg)]()
4+
![visitors](https://visitor-badge.glitch.me/badge?page_id=dvlab-research/UVTR)
5+
6+
**Unifying Voxel-based Representation with Transformer for 3D Object Detection**
7+
8+
Yanwei Li, Yilun Chen, Xiaojuan Qi, Zeming Li, Jian Sun, Jiaya Jia
9+
10+
[[`arXiv`]()] [[`BibTeX`](#CitingUVTR)]
11+
12+
<div align="center">
13+
<img src="projects/docs/uvtr.png"/>
14+
</div><br/>
15+
16+
This project provides an implementation for the paper "[Unifying Voxel-based Representation with Transformer for 3D Object Detection]()" based on [mmDetection3D](https://github.com/open-mmlab/mmdetection3d). UVTR aims to unify multi-modality representations in the voxel space for accurate and robust single- or cross-modality 3D detection.
17+
18+
## Preparation
19+
This project is based on [mmDetection3D](https://github.com/open-mmlab/mmdetection3d), which can be constructed as follows.
20+
* Install PyTorch [v1.7.1](https://pytorch.org/get-started/previous-versions/) and mmDetection3D [v0.17.3](https://github.com/open-mmlab/mmdetection3d/tree/v0.17.3) following [the instructions](https://github.com/open-mmlab/mmdetection3d/blob/v0.17.3/docs/getting_started.md).
21+
* Copy our project and related files to installed mmDetection3D:
22+
```bash
23+
cp -r projects mmdetection3d/
24+
cp -r extra_tools mmdetection3d/
25+
```
26+
* Prepare the nuScenes dataset following [the structure](https://github.com/open-mmlab/mmdetection3d/blob/v0.17.3/docs/data_preparation.md).
27+
* Generate the unified data info and sampling database for nuScenes dataset:
28+
```bash
29+
python3 extra_tools/create_data.py nuscenes --root-path ./data/nuscenes --out-dir ./data/nuscenes --extra-tag nuscenes_unified
30+
```
31+
32+
## Training
33+
You can train the model following [the instructions](https://github.com/open-mmlab/mmdetection3d/blob/v0.17.3/docs/datasets/nuscenes_det.md).
34+
You can find the pretrained models [here](https://drive.google.com/drive/folders/1KvG7tBYhmFQCiF_pAZc3Aa3H_D__-Jqh?usp=sharing) if you want to train the model from scratch.
35+
For example, to launch UVTR training on multi GPUs,
36+
one should execute:
37+
```bash
38+
cd /path/to/mmdetection3d
39+
bash extra_tools/dist_train.sh ${CFG_FILE} ${NUM_GPUS}
40+
```
41+
or train with a single GPU:
42+
```bash
43+
python3 extra_tools/train.py ${CFG_FILE}
44+
```
45+
46+
## Evaluation
47+
You can evaluate the model following [the instructions](./docs/GETTING_STARTED.md).
48+
For example, to launch UVTR evaluation with a pretrained checkpoint on multi GPUs,
49+
one should execute:
50+
```bash
51+
bash extra_tools/dist_test.sh ${CFG_FILE} ${CKPT} ${NUM_GPUS} --eval=bbox
52+
```
53+
or evaluate with a single GPU:
54+
```bash
55+
python3 extra_tools/test.py ${CFG_FILE} ${CKPT} --eval=bbox
56+
```
57+
## nuScenes 3D Object Detection Results
58+
We provide results on nuScenes *val* set with pretrained models.
59+
| | NDS (%) | mAP (%) | mATE&darr; | mASE&darr; | mAOE&darr; | mAVE&darr; | mAAE&darr; | download |
60+
|---------------------------------------------|:-------:|:-------:|:-------:|:---------:|:---------:|:---------:|:---------:|:---------:|
61+
| Camera-based |
62+
| [UVTR-C-R50-H5](projects/configs/uvtr/camera_based/camera/uvtr_c_r50_h5.py) | 40.1 | 31.3 | 0.810 | 0.281 | 0.486 | 0.793 | 0.187 | [GoogleDrive](https://drive.google.com/file/d/1gomNuo5--I5bdDiuiJxnhUbSw4GqE4VO/view?usp=sharing) |
63+
| [UVTR-C-R50-H11](projects/configs/uvtr/camera_based/camera/uvtr_c_r50_h11.py) | 41.8 | 33.3 | 0.795 | 0.276 | 0.452 | 0.761 | 0.196 | [GoogleDrive](https://drive.google.com/file/d/1ZCwzpsByd5ZulgHltGQCIzoOZmI8FC12/view?usp=sharing) |
64+
| [UVTR-C-R101](projects/configs/uvtr/camera_based/camera/uvtr_c_r101_h11.py) | 44.1 | 36.1 | 0.761 | 0.271 | 0.409 | 0.756 | 0.203 | [GoogleDrive](https://drive.google.com/file/d/1Mc3ZDGDPqc5uqZvrJswTn4TQdsEwtnAP/view?usp=sharing) |
65+
| [UVTR-CS-R50](projects/configs/uvtr/camera_based/camera_sweep/uvtr_cs5_r50_h11.py) | 47.2 | 36.2 | 0.756 | 0.276 | 0.399 | 0.467 | 0.189 | [GoogleDrive](https://drive.google.com/file/d/1BHsUzTuColqtHEIXczhgC7SsWi_0mA69/view?usp=sharing) |
66+
| [UVTR-CS-R101](projects/configs/uvtr/camera_based/camera_sweep/uvtr_cs4_r101_h11.py) | 48.3 | 37.9 | 0.739 | 0.267 | 0.350 | 0.510 | 0.200 | [GoogleDrive](https://drive.google.com/file/d/1JcNbnIBfp5us2CaEktr1-4t5jWOFLldA/view?usp=sharing) |
67+
| [UVTR-L2C-R101](projects/configs/uvtr/camera_based/knowledge_distill/uvtr_l2c_r101_h11.py) | 45.0 | 37.2 | 0.735 | 0.269 | 0.397 | 0.761 | 0.193 | [GoogleDrive](https://drive.google.com/file/d/1Knc9EHeOjXtAkRzRAN0jPUFSiqK2t1Ac/view?usp=sharing) |
68+
| [UVTR-L2CS3-R101](projects/configs/uvtr/camera_based/knowledge_distill/uvtr_l2cs3_r101_h11.py) | 48.8 | 39.2 | 0.720 | 0.268 | 0.354 | 0.534 | 0.206 | [GoogleDrive](https://drive.google.com/file/d/1Q5f-fESCKje9q98mj7v6pC9r_yYUw1-4/view?usp=sharing) |
69+
| LiDAR-based |
70+
| [UVTR-L-V0075](projects/configs/uvtr/lidar_based/uvtr_l_v0075_h5.py) | 67.6 | 60.8 | 0.335 | 0.257 | 0.303 | 0.206 | 0.183 | [GoogleDrive](https://drive.google.com/file/d/11wepYo4alFifpEEOtnmRJg6-plLE1QD8/view?usp=sharing) |
71+
| Multi-modality |
72+
| [UVTR-M-V0075-R101](projects/configs/uvtr/lidar_based/uvtr_l_v01_h5.py) | 70.2 | 65.4 | 0.333 | 0.258 | 0.270 | 0.216 | 0.176 | [GoogleDrive](https://drive.google.com/file/d/1dlxXIS4Cuv6ePxuxMRIaxpG_b1Pk8sqO/view?usp=sharing) |
73+
## Acknowledgement
74+
We would like to thank the authors of [mmDetection3D](https://github.com/open-mmlab/mmdetection3d) and [DETR3D](https://github.com/WangYueFt/detr3d) for their open-source release.
75+
76+
## License
77+
`UVTR` is released under the [Apache 2.0 license](LICENSE).
78+
79+
## <a name="CitingUVTR"></a>Citing UVTR
80+
81+
Consider cite UVTR in your publications if it helps your research.
82+
83+
```
84+
@article{li2022uvtr,
85+
title={Unifying Voxel-based Representation with Transformer for 3D Object Detection},
86+
author={Li, Yanwei and Chen, Yilun and Qi, Xiaojuan and Li, Zeming and Sun, Jian and Jia, Jiaya},
87+
booktitle={arXiv},
88+
year={2022}
89+
}
90+
```

extra_tools/create_data.py

+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Copyright (c) OpenMMLab. All rights reserved.
2+
import argparse
3+
from os import path as osp
4+
5+
from data_converter import nuscenes_converter as nuscenes_converter
6+
from data_converter.create_unified_gt_database import create_groundtruth_database
7+
8+
9+
def nuscenes_data_prep(root_path,
10+
info_prefix,
11+
version,
12+
dataset_name,
13+
out_dir,
14+
max_sweeps=10):
15+
"""Prepare data related to nuScenes dataset.
16+
17+
Related data consists of '.pkl' files recording basic infos,
18+
2D annotations and groundtruth database.
19+
20+
Args:
21+
root_path (str): Path of dataset root.
22+
info_prefix (str): The prefix of info filenames.
23+
version (str): Dataset version.
24+
dataset_name (str): The dataset class name.
25+
out_dir (str): Output directory of the groundtruth database info.
26+
max_sweeps (int): Number of input consecutive frames. Default: 10
27+
"""
28+
nuscenes_converter.create_nuscenes_infos(
29+
root_path, info_prefix, version=version, max_sweeps=max_sweeps)
30+
31+
if version == 'v1.0-test':
32+
info_test_path = osp.join(root_path, f'{info_prefix}_infos_test.pkl')
33+
nuscenes_converter.export_2d_annotation(
34+
root_path, info_test_path, version=version)
35+
return
36+
37+
info_train_path = osp.join(root_path, f'{info_prefix}_infos_train.pkl')
38+
info_val_path = osp.join(root_path, f'{info_prefix}_infos_val.pkl')
39+
nuscenes_converter.export_2d_annotation(
40+
root_path, info_train_path, version=version)
41+
nuscenes_converter.export_2d_annotation(
42+
root_path, info_val_path, version=version)
43+
create_groundtruth_database(dataset_name, root_path, info_prefix,
44+
f'{out_dir}/{info_prefix}_infos_train.pkl')
45+
46+
47+
parser = argparse.ArgumentParser(description='Data converter arg parser')
48+
parser.add_argument('dataset', metavar='nuscenes', help='name of the dataset')
49+
parser.add_argument(
50+
'--root-path',
51+
type=str,
52+
default='./data/nuscenes',
53+
help='specify the root path of dataset')
54+
parser.add_argument(
55+
'--version',
56+
type=str,
57+
default='v1.0',
58+
required=False,
59+
help='specify the dataset version, no need for nuscenes')
60+
parser.add_argument(
61+
'--max-sweeps',
62+
type=int,
63+
default=10,
64+
required=False,
65+
help='specify sweeps of lidar per example')
66+
parser.add_argument(
67+
'--out-dir',
68+
type=str,
69+
default='./data/nuscenes',
70+
required='False',
71+
help='name of info pkl')
72+
parser.add_argument('--extra-tag', type=str, default='nuscenes')
73+
parser.add_argument(
74+
'--workers', type=int, default=4, help='number of threads to be used')
75+
args = parser.parse_args()
76+
77+
if __name__ == '__main__':
78+
if args.dataset == 'nuscenes' and args.version != 'v1.0-mini':
79+
train_version = f'{args.version}-trainval'
80+
nuscenes_data_prep(
81+
root_path=args.root_path,
82+
info_prefix=args.extra_tag,
83+
version=train_version,
84+
dataset_name='NuScenesDataset',
85+
out_dir=args.out_dir,
86+
max_sweeps=args.max_sweeps)
87+
test_version = f'{args.version}-test'
88+
nuscenes_data_prep(
89+
root_path=args.root_path,
90+
info_prefix=args.extra_tag,
91+
version=test_version,
92+
dataset_name='NuScenesDataset',
93+
out_dir=args.out_dir,
94+
max_sweeps=args.max_sweeps)
95+
elif args.dataset == 'nuscenes' and args.version == 'v1.0-mini':
96+
train_version = f'{args.version}'
97+
nuscenes_data_prep(
98+
root_path=args.root_path,
99+
info_prefix=args.extra_tag,
100+
version=train_version,
101+
dataset_name='NuScenesDataset',
102+
out_dir=args.out_dir,
103+
max_sweeps=args.max_sweeps)

extra_tools/create_data.sh

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
3+
set -x
4+
export PYTHONPATH=`pwd`:$PYTHONPATH
5+
6+
PARTITION=$1
7+
JOB_NAME=$2
8+
CONFIG=$3
9+
WORK_DIR=$4
10+
GPUS=${GPUS:-1}
11+
GPUS_PER_NODE=${GPUS_PER_NODE:-1}
12+
SRUN_ARGS=${SRUN_ARGS:-""}
13+
JOB_NAME=create_data
14+
15+
srun -p ${PARTITION} \
16+
--job-name=${JOB_NAME} \
17+
--gres=gpu:${GPUS_PER_NODE} \
18+
--ntasks=${GPUS} \
19+
--ntasks-per-node=${GPUS_PER_NODE} \
20+
--kill-on-bad-exit=1 \
21+
${SRUN_ARGS} \
22+
python3 -u tools/create_data.py kitti \
23+
--root-path ./data/kitti \
24+
--out-dir ./data/kitti \
25+
--extra-tag kitti

0 commit comments

Comments
 (0)