Skip to content

kkjjkamal123/ARM-Bharath-Challenge-2026

Repository files navigation


🧠 What This Does

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

πŸ“Š Performance

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


πŸ—οΈ System Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    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.


πŸš€ Why ARM-Optimized?

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

πŸ“¦ Repository Structure

πŸ“¦ 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

βš™οΈ Setup & Installation

Hardware Required

  • Raspberry Pi 5 (4GB or 8GB)
  • Raspberry Pi Camera Module v2 (CSI)
  • Active cooling (fan heatsink recommended)
  • High-write microSD card (A2 rated)

Software Setup

# 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

Controls

Key Action
Q Quit and show session stats

🎯 Detection Classes

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

πŸ“ˆ Training Details

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)

Training Convergence

Epoch mAP50 mAP50-95
10 0.880 0.720
20 0.939 0.790
35 0.970 0.832
50 0.982 0.857

πŸ“ Output Log Format

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=88

πŸ”§ Configuration

Edit 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 inference

πŸ† Challenge Details

Bharat 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

πŸ‘€ Author

Made for Bharat AI-SoC Challenge 2026

GitHub


About

Real-time road anomaly detection on RPi 5 | YOLOv8n-OBB INT8 | 43.6 FPS (single mode) | mAP50: 0.982 | Bharat AI-SoC Challenge 2026

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages