AWS Builder Center
What I Learned Building an Explainable AI Pipeline for Autonomous Vehicles

What I Learned Building an Explainable AI Pipeline for Autonomous Vehicles

Combining YOLO object detection with Grad-CAM, SHAP, and LiDAR to make autonomous vehicle decisions explainable in real time — and what broke along the way.

AI Engineer
Object detection models are everywhere in autonomous driving — a YOLO model spots a pedestrian, draws a box, moves on. But it never tells you why it made that call. For a self-driving system, that's a real problem. If a model is wrong, or right for the wrong reasons, a bounding box alone won't tell you which.
That's the gap I tried to close in a recent capstone project: an explainable AI pipeline for autonomous vehicles, combining object detection with visual and quantitative explanations in real time.
The stack:
  • CARLA simulator for the driving environment
  • YOLOv5 (tested across Nano/Small/Medium variants) for object detection
  • Grad-CAM for visual "why" heatmaps — showing which pixels actually drove a detection
  • SHAP for decision attribution — a more quantitative breakdown of feature contribution
  • LiDAR for 360° spatial reasoning layered alongside the camera-based detections
  • A real-time multi-panel dashboard tying all of it together
A few things I learned:
Getting Grad-CAM to work cleanly on YOLO's architecture wasn't plug-and-play — YOLO's detection heads aren't structured like a standard classifier, so the usual Grad-CAM hooks needed adapting to actually target the right layers for meaningful heatmaps.
There's also a real tradeoff between model size and real-time performance. The larger YOLO variants gave better detections, but running Grad-CAM and SHAP on top of that in real time meant every extra parameter cost us frame rate. Nano was often the more practical choice once explainability was in the loop, not just detection accuracy.
Combining LiDAR spatial data with 2D visual explanations was the trickiest integration — the two live in different coordinate systems, and getting them to genuinely complement each other on one dashboard (not just sit side by side) took real iteration.
Where I'd take this next: I think there's a lot of room to explore explainability that updates during a vehicle's decision sequence rather than after a single frame — showing not just "why did it flag this" but "how did its confidence shift over the last few frames."
Curious if anyone else here has worked on XAI for CV pipelines specifically — would love to hear what tools or approaches you've used.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article