Skip to content

Commit feabe65

Browse files
committed
feat: Update CC-3DT++.
1 parent 1688775 commit feabe65

File tree

9 files changed

+450
-39
lines changed

9 files changed

+450
-39
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<!-- pypi-strip -->
33
<picture>
44
<!-- /pypi-strip -->
5-
<img alt="vis4d" src="https://dl.cv.ethz.ch/vis4d/vis4d_logo.svg" width="400">
5+
<img alt="vis4d" src="docs/source/_static/vis4d_logo.svg" width="400">
66
<!-- pypi-strip -->
77
</picture>
88
<!-- /pypi-strip -->

scripts/eval_nusc/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# nuScenes 3D Detection and Tracking Evaluation
2+
3+
This folder contains the code and python environment to run nuScenes 3D detection and tracking evaluation locally.
4+
5+
### Installation
6+
- Python: 3.6
7+
8+
```bash
9+
pip install -r nusc.txt
10+
```
11+
12+
### Run
13+
- $WORK_DIR is your output folder which contains the prediction json file.
14+
- $VERSION is `mini` or `trainval` to select mini or validation split.
15+
16+
```bash
17+
bash eval_nusc.sh $WORK_DIR $VERSION
18+
```

scripts/eval_nusc/eval_nusc.py

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
"""nuScenes evaluation pipeline for Vis4D."""
2+
import argparse
3+
import os
4+
import json
5+
6+
from nuscenes import NuScenes
7+
from nuscenes.eval.detection.evaluate import NuScenesEval
8+
from nuscenes.eval.detection.config import config_factory
9+
10+
from nuscenes.eval.tracking.evaluate import TrackingEval as track_eval
11+
from nuscenes.eval.tracking.utils import print_final_metrics
12+
from nuscenes.eval.tracking.data_classes import TrackingConfig, TrackingMetrics
13+
from nuscenes.eval.common.config import config_factory as track_configs
14+
15+
16+
def parse_arguments() -> argparse.Namespace:
17+
"""Parse arguments."""
18+
parser = argparse.ArgumentParser(description="Vis4D for nuScenes eval.")
19+
parser.add_argument(
20+
"--input",
21+
"-i",
22+
help=("Path to save nuScenes format dection / tracking results."),
23+
)
24+
parser.add_argument(
25+
"--version",
26+
"-v",
27+
choices=["v1.0-trainval", "v1.0-test", "v1.0-mini"],
28+
help="NuScenes dataset version to convert.",
29+
)
30+
parser.add_argument(
31+
"--dataroot",
32+
"-d",
33+
help="NuScenes dataset root.",
34+
)
35+
parser.add_argument(
36+
"-m",
37+
"--mode",
38+
default="tracking",
39+
choices=["tracking", "detection"],
40+
help="Conversion mode: detection or tracking.",
41+
)
42+
return parser.parse_args()
43+
44+
45+
def eval_detection(
46+
version: str,
47+
dataroot: str,
48+
output_dir: str,
49+
result_path: str,
50+
eval_set: str,
51+
) -> None:
52+
"""Evaluate detection results."""
53+
nusc = NuScenes(version=version, dataroot=dataroot, verbose=True)
54+
55+
nusc_eval = NuScenesEval(
56+
nusc,
57+
config=config_factory("detection_cvpr_2019"),
58+
result_path=result_path,
59+
eval_set=eval_set,
60+
output_dir=output_dir,
61+
verbose=True,
62+
)
63+
_ = nusc_eval.main(render_curves=False)
64+
65+
66+
def eval_tracking(
67+
version: str, output_dir: str, result_path: str, root: str, eval_set: str
68+
) -> None:
69+
"""Evaluate tracking results."""
70+
nusc_eval = track_eval(
71+
config=track_configs("tracking_nips_2019"),
72+
result_path=result_path,
73+
eval_set=eval_set,
74+
output_dir=output_dir,
75+
verbose=True,
76+
nusc_version=version,
77+
nusc_dataroot=root,
78+
)
79+
_ = nusc_eval.main()
80+
81+
82+
def evaluate(
83+
version: str,
84+
dataroot: str,
85+
mode: str,
86+
output_dir: str,
87+
result_path: str,
88+
root: str,
89+
) -> None:
90+
"""nuScenes evaluation."""
91+
if "mini" in version:
92+
eval_set = "mini_val"
93+
else:
94+
eval_set = "val"
95+
96+
if mode == "tracking":
97+
eval_tracking(version, output_dir, result_path, root, eval_set)
98+
else:
99+
eval_detection(version, dataroot, output_dir, result_path, eval_set)
100+
101+
102+
def print_metric_summary(metric_summary_path: str) -> None:
103+
"""Print metric summary."""
104+
with open(metric_summary_path, "r") as f:
105+
metrics = json.load(f)
106+
107+
cfg = TrackingConfig.deserialize(metrics["cfg"])
108+
tm = TrackingMetrics(cfg=cfg)
109+
tm.add_runtime(metrics["eval_time"])
110+
tm.label_metrics = metrics["label_metrics"]
111+
112+
print_final_metrics(metrics)
113+
114+
115+
if __name__ == "__main__":
116+
"""Main."""
117+
args = parse_arguments()
118+
119+
if args.mode == "detection":
120+
metric = "detect_3d"
121+
else:
122+
metric = "track_3d"
123+
124+
evaluate(
125+
args.version,
126+
args.dataroot,
127+
args.mode,
128+
args.input,
129+
os.path.join(args.input, f"{metric}_predictions.json"),
130+
args.dataroot,
131+
)

scripts/eval_nusc/eval_nusc.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
work_dir=$1
3+
version=$2
4+
5+
# 3D Detection Evaluation
6+
python eval_nusc.py \
7+
--input $work_dir/detect_3d \
8+
--version v1.0-${version} \
9+
--dataroot data/nuscenes \
10+
--mode detection
11+
12+
# 3D Tracking Evaluation
13+
python eval_nusc.py \
14+
--input $work_dir/track_3d \
15+
--version v1.0-${version} \
16+
--dataroot=data/nuscenes \
17+
--mode tracking

scripts/eval_nusc/nusc.txt

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
argon2-cffi==21.3.0
2+
argon2-cffi-bindings==21.2.0
3+
async-generator==1.10
4+
attrs==22.2.0
5+
backcall==0.2.0
6+
bleach==4.1.0
7+
cachetools==4.2.4
8+
certifi==2021.5.30
9+
cffi==1.15.1
10+
comm==0.1.4
11+
cycler==0.11.0
12+
dataclasses==0.8
13+
decorator==5.1.1
14+
defusedxml==0.7.1
15+
descartes==1.1.0
16+
entrypoints==0.4
17+
fire==0.5.0
18+
importlib-metadata==4.8.3
19+
importlib-resources==5.4.0
20+
ipykernel==5.5.6
21+
ipython==7.16.3
22+
ipython-genutils==0.2.0
23+
ipywidgets==7.8.1
24+
jedi==0.17.2
25+
Jinja2==3.0.3
26+
joblib==1.1.1
27+
jsonschema==3.2.0
28+
jupyter==1.0.0
29+
jupyter-client==7.1.2
30+
jupyter-console==6.4.3
31+
jupyter-core==4.9.2
32+
jupyterlab-pygments==0.1.2
33+
jupyterlab-widgets==1.1.7
34+
kiwisolver==1.3.1
35+
MarkupSafe==2.0.1
36+
matplotlib==3.3.4
37+
mistune==0.8.4
38+
motmetrics==1.1.3
39+
nbclient==0.5.9
40+
nbconvert==6.0.7
41+
nbformat==5.1.3
42+
nest-asyncio==1.5.8
43+
notebook==6.4.10
44+
numpy==1.19.5
45+
nuscenes-devkit==1.1.10
46+
opencv-python==4.5.4.58
47+
packaging==21.3
48+
pandas==1.1.5
49+
pandocfilters==1.5.0
50+
parso==0.7.1
51+
pexpect==4.9.0
52+
pickleshare==0.7.5
53+
Pillow==8.4.0
54+
prometheus-client==0.17.1
55+
prompt-toolkit==3.0.36
56+
ptyprocess==0.7.0
57+
pycocotools==2.0.7
58+
pycparser==2.21
59+
Pygments==2.14.0
60+
pyparsing==3.1.1
61+
pyquaternion==0.9.9
62+
pyrsistent==0.18.0
63+
python-dateutil==2.8.2
64+
pytz==2023.3.post1
65+
pyzmq==25.1.2
66+
qtconsole==5.2.2
67+
QtPy==2.0.1
68+
scikit-learn==0.24.2
69+
scipy==1.5.4
70+
Send2Trash==1.8.2
71+
Shapely==1.8.5
72+
six==1.16.0
73+
termcolor==1.1.0
74+
terminado==0.12.1
75+
testpath==0.6.0
76+
threadpoolctl==3.1.0
77+
tornado==6.1
78+
tqdm==4.64.1
79+
traitlets==4.3.3
80+
typing_extensions==4.1.1
81+
wcwidth==0.2.13
82+
webencodings==0.5.1
83+
widgetsnbextension==3.6.6
84+
zipp==3.6.0

vis4d/engine/flag.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,13 @@
44

55
from .parser import DEFINE_config_file
66

7-
# TODO: Currently this does not allow to load multpile config files.
8-
# Would be nice to extend functionality to chain multiple config files using
9-
# e.g. --config=model_1.py --config=loader_args.py
10-
# or --config=my_config.py --config.train_dl=different_dl.py
11-
12-
# TODO: Support resume from folder and load config directly from it.
137
_CONFIG = DEFINE_config_file("config", method_name="get_config")
148
_GPUS = flags.DEFINE_integer("gpus", default=0, help="Number of GPUs")
159
_CKPT = flags.DEFINE_string("ckpt", default=None, help="Checkpoint path")
1610
_RESUME = flags.DEFINE_bool("resume", default=False, help="Resume training")
1711
_SHOW_CONFIG = flags.DEFINE_bool(
1812
"print-config", default=False, help="If set, prints the configuration."
1913
)
20-
_SWEEP = DEFINE_config_file("sweep", method_name="get_sweep")
21-
_SLURM = flags.DEFINE_bool(
22-
"slurm", default=False, help="If set, setup slurm running jobs."
23-
)
2414
_VIS = flags.DEFINE_bool(
2515
"vis",
2616
default=False,
@@ -34,7 +24,5 @@
3424
"_CKPT",
3525
"_RESUME",
3626
"_SHOW_CONFIG",
37-
"_SWEEP",
38-
"_SLURM",
3927
"_VIS",
4028
]

vis4d/engine/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def main(argv: ArgsType) -> None:
104104

105105
if not vis and isinstance(callback, VisualizerCallback):
106106
rank_zero_info(
107-
f"{callback.visualizer} is not used."
107+
f"{callback.visualizer} is not used. "
108108
"Please set --vis=True to use it."
109109
)
110110
continue

0 commit comments

Comments
 (0)