Exploiting Spatial Sparsity for Event Cameras with Visual Transformers

Zuowen Wang, Yuhuang Hu, Shih-Chii Liu

Abstract

Event cameras generate highly sparse data, but standard Convolutional Neural Networks (CNNs) waste compute by processing the empty regions of these visual frames. This paper introduces a Visual Transformer (ViT) approach that filters out "inactive" patches, leveraging the ViT's ability to handle variable-length inputs. This technique cuts computational cost in half with almost no loss in accuracy.

Introduction: The Sparsity Challenge in Event Vision

Event cameras (like the DVS or DAVIS) operate differently from standard cameras: instead of capturing full frames at a fixed rate, they only report asynchronous, local changes in brightness. This means if a scene is mostly static, the output is highly spatially sparse. To process this data with Deep Neural Networks, researchers typically accumulate these events into dense 2D or 3D tensors. However, standard CNNs must process the entire input grid, effectively destroying the computational advantage of the sparse data by wasting math operations on empty pixels.

Active patch selection from sparse event data.

Methodology: DVS-ViT

The authors propose a pipeline called DVS-ViT that actively filters the input data before it hits the heavy transformer layers. Unlike CNNs, which require a rigid, dense grid, ViTs treat an image as a sequence of patches (tokens), making them uniquely suited for sparse data. This allows the model to simply "drop" empty regions of an event frame without breaking the architecture.

1. Active Patch Selection

The raw, asynchronous event stream is accumulated into a 3D voxel grid and divided into non-overlapping 16x16 patches. The system calculates an "Active Ratio" (AR) for each patch—the number of non-zero pixels divided by the total pixels. If a patch's AR falls below a predefined threshold, it is deemed "inactive" and discarded.

2. Transformer Processing and Architecture

Only the "active" patches are flattened, linearly projected, and fed into the ViT. Crucially, the model retains a full-sized positional embedding matrix so the transformer still knows exactly where each active patch originated.

The DVS-ViT architecture (a), transformer encoder layer (b), and active patch statistics (c).

While the quadratic cost of the ViT's Self-Attention (SA) mechanism is significant, the authors' bottleneck analysis reveals that for standard vision tasks, the Multi-Layer Perceptron (MLP) layers consume more FLOPs. Dropping inactive patches yields a massive, linear reduction in MLP compute, alongside the quadratic savings in SA.

3. Mixed Training Strategy

To make the model robust to varying levels of sparsity, the authors introduce a training regime where the AR threshold is randomly sampled (between 0.0 and 0.7) for every iteration. This acts as a powerful regularizer, forcing the network to recognize objects with varying amounts of missing patches.

Key Results

Evaluated on the N-Caltech101 dataset, DVS-ViT achieves competitive performance with significantly reduced overhead:

  • Massive Compute Reduction: Setting the active patch threshold to 0.35 reduces the number of processed patches by over 50%. This translates to a 51.4% reduction in MACs and a 46% speedup in inference time on a server CPU.
  • Maintained Accuracy: Using the mixed training strategy, the DVS-ViT achieves 82.66% accuracy, virtually identical to the baseline ViT that processes all patches (83.00%), but using half the compute (7.47G MACs vs 15.37G MACs).
  • Competitive with CNNs: The sparse ViT approach matches or outperforms established CNN baselines, such as ResNet34 (82.5% at 3.41G MACs) and VGG-19 (76.6% at 18.05G MACs).

Limitations and Future Work

Because the number of active patches varies wildly from frame to frame, batching becomes difficult; the authors used a batch size of 1 during training. Furthermore, ViTs lack the inductive biases of CNNs and require large amounts of data or pre-training to generalize well. Future work includes applying this sparse ViT architecture to more complex tasks like optical flow or object detection and deploying it onto compute-constrained edge hardware.

Summary updated

Abstract

Event cameras report local changes of brightness through an asynchronous stream of output events. Events are spatially sparse at pixel locations with little brightness variation. We propose using a visual transformer (ViT) architecture to leverage its ability to process a variable-length input. The input to the ViT consists of events that are accumulated into time bins and spatially separated into non-overlapping sub-regions called patches. Patches are selected when the number of nonzero pixel locations within a sub-region is above a threshold. We show that by fine-tuning a ViT model on these selected active patches, we can reduce the average number of patches fed into the backbone during the inference by at least 50% with only a minor drop (0.34%) of the classification accuracy on the N-Caltech101 dataset. This reduction translates into a decrease of 51% in Multiply-Accumulate (MAC) operations and an increase of 46% in the inference speed using a server CPU.
BibTeX
@inproceedings{wang2022exploiting,
  author = {Zuowen Wang and Yuhuang Hu and Shih-Chii Liu},
  title = {{Exploiting Spatial Sparsity for Event Cameras with Visual Transformers}},
  booktitle = {ICIP},
  year = {2022},
  url = {https://openreview.net/forum?id=tYa5suErxu},
}
Figure