Anomaly detection for autonomous vehicles
An autoencoder trained on normal CARLA telemetry that flags anomalies and traffic-law violations live
An autoencoder compresses its input and then tries to rebuild it. Trained only on normal driving, it rebuilds normal telemetry well and abnormal telemetry badly. The size of the reconstruction error is the anomaly score: if it crosses a threshold, the moment is flagged.
Source: github.com/Krishna-Gunjan/Data-Extraction-and-Prediction-for-AVs
The pipeline
- Collect telemetry from CARLA: position, velocity, IMU, GNSS, controls and more.
- Train the autoencoder on normal driving; the model and scaler are saved.
- Detect live using the reconstruction error against a tunable threshold.
- Log telemetry and statistics to Redis.
- Export telemetry or anomalies to JSON for analysis.
The model
A 22-feature autoencoder with a symmetric bottleneck, 22 → 16 → 8 → 4 → 8 → 16 → 22, trained on normal CARLA telemetry. The anomaly threshold is the 95th percentile of the reconstruction error.
Results
A live CARLA demo showcased ADAS behaviour and its use for detecting traffic-law violations, such as running through a red light and exceeding the speed limit, with 97.9% accuracy.
Repository tools
-
autoencoder.py: loads a dataset, trains, saves the model and scaler. -
live_redis.py: reads CARLA sensors, scores them with the model, logs to Redis. -
redis_query.py: exports all telemetry or only anomalies to JSON.
Limits
- The model learns what this simulator’s normal driving looks like; real vehicles would need real data.
- A single threshold trades missed anomalies against false alarms; the 95th percentile is a tunable starting point.
- The 97.9% figure is from a scripted live demo, not a broad benchmark.
Stack: Python, CARLA, TensorFlow/Keras, scikit-learn, Redis.