An intelligent road anomaly detection platform powered by a dual YOLOv8 model architecture. Upload geotagged images or videos, stream live camera feed, and get instant anomaly detection with severity scoring, GPS mapping, and municipality-ready reports.
Features β’ Dashboards β’ Installation β’ Dataset β’ API
RoadSense AI is a full-stack web application that automates the detection of road surface anomalies β potholes, cracks, and severe cracks β using deep learning. The system combines two complementary YOLOv8 models to balance detection accuracy and inference speed, assigns a severity score (1β10) to each finding, pins anomalies on a real GPS map, and presents everything across three purpose-built dashboards.
Built for:
- Citizens and field teams who report road damage
- Municipal authorities who need to prioritize repairs
- Infrastructure management and smart city initiatives
- π· Image upload β JPEG, PNG, BMP, WebP
- π¬ Video upload β MP4, AVI, MOV, MKV (processed frame by frame)
- π‘ Live camera stream β real-time detection via device webcam (MJPEG, no external API)
- π§ Dual-model architecture β Model 1 (accuracy, red boxes) + Model 2 (speed, blue boxes) run simultaneously
- ποΈ Per-model confidence threshold β independently adjustable sliders for each model
- β Toggle models β enable or disable each model independently
- π Severity scoring (1β10) β AI-computed from anomaly type and bounding box area ratio
- πΊοΈ Real GPS map β Leaflet.js with OpenStreetMap tiles; pins colored by severity level
- π GPS auto-extraction β reads EXIF metadata from geotagged images/videos automatically
- βοΈ Manual coordinate entry β fallback when EXIF data is unavailable
- π Reverse geocoding β Nominatim API converts coordinates to human-readable city/state
- π₯οΈ Upload Dashboard β detect anomalies, view annotated results, severity display
- ποΈ Municipality Dashboard β GPS map with severity filter, anomaly table, area search
- π History Dashboard β full detection history with thumbnail images and scores
- π Area search β search by city/area name; map and table filter to matching records
- π― Severity filter β click a severity band (1β3, 4β6, 7β8, 9β10) to isolate pins on map
- π Anomaly table β sorted by severity (highest first), shows all anomaly types per record
- π GPS pin coloring β color-coded pins with pulsing animation for critical anomalies
roadsense_project/
β
βββ app.py # Flask backend β all routes and API logic
βββ inference.py # Dual-model inference + severity calculation
βββ location_utils.py # GPS extraction (EXIF) + Nominatim geocoding
βββ config.py # Model paths and default confidence values
βββ utils.py # Helper utilities
βββ requirements.txt # Python dependencies
β
βββ RoadDetectionModel/ # Model 1 weights (custom trained YOLOv8m)
β βββ RoadModel_yolov8m.pt_rounds120_b9/
β βββ weights/
β βββ best.pt β Model 1 weights file
β
βββ YOLOv8_Small_2nd_Model.pt # Model 2 weights (YOLOv8 Small)
β
βββ templates/
β βββ index.html # Upload Dashboard
β βββ analytics.html # Municipality Dashboard
β βββ history_page.html # History Dashboard
β
βββ static/
βββ uploads/ # Uploaded files (auto-created)
βββ results/ # Annotated output files (auto-created)
βββ demo/ # Dashboard screenshots
βββ history.json # Detection records store
| Requirement | Version |
|---|---|
| Python | 3.9 or higher |
| pip | latest |
| RAM | 8 GB minimum, 16 GB recommended |
| Processor | Multi-core CPU (GPU optional but improves speed) |
git clone https://github.com/guptamukul05/roadsense_project.git
cd roadsense_project# Windows
python -m venv venv
venv\Scripts\activate
# macOS / Linux
python3 -m venv venv
source venv/bin/activateYou will see (venv) at the start of your terminal β this means it is active.
pip install -r requirements.txtThis installs Flask, OpenCV, Ultralytics YOLOv8, Supervision, Pillow, NumPy, and Requests. Takes 3β5 minutes depending on internet speed.
Make sure both model weight files exist before running:
roadsense_project/
βββ RoadDetectionModel/
β βββ RoadModel_yolov8m.pt_rounds120_b9/
β βββ weights/
β βββ best.pt β
required
βββ YOLOv8_Small_2nd_Model.pt β
required
python app.pyExpected terminal output:
β
Model 1 loaded (YOLOv8m β RoadModel)
β
Model 2 loaded (YOLOv8 Small)
* Running on http://0.0.0.0:5000
Open your browser and visit:
http://localhost:5000
cd roadsense_project
venv\Scripts\activate # Windows
# source venv/bin/activate # macOS / Linux
python app.py| Property | Value |
|---|---|
| Architecture | YOLOv8 Medium (YOLOv8m) |
| Training epochs | 120 |
| Input size | 640 Γ 640 px |
| Default confidence threshold | 0.35 |
| Box color in output | π΄ Red |
| Primary strength | High accuracy β captures subtle and irregular anomalies |
| Property | Value |
|---|---|
| Architecture | YOLOv8 Small |
| Input size | 640 Γ 640 px |
| Default confidence threshold | 0.40 |
| Box color in output | π΅ Blue |
| Primary strength | Fast inference β suitable for real-time processing |
A single large model is accurate but slow. A single small model is fast but misses subtle anomalies. Running both simultaneously gives:
- Fewer missed detections β subtle cracks caught by Model 1
- Real-time capability β Model 2 keeps inference fast
- Visual transparency β red vs blue boxes clearly show which model flagged what
Severity is computed automatically from all detections across both models, using the anomaly class and how much of the image it occupies.
| Anomaly Class | Weight | Reason |
|---|---|---|
| Pothole | 8.0 | Highest accident risk, direct vehicle damage |
| Crack-Severe | 6.0 | Structural damage with spreading risk |
| Crack | 2.0 | Surface level, lower urgency |
| Other / Unknown | 1.0 | Unclassified anomaly |
| Score | Level | Color | Recommended Action |
|---|---|---|---|
| 1 β 3 | Low | π’ Green | Monitor only |
| 4 β 6 | Medium | π‘ Yellow | Schedule repair |
| 7 β 8 | High | π Orange | Priority repair this week |
| 9 β 10 | Critical | π΄ Red | Immediate action required |
The models were trained on the RDD2022 (Road Damage Dataset 2022) β a large-scale, multi-country road damage dataset collected using smartphone cameras mounted on vehicles.
| Property | Value |
|---|---|
| Total Images | ~47,000 annotated images |
| Countries | Japan, India, United States, Czech Republic, Norway, China |
| Annotation Format | YOLO format (normalized bounding boxes) |
| Collection Method | Smartphone cameras on moving vehicles |
| Preprocessing | Resized to 640 Γ 640 px |
| Class | Description |
|---|---|
pothole |
Bowl-shaped depression β road surface removed |
crack |
Longitudinal, transverse, or surface cracking |
crack-severe |
Alligator / fatigue cracking β deep structural damage |
Heavy-Vehicle |
Trucks, buses (road scene context) |
Light-Vehicle |
Cars, motorbikes (road scene context) |
Pedestrian |
People in the frame |
Speed-Bump |
Speed breaker / sleeping policeman |
- Name: RDD2022 β Road Damage Dataset 2022
- Published by: Deeksha Arya et al., Tohoku University
- Repository: https://github.com/sekilab/RoadDamageDetector
- License: CC BY 4.0
| Metric | Overall | Pothole | Crack | Crack-Severe |
|---|---|---|---|---|
| Precision | 0.736 | 0.597 | 0.576 | 0.548 |
| Recall | 0.740 | 0.440 | 0.484 | 0.503 |
| mAP@0.5 | 0.745 | 0.468 | 0.505 | 0.493 |
| mAP@0.5:0.95 | 0.448 | 0.198 | 0.240 | 0.273 |
Average inference speed: ~12 ms per image
| Method | Endpoint | Description |
|---|---|---|
GET |
/ |
Upload Dashboard |
GET |
/analytics |
Municipality Dashboard |
GET |
/history_page |
History Dashboard |
POST |
/detect/image |
Run detection on uploaded image |
POST |
/detect/video |
Run detection on uploaded video |
POST |
/camera/start |
Start live webcam detection |
POST |
/camera/stop |
Stop live webcam |
GET |
/camera/stream |
MJPEG live camera stream |
GET |
/history |
Fetch all detection records as JSON |
POST |
/history/clear |
Clear all detection history |
GET |
/status |
Model load status and camera state |
| Service | Purpose |
|---|---|
| OpenStreetMap Nominatim | Reverse geocoding β converts GPS coordinates to city/state name when saving a detection record |
| OpenStreetMap Nominatim | Forward geocoding β converts a typed area name to coordinates for the municipality area search feature |
| Leaflet.js + OSM tiles | Interactive GPS map rendering across Municipality and Upload dashboards |
Live camera streaming uses no external API β handled entirely by OpenCV webcam capture and Flask MJPEG streaming.
Model 1 not found on startup
β Ensure RoadDetectionModel/RoadModel_yolov8m.pt_rounds120_b9/weights/best.pt exists in the project root.
Model 2 not found on startup
β Ensure YOLOv8_Small_2nd_Model.pt exists in the project root.
Camera not opening β Close any other application using the webcam (Zoom, Teams, OBS, etc.) and try again.
Address already in use error
β Port 5000 is occupied. Run on a different port:
flask run --port 5001Then open http://localhost:5001
No GPS coordinates extracted from image β The image was not geotagged. Use the manual latitude/longitude input fields, or click "Auto-detect GPS from device" to use browser geolocation.
Slow video processing β The system processes every 2nd frame for speed. Use shorter clips on low-end hardware. An NVIDIA GPU with CUDA will significantly improve processing speed.





