Skip to content

Commit 8989436

Browse files
committed
Initial commit
1 parent 775605b commit 8989436

Some content is hidden

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

50 files changed

+4901
-2
lines changed

LICENSE

+674
Large diffs are not rendered by default.

README.md

+134-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,134 @@
1-
# DR-SPAAM-Detector
2-
DR-SPAAM detector. Code to be released.
1+
This repository contains the implementation of *DR-SPAAM: A Spatial-Attention and Auto-regressive Model for Person Detection in 2D Range Data* ([arXiv](https://arxiv.org/abs/2004.14079)).
2+
3+
# DR-SPAAM Detector
4+
DR-SPAAM is a deep learning based person detector that detects persons in 2D range sequences obtained from a laser scanner.
5+
6+
![](imgs/dets.gif)
7+
8+
Although DR-SPAAM is a detector, it can generate simple tracklets, based on its spatial similarity module.
9+
10+
![](imgs/tracks.gif)
11+
12+
To interface with many robotic applications, an example ROS node is also included.
13+
The ROS node, `dr_spaam_ros` subscribes to the laser scan (`sensor_msgs/LaserScan`)
14+
and publishes detections as `geometry_msgs/PoseArray`.
15+
To use a different message defination, simply modify `_detections_to_ros_msg`
16+
method in `src/dr_spaam_ros/dr_spaam_ros.py`.
17+
18+
![](imgs/dr_spaam_ros.gif)
19+
20+
## Quick Start
21+
We provide our complete training and eveluation code.
22+
If you would like to re-run experiments and make changes to our code, you can start out with the following scripts.
23+
24+
First clone and install the repository.
25+
```
26+
git clone https://github.com/VisualComputingInstitute/DR-SPAAM-Detector.git
27+
cd dr_spaam
28+
python setup.py install
29+
```
30+
31+
Download and put the [DROW dataset](https://github.com/VisualComputingInstitute/DROW) under `dr_spaam/data`.
32+
33+
Download the checkpoints from the release section and put them under `dr_spaam/ckpts`.
34+
35+
To measure the network inference time, run:
36+
```
37+
python bin/demo.py --time
38+
```
39+
40+
To visualize detections on an example sequence, run:
41+
```
42+
python bin/demo.py --dets
43+
```
44+
45+
To visualize detections with tracklets, run:
46+
```
47+
python bin/demo.py --tracks
48+
```
49+
50+
To train your own network, run:
51+
```
52+
python bin/train.py --cfg cfgs/dr_spaam.yaml
53+
```
54+
55+
To evaluat a checkpoint, run:
56+
```
57+
python bin/eval.py --cfg cfgs/dr_spaam.yaml --ckpt ckpts/dr_spaam_e40.pth
58+
```
59+
(add `--val` to evaluate on the validation set)
60+
61+
Integrating DR-SPAAM into other python projects is easy.
62+
Here's a minimum example.
63+
```python
64+
import numpy as np
65+
from dr_spaam.detector import Detector
66+
67+
# Detector class wraps up preprocessing, inference, and postprocessing for
68+
# DR-SPAAM. Set `original_drow=True` to use the original DROW model instead.
69+
# Use `stride` to skip scan points if faster inference speed is needed.
70+
ckpt = 'path_to_checkpoint'
71+
detector = Detector(ckpt, original_drow=False, gpu=True, stride=1)
72+
73+
# set angular grid (this is only required once)
74+
ang_inc = np.radians(0.5) # angular increment of the scanner
75+
num_pts = 450 # number of points in a scan
76+
detector.set_laser_spec(ang_inc, num_pts)
77+
78+
# inference
79+
while True:
80+
scan = np.random.rand(num_pts) # scan is a 1D numpy array with positive values
81+
dets_xy, dets_cls, instance_mask = detector(scan) # get detection
82+
83+
# confidence threshold
84+
cls_thresh = 0.4
85+
cls_mask = dets_cls > cls_thresh
86+
dets_xy = dets_xy[cls_mask]
87+
dets_cls = dets_cls[cls_mask]
88+
```
89+
90+
## ROS node
91+
We provide an example ROS node `dr_spaam_ros`.
92+
First install `dr_spaam` to your python environment.
93+
Then compile the ROS package
94+
```
95+
catkin build dr_spaam_ros
96+
```
97+
98+
Modify the topics and the path to the pre-trained checkpoint at
99+
`dr_spaam_ros/config/` and launch the node using
100+
```
101+
roslaunch dr_spaam_ros dr_spaam_ros.launch
102+
```
103+
104+
Use the following code to convert a sequence from a DROW dataset into a rosbag
105+
```
106+
python scripts/drow_data_converter.py --seq <PATH_TO_SEQUENCE> --output drow.bag
107+
```
108+
109+
Use RViz to visualize the inference result.
110+
A simple RViz config is located at `dr_spaam_ros/example.rviz`.
111+
112+
## Inference time
113+
| | AP<sub>0.3</sub> | AP<sub>0.5</sub> | FPS (RTX 2080 laptop) | FPS (Jetson AGX) |
114+
|--------|------------------|------------------|-----------------------|------------------|
115+
|DROW | 0.638 | 0.659 | 95.8 | 24.8 |
116+
|DR-SPAAM| 0.707 | 0.723 | 87.3 | 22.6 |
117+
118+
Note: In the original paper, we used a voting scheme for postprocessing.
119+
In the implementation here, we have replaced the voting with a non-maximum suppression,
120+
where two detections that are less than 0.5 m apart are considered as duplicates
121+
and the less confident one is suppressed.
122+
Thus there is a mismatch between the numbers here and those shown in the paper.
123+
124+
## Citation
125+
If you use DR-SPAAM in your project, please cite:
126+
```BibTeX
127+
@article{Jia2020DRSPAAM,
128+
title = {{DR-SPAAM: A Spatial-Attention and Auto-regressive
129+
Model for Person Detection in 2D Range Data}},
130+
author = {Dan Jia and Alexander Hermans and Bastian Leibe},
131+
journal = {arXiv:2004.14079},
132+
year = {2020}
133+
}
134+
```

dr_spaam/.gitignore

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
*~
2+
*__pycache__*
3+
*_ext*
4+
*.bag
5+
*.csv
6+
*.cu.o
7+
*.DS_Store
8+
*.ipynb_checkpoints
9+
*.pkl
10+
*.png
11+
*.pth
12+
*.pyc
13+
*.tfevents*
14+
*.yml
15+
16+
.idea/
17+
.vscode/
18+
*.egg-info/
19+
build/
20+
ckpt/
21+
ckpts/
22+
data/
23+
dist/
24+
output/
25+
results/
26+
result_*/

0 commit comments

Comments
 (0)