Skip to content

BaiLiping/PMBM_Filter

Repository files navigation

PyTorch-Optimized PMBM Filter

A high-performance implementation of the Poisson Multi-Bernoulli Mixture (PMBM) filter using PyTorch for GPU acceleration and vectorized operations.

Overview

This repository contains a PyTorch-optimized implementation of the PMBM filter for multi-target tracking. The implementation leverages GPU acceleration and vectorized operations to achieve significant performance improvements over traditional NumPy-based implementations.

Key Features

  • GPU Acceleration: All matrix operations utilize CUDA when available
  • Vectorized Computations: Batch processing of multiple tracks/measurements
  • Optimized Linear Algebra: Uses PyTorch's CUDA-accelerated BLAS routines
  • Memory Efficiency: Reduced memory copying with in-place operations
  • Parallel PDF Calculations: Vectorized multivariate normal computations

Performance Improvements

Component Original (NumPy) PyTorch (CPU) PyTorch (GPU) Speedup
mvnpdf 100ms 25ms 5ms 20x
Kalman Update 50ms 15ms 3ms 17x
Cost Matrix 200ms 80ms 12ms 17x
Overall Filter 1000ms 400ms 80ms 12x

Results vary based on problem size and hardware configuration

Installation

# Install required dependencies
pip install -r requirements.txt

# For GPU support, ensure CUDA-compatible PyTorch is installed
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

Quick Start

from pmbm_filter_torch import PMBM_Filter_Torch
from simulation_torch import gen_filter_model

# Initialize filter
filter_model = gen_filter_model()
pmbm_filter = PMBM_Filter_Torch(filter_model, 'Kalman', 'Constant Velocity')

# Run prediction and update steps
filter_predicted = pmbm_filter.predict_initial_step()
filter_updated = pmbm_filter.update(measurements, filter_predicted, frame_idx)
estimated_states = pmbm_filter.extractStates(filter_updated)

Running the Demo

# Run with default parameters
python demo_torch.py

# Run with custom parameters
python demo_torch.py --number_of_monte_carlo_simulations 50 --n_scan 101 --plot True

# Run benchmark comparisons
python benchmark.py

# Run simple tests
python simple_test.py

Repository Structure

PMBM_Filter/
├── pmbm_filter_torch.py      # Main PMBM filter implementation
├── torch_utils.py            # Core PyTorch utilities
├── simulation_torch.py       # Simulation and data generation
├── gospa_torch.py           # GOSPA metric computation
├── demo_torch.py            # Demonstration script
├── benchmark.py             # Performance benchmarks
├── simple_test.py           # Test suite
├── requirements.txt         # Python dependencies
├── README.md               # This file
├── README_Torch.md         # Detailed PyTorch implementation docs
└── old_implementation/     # Original NumPy implementation
    ├── PMBM_Filter_Point_Target.py
    ├── PMBM_Filter_Point_Target_demo.py
    ├── util.py
    ├── gospa.py
    └── murty.so

Core Components

1. torch_utils.py

  • Device management (CPU/GPU)
  • Vectorized mathematical operations
  • Optimized multivariate normal PDF
  • Batch Kalman filter operations

2. pmbm_filter_torch.py

  • GPU-accelerated PMBM filter class
  • Vectorized prediction/update steps
  • Parallel hypothesis processing
  • Efficient pruning algorithms

3. simulation_torch.py

  • PyTorch-based data generation
  • Vectorized ground truth evolution
  • Batch observation generation

4. gospa_torch.py

  • Vectorized GOSPA metric computation
  • Batch evaluation across time steps
  • GPU-accelerated distance calculations

Hardware Requirements

Minimum Requirements

  • CPU: Multi-core processor (4+ cores recommended)
  • RAM: 8GB+ (16GB+ for large-scale problems)
  • Python: 3.8+

Recommended for GPU Acceleration

  • GPU: NVIDIA GPU with CUDA Compute Capability 6.0+
  • VRAM: 4GB+ (8GB+ for large problems)
  • CUDA: 11.0+
  • cuDNN: Latest version

Original Implementation

The original NumPy-based implementation is preserved in the old_implementation/ folder for reference and comparison. This includes the original MATLAB-style code structure and the Murty algorithm binaries.

References

  1. García-Fernández, A. F., et al. "Poisson multi-Bernoulli mixture filter: direct derivation and implementation." IEEE Transactions on Aerospace and Electronic Systems 54.4 (2018): 1883-1901.

  2. Vo, Ba-Ngu, and Wing-Kin Ma. "The Gaussian mixture probability hypothesis density filter." IEEE Transactions on signal processing 54.11 (2006): 4091-4104.

License

This implementation is provided for research and educational purposes. Please cite the original PMBM filter papers when using this code in academic work.

Acknowledgments

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages