CEMFormer: Learning to Predict Driver Intentions from in-Cabin and External Cameras via Spatial-Temporal Transformers

Yunsheng Ma, Wenqian Ye, Xu Cao, Amr Abdelraouf, Kyungtae Han, Rohit Gupta, Ziran Wang

Introduction

Predicting a driver’s intention before a maneuver is executed is a critical component of Advanced Driver-Assistance Systems (ADAS). If a vehicle can anticipate a lane change or a turn seconds before it happens, it can provide earlier warnings or adjust autonomous safety protocols. However, this task remains challenging due to three primary limitations in current research: the reliance on "late fusion" (processing driver and road views separately), the difficulty of maintaining temporal context in real-time (causal constraints), and the lack of environmental "common sense" in model predictions.

CEMFormer (Cross-View Episodic Memory Transformer) addresses these challenges by utilizing a unified transformer architecture that processes in-cabin and external camera feeds simultaneously, supported by a novel memory mechanism and a context-aware loss function.

Methodology

Spatial-Temporal Encoder

Unlike traditional models that use separate branches for different camera views and merge them at the final layer, CEMFormer employs a unified Spatial-Temporal Encoder. The model divides images from both the in-cabin (driver-facing) and external (road-facing) cameras into patches. These patches are fed into a single transformer, allowing the model to learn early-stage cross-view correlations—such as the relationship between a driver’s head orientation and the appearance of a gap in adjacent traffic.

Episodic Memory Module

To maintain temporal awareness without the computational overhead of processing long video sequences, CEMFormer introduces an Episodic Memory Module. This module utilizes $K$ "memory tokens" that encapsulate historical context. These tokens are updated at each time step and passed forward, allowing the model to retain a compressed history of the preceding frames. This ensures the model remains causal and efficient enough for real-time deployment.

Context-Consistency (CC) Loss

A significant innovation in CEMFormer is the Context-Consistency (CC) Loss. Standard models often make predictions that are physically or logically impossible—for instance, predicting a right-lane change when the vehicle is already in the rightmost lane. The researchers defined a set of "contradicting scenarios" based on lane position and intersection proximity. The CC loss penalizes the model when its predictions violate these logical constraints, effectively acting as a regularizer that forces the model to respect the rules of the road.

Experimental Setup

The framework was evaluated using the Brain4Cars dataset, a standard benchmark for driver intention. The dataset consists of 594 video clips featuring dual views (inside and outside) and five distinct maneuvers: Go Straight, Left Lane Change, Right Lane Change, Left Turn, and Right Turn. The dataset includes precise annotations for maneuver start times, enabling the evaluation of the model’s ability to anticipate actions before they are fully realized.

Results and Discussion

Performance and Efficiency

CEMFormer achieved state-of-the-art results on the Brain4Cars benchmark, reaching an 87.09% F1 score and 85.37% accuracy. This outperforms previous end-to-end methods, including those based on 3D ResNet or ConvLSTM architectures. Notably, CEMFormer is highly efficient, utilizing approximately 60% fewer parameters than comparable state-of-the-art models. On a single NVIDIA RTX 3090 Ti, the model operates at 15.56 FPS, meeting the requirements for real-time ADAS applications.

Ablation Studies

The contribution of each module was quantified through ablation testing:

  • Episodic Memory: Provided a 4.42% improvement in F1 score, confirming the importance of historical context.
  • Context-Consistency Loss: Added a 5.44% boost to the F1 score, demonstrating that environmental logic significantly improves predictive accuracy.

Qualitative Insights

Analysis of the model’s attention mechanisms revealed that CEMFormer naturally learns to shift its focus over time. It typically begins by analyzing the driver’s face and gaze (to detect mirror checks) and shifts toward the steering wheel and external lane markings as the maneuver begins.

Limitations and Future Work

While CEMFormer represents a significant step forward, some limitations remain. The episodic memory is currently optimized for a 5-second window, which may be insufficient for highly complex or prolonged driving scenarios. Additionally, the researchers noted that the external camera feed can sometimes introduce noise that the model struggles to filter. Future research will explore the integration of HD Maps and V2X (Vehicle-to-Everything) communications to provide a richer, more robust environmental context than a single forward-facing camera can provide.

Summary updated

BibTeX
@inproceedings{ma2023cemformer,
  author = {Yunsheng Ma and Wenqian Ye and Xu Cao and Amr Abdelraouf and Kyungtae Han and Rohit Gupta and Ziran Wang},
  title = {{CEMFormer: Learning to Predict Driver Intentions from in-Cabin and External Cameras via Spatial-Temporal Transformers}},
  booktitle = {ITSC},
  year = {2023},
}
Figure