MCPcopy Index your code
hub / github.com/VisualComputingInstitute/DR-SPAAM-Detector

github.com/VisualComputingInstitute/DR-SPAAM-Detector @v1.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.1 ↗ · + Follow
123 symbols 368 edges 26 files 11 documented · 9%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

This repository contains the implementation of DR-SPAAM: A Spatial-Attention and Auto-regressive Model for Person Detection in 2D Range Data to appear in IROS'20 (arXiv).

DR-SPAAM Detector

DR-SPAAM is a deep learning based person detector that detects persons in 2D range sequences obtained from a laser scanner.

Although DR-SPAAM is a detector, it can generate simple tracklets, based on its spatial similarity module.

To interface with many robotic applications, an example ROS node is included. The ROS node, dr_spaam_ros subscribes to the laser scan (sensor_msgs/LaserScan) and publishes detections as geometry_msgs/PoseArray and visualization markers for RViz.

Quick Start

We provide our complete training and eveluation code. If you would like to re-run experiments and make changes to our code, you can start out with the following scripts.

First clone and install the repository.

git clone https://github.com/VisualComputingInstitute/DR-SPAAM-Detector.git
cd dr_spaam
python setup.py install

Download and put the DROW dataset under dr_spaam/data. Download the checkpoints from the release section and put them under dr_spaam/ckpts. The directory should have the following layout.

dr_spaam
├── data
│   ├── DROWv2-data
│   │   ├── test
│   │   ├── train
│   │   ├── val
├── ckpts
│   ├── drow_e40.pth
│   ├── drow5_e40.pth
│   ├── dr_spaam_e40.pth
...

Run bin/demo.py to measure the inference time (--time), to visualize detections on an example sequence (--dets), or to visualize tracklets (--tracks).

python bin/demo.py [--time/--dets/--tracks]

To train a network, run:

python bin/train.py --cfg cfgs/dr_spaam.yaml

To evaluat a checkpoint on the test set (on the validation set with --val), run:

python bin/eval.py --cfg cfgs/dr_spaam.yaml --ckpt ckpts/dr_spaam_e40.pth [--val]

Integrating DR-SPAAM into other python projects is easy. Here's a minimum example.

import numpy as np
from dr_spaam.detector import Detector

# Detector class wraps up preprocessing, inference, and postprocessing for DR-SPAAM.
# Checkout the comment in the code for meanings of the parameters.
ckpt = 'path_to_checkpoint'
detector = Detector(
    model_name="DR-SPAAM", 
    ckpt_file=ckpt, 
    gpu=True, 
    stride=1, 
    tracking=False
)

# set angular grid (this is only required once)
ang_inc = np.radians(0.5)  # angular increment of the scanner
num_pts = 450  # number of points in a scan
detector.set_laser_spec(ang_inc, num_pts)

# inference
while True:
    scan = np.random.rand(num_pts)  # scan is a 1D numpy array with positive values
    dets_xy, dets_cls, instance_mask = detector(scan)  # get detection

    # confidence threshold
    cls_thresh = 0.2
    cls_mask = dets_cls > cls_thresh
    dets_xy = dets_xy[cls_mask]
    dets_cls = dets_cls[cls_mask]

ROS node

We provide an example ROS node dr_spaam_ros. First install dr_spaam to your python environment. Then compile the ROS package

catkin build dr_spaam_ros

Modify the topics and the path to the pre-trained checkpoint at dr_spaam_ros/config/ and launch the node using

roslaunch dr_spaam_ros dr_spaam_ros.launch

Use the following code to convert a sequence from a DROW dataset into a rosbag

python scripts/drow_data_converter.py --seq <PATH_TO_SEQUENCE> --output drow.bag

Use RViz to visualize the inference result. A simple RViz config is located at dr_spaam_ros/example.rviz.

Inference time

AP0.3 AP0.5 FPS (RTX 2080 laptop) FPS (Jetson AGX)
DROW 0.638 0.659 95.8 24.8
DR-SPAAM 0.707 0.723 87.3 22.6

Note: In the original paper, we used a voting scheme for postprocessing. In the implementation here, we have replaced the voting with a non-maximum suppression, where two detections that are less than 0.5 m apart are considered as duplicates and the less confident one is suppressed. Thus there is a mismatch between the numbers here and those listed in the paper.

Citation

If you use DR-SPAAM in your project, please cite:

@inproceedings{Jia2020DRSPAAM,
  title        = {{DR-SPAAM: A Spatial-Attention and Auto-regressive
                   Model for Person Detection in 2D Range Data}},
  author       = {Dan Jia and Alexander Hermans and Bastian Leibe},
  booktitle    = {International Conference on Intelligent Robots and Systems (IROS)},
  year         = {2020}
}

Core symbols most depended-on inside this repo

_conv3x3
called by 11
dr_spaam/src/dr_spaam/model/drow.py
rphi_to_xy
called by 6
dr_spaam/src/dr_spaam/utils/utils.py
peakf1
called by 6
dr_spaam/src/dr_spaam/utils/prec_rec_utils.py
eer
called by 6
dr_spaam/src/dr_spaam/utils/prec_rec_utils.py
_forward_cutout
called by 6
dr_spaam/src/dr_spaam/model/drow.py
_forward_fused_cutout
called by 5
dr_spaam/src/dr_spaam/model/drow.py
set_laser_spec
called by 4
dr_spaam/src/dr_spaam/detector.py
load_checkpoint
called by 4
dr_spaam/src/dr_spaam/utils/train_utils.py

Shape

Function 63
Method 47
Class 13

Languages

Python98%
C++2%

Modules by API surface

dr_spaam/src/dr_spaam/model/drow.py24 symbols
dr_spaam/src/dr_spaam/utils/utils.py18 symbols
dr_spaam/src/dr_spaam/utils/train_utils.py12 symbols
dr_spaam/src/dr_spaam/detector.py11 symbols
dr_spaam/src/dr_spaam/utils/dataset.py10 symbols
dr_spaam_ros/src/dr_spaam_ros/dr_spaam_ros.py9 symbols
dr_spaam/src/dr_spaam/utils/prec_rec_utils.py9 symbols
dr_spaam/src/dr_spaam/utils/eval_utils.py8 symbols
dr_spaam/src/dr_spaam/model/loss_utils.py7 symbols
dr_spaam/bin/demo.py4 symbols
dr_spaam_ros/scripts/drow_data_converter.py3 symbols
dr_spaam/src/dr_spaam/utils/pytorch_nms/src/nms.cpp2 symbols

For agents

$ claude mcp add DR-SPAAM-Detector \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact