A fully edge-deployed AI system running on Raspberry Pi 5 that:
- Detects potholes using oriented bounding boxes (rotated to fit irregular shapes)
- Detects unexpected obstacles β people, dogs, vehicles β using a second COCO model
- Runs at 43.6 FPS average with only ~10ms inference latency
- Logs every detection with timestamp and GPS-ready coordinates to CSV
- Requires zero internet connection β fully on-device inference
| Metric | Value |
|---|---|
| π― OBB mAP50 | 0.982 |
| π OBB mAP50-95 | 0.857 |
| β‘ Avg Inference Latency | ~10ms |
| π¬ Average FPS | 43.6 |
| πΎ Model Size (INT8) | 3.13 MB |
| π‘οΈ CPU Utilization | ~65% |
| π Input Resolution | 320 Γ 320 px |
Challenge Target: β₯ 5 FPS β Achieved 8.7Γ the target
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β BHARAT AI-SoC INFERENCE PIPELINE β
ββββββββββββββββ¬βββββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββ€
β β β β
β Pi Camera β Preprocess (320Γ320) β CSV Anomaly Log β
β Module v2 β BGRβRGB + Normalize β Timestamped β
β (CSI) β β Coordinates β
β β β β
ββββββββ¬ββββββββ΄βββββββββββββββ¬ββββββββββββββββ΄ββββββββββββ¬ββββββββββββ
β β β
βΌ βΌ βΌ
βββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββββββββββ
β VideoStreamβ β YOLOv8n-OBB β β YOLOv8n COCO β
β Thread βββββΆβ INT8 TFLite β β INT8 TFLite β
β (lock-safe)β β POTHOLES β β OBSTACLES β
βββββββββββββββ β mAP50: 0.982 β β 80 Classes β
ββββββββββ¬ββββββββββ βββββββββββββ¬ββββββββββββββ
β β
βΌ βΌ
βββββββββββββββββββββββββββββββββββββββββββ
β Post-Processing β
β OBB Rotated Boxes + NMS β
β COCO Axis-Aligned Boxes + NMS β
ββββββββββββββββββββββ¬βββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββ
β OpenCV Overlay β
β Filled rotated boxes (potholes) β
β Labelled rectangles (obstacles) β
β FPS + Latency HUD β
βββββββββββββββββββββββββββββββββββββββββββ
Entire pipeline runs on ARM Cortex-A76 CPU β no accelerators.
| Optimization | Technical Detail |
|---|---|
| YOLOv8n-OBB | C2f blocks use depthwise separable convolutions that map directly to ARM NEON SIMD instructions |
| INT8 Quantization | Reduces model from FP32 β INT8 β uses integer ALU lanes on Cortex-A76, ~4Γ faster than FP32 |
| XNNPACK Delegate | Google's ARM-tuned kernel library β automatically selects NEON-optimized ops |
| 4-Thread Inference | All 4 Cortex-A76 cores utilized via num_threads=4 |
| 320px Input | 4Γ less compute vs 640px β optimal latency/accuracy for edge deployment |
| Lock-safe Camera Thread | Decouples capture from inference β eliminates I/O blocking |
π¦ Bharat-AI-SoC-Road-Anomaly-Detection/
βββ π README.md β You are here
βββ π Project_Report.md β Full technical report
βββ π inference_final_rpi5.py β Main inference script (OBB + COCO)
βββ π inference_obb_rpi5.py β OBB-only pothole detection
βββ π Bharat_AI_SoC_OBB.ipynb β Training notebook (Colab)
βββ π Export_COCO_Obstacle_Model.ipynb β COCO export notebook
βββ π€ pothole_obb_int8.tflite β Trained OBB model (3.13 MB)
βββ π€ yolov8n_coco_int8.tflite β COCO obstacle model
βββ π labels.txt β Class labels
- Raspberry Pi 5 (4GB or 8GB)
- Raspberry Pi Camera Module v2 (CSI)
- Active cooling (fan heatsink recommended)
- High-write microSD card (A2 rated)
# 1. Clone repo
git clone https://github.com/kkjjkamal123/Bharat-AI-SoC-Road-Anomaly-Detection
cd Bharat-AI-SoC-Road-Anomaly-Detection
# 2. Install dependencies
sudo apt update
sudo apt install python3-opencv python3-picamera2 -y
pip install ai-edge-litert --break-system-packages
# 3. Run
python3 inference_final_rpi5.py| Key | Action |
|---|---|
Q |
Quit and show session stats |
| Class | Model | Box Type | Colour |
|---|---|---|---|
| π³οΈ Pothole | YOLOv8n-OBB | Rotated (fitted) | π’ Green |
| π§ Person | YOLOv8n COCO | Axis-aligned | π Orange |
| π Dog | YOLOv8n COCO | Axis-aligned | π©· Pink |
| π Car | YOLOv8n COCO | Axis-aligned | π£ Magenta |
| π Bus / Truck | YOLOv8n COCO | Axis-aligned | π£ Purple |
| π¦ Traffic Light | YOLOv8n COCO | Axis-aligned | π‘ Yellow |
| π Stop Sign | YOLOv8n COCO | Axis-aligned | π΄ Red |
| π² Bicycle | YOLOv8n COCO | Axis-aligned | π΅ Blue |
Architecture : YOLOv8n-OBB (Oriented Bounding Box β Nano)
Dataset : Roboflow Pothole OBB Dataset (198 images)
Epochs : 50 | Batch: 16 | Image: 320px
Optimizer : AdamW lr0=0.001
Augmentation : Mosaic 1.0, flips, HSV, albumentations
Pretrained : COCO (fine-tuned on pothole data)
Export : TFLite INT8 post-training static quantization
Calibration : Training set (representative dataset)
| Epoch | mAP50 | mAP50-95 |
|---|---|---|
| 10 | 0.880 | 0.720 |
| 20 | 0.939 | 0.790 |
| 35 | 0.970 | 0.832 |
| 50 | 0.982 | 0.857 |
Every detection is saved to road_anomalies_log.csv:
Timestamp,Type,Class,Confidence,Details
2026-02-20 21:45:11,Pothole,Pothole,0.94,cx=312 cy=278 angle=23.4
2026-02-20 21:45:11,Obstacle,Person,0.87,x=120 y=45 w=80 h=210
2026-02-20 21:45:12,Obstacle,Dog,0.76,x=340 y=190 w=95 h=88Edit the top of inference_final_rpi5.py to tune behaviour:
OBB_CONF = 0.35 # raise to reduce false positives
DET_CONF = 0.45 # obstacle confidence threshold
FILL_ALPHA = 0.25 # OBB fill transparency (0=none, 1=solid)
DISPLAY_EVERY = 2 # render every Nth frame (raise to increase FPS)
NUM_THREADS = 4 # CPU cores for inferenceBharat AI-SoC Student Challenge | Problem Statement 3 Real-Time Road Anomaly Detection from Dashcam Footage on Raspberry Pi
- Organizers: Arm Education, IIT Delhi, MeitY
- Requirement: β₯ 5 FPS real-time inference on CPU only
- Achieved: 43.6 FPS on single mode ( Potholes alone ) β 8.7Γ the requirement
- Achieved: ~22 FPS on dual mode ( Potholes and Obstacles ) β 4.4Γ the requirement
- Approach: Dual-model pipeline (OBB potholes + COCO obstacles), INT8 quantized, XNNPACK accelerated
Made for Bharat AI-SoC Challenge 2026