Skip to content

About

AI-powered V2V collision-risk prediction with a real-time 3D traffic simulation, Random Forest regression, live risk analytics, and proactive safety alerts.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

ย 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿš— PreCrash-AI

AI-Powered V2V Collision Risk Prediction & Real-Time 3D Traffic Simulation

PreCrash-AI is an AI-powered automotive safety system designed to predict the risk of Vehicle-to-Vehicle (V2V) collisions using machine learning and visualize the predicted risk through an interactive real-time 3D traffic simulation.

The system analyzes vehicle movement and environmental conditions such as speed, relative speed, distance, lane position, weather, and braking events to estimate collision risk and provide proactive safety alerts.


๐ŸŽฏ Project Objective

The objective of PreCrash-AI is to explore how Artificial Intelligence and Vehicle-to-Vehicle communication data can be used to identify potentially dangerous driving situations before a collision occurs.

By combining machine learning-based collision-risk prediction with real-time traffic simulation and visualization, the system demonstrates how intelligent transportation systems can provide proactive warnings and contribute to safer road environments.


โœจ Features

  • AI-based V2V collision risk prediction
  • Random Forest Regression model
  • Real-time 3D traffic simulation
  • Multiple simulated vehicles across multiple lanes
  • Live collision-risk monitoring
  • Proactive high-risk collision alerts
  • Vehicle-to-Vehicle data simulation
  • Dynamic vehicle speed controls
  • Weather simulation including Clear, Rain, and Fog
  • Real-time V2V communication logs
  • Collision-risk timeline visualization
  • AI feature importance visualization
  • Interactive traffic environment
  • Multiple camera modes including Top, POV, and Chase views
  • Backend API for real-time collision prediction

๐Ÿง  Machine Learning Model

PreCrash-AI uses a Random Forest Regressor to estimate collision risk based on vehicle and environmental parameters.

Random Forest combines multiple decision trees and produces a more stable prediction by aggregating their outputs.

Input Features

The model considers factors such as:

  • Ego vehicle speed
  • Other vehicle speed
  • Distance between vehicles
  • Relative speed
  • Lane difference
  • Weather condition
  • Brake events

Output

The model generates a collision-risk score ranging from:

0.0 โ†’ Low Collision Risk

1.0 โ†’ High Collision Risk

The predicted score is used by the application to display real-time risk levels and generate warnings when potentially dangerous situations are detected.


๐Ÿ—๏ธ System Architecture

Vehicle Simulation
        โ†“
V2V Data Generation
        โ†“
Feature Extraction
        โ†“
Machine Learning Model
(Random Forest Regressor)
        โ†“
Collision Risk Prediction
        โ†“
Risk Analysis & Alerts
        โ†“
Real-Time Dashboard
        โ†“
3D Traffic Visualization

๐Ÿ”„ Workflow

  1. Vehicles are simulated in the 3D traffic environment.
  2. Vehicle parameters such as speed, position, distance, and braking behaviour are collected.
  3. V2V data is generated between nearby vehicles.
  4. Relevant features are sent to the Flask backend.
  5. The trained Random Forest model processes the input features.
  6. The model predicts the collision-risk score.
  7. Risk values are sent back to the frontend.
  8. The dashboard displays the prediction in real time.
  9. High-risk situations trigger proactive safety alerts.

๐Ÿ’ป Tech Stack

Machine Learning

  • Python
  • Scikit-learn
  • Pandas
  • NumPy
  • Random Forest Regression

Backend

  • Flask
  • Flask-CORS
  • Python

Frontend

  • HTML
  • CSS
  • JavaScript
  • Three.js
  • Chart.js

Visualization

  • Three.js for interactive 3D traffic simulation
  • Chart.js for real-time analytics and risk visualization

Version Control

  • Git
  • GitHub

๐Ÿ“ Project Structure

PreCrash-AI/
โ”‚
โ”œโ”€โ”€ backend/
โ”‚   โ”œโ”€โ”€ app.py
โ”‚   โ”œโ”€โ”€ train_model.py
โ”‚   โ”œโ”€โ”€ model.pkl
โ”‚   โ”œโ”€โ”€ requirements.txt
โ”‚   โ””โ”€โ”€ v2v_collision_probability_dataset.csv
โ”‚
โ”œโ”€โ”€ frontend/
โ”‚   โ”œโ”€โ”€ index.html
โ”‚   โ”œโ”€โ”€ style.css
โ”‚   โ””โ”€โ”€ script.js
โ”‚
โ”œโ”€โ”€ .gitignore
โ”‚
โ””โ”€โ”€ README.md

๐Ÿš€ How to Run the Project

1. Clone the Repository

Open a terminal and run:

git clone https://github.com/thanvitha-ippagunta/PreCrash-AI.git

Move into the project directory:

cd PreCrash-AI

2. Move to the Backend Folder

cd backend

3. Install Required Dependencies

pip install -r requirements.txt

4. Train the Model

If the trained model is not already available, run:

python train_model.py

This trains the Random Forest collision-risk prediction model.


5. Start the Backend

Run:

python app.py

The Flask backend will start locally.


6. Open the Application

Open the frontend application in your browser.

The backend will typically run at:

http://127.0.0.1:5000

๐Ÿ“ก Backend API

The Flask backend handles communication between the 3D traffic simulation and the machine learning model.

Main Functions

Function Description
Collision Prediction Predicts collision risk using vehicle data
Prediction History Stores and retrieves recent predictions
Feature Importance Displays the influence of model features
System Status Checks whether the AI prediction engine is running
Simulation Reset Clears prediction and simulation history

๐Ÿ“Š Collision Risk Analysis

The application continuously evaluates the relationship between vehicles.

Important factors affecting collision risk include:

Distance

Vehicles travelling very close to each other generally have a higher collision risk.

Relative Speed

A large difference in speed between two vehicles can increase the probability of a collision.

Lane Position

Vehicles occupying the same or nearby lanes may have greater interaction risk.

Braking Behaviour

Sudden braking can significantly increase the risk for vehicles travelling behind.

Weather Conditions

Rain and fog can influence safe driving conditions and therefore affect estimated collision risk.


๐ŸŒฆ๏ธ Weather Simulation

PreCrash-AI supports multiple environmental conditions:

  • โ˜€๏ธ Clear
  • ๐ŸŒง๏ธ Rain
  • ๐ŸŒซ๏ธ Fog

These conditions allow the collision prediction system to be evaluated under different simulated driving environments.


๐Ÿš˜ V2V Communication

Vehicle-to-Vehicle communication allows vehicles to exchange information such as:

  • Speed
  • Position
  • Distance
  • Relative movement
  • Braking behaviour
  • Driving conditions

PreCrash-AI simulates this information exchange and uses the generated data as input to the machine learning prediction system.


๐Ÿ“ˆ Real-Time Analytics

The application provides visual analytics to help understand the AI system's predictions.

These include:

  • Current collision-risk score
  • Collision-risk timeline
  • Vehicle interaction information
  • AI prediction status
  • V2V communication logs
  • Feature importance
  • High-risk alerts

๐ŸŒณ Why Random Forest?

Random Forest was selected because it:

  • Handles nonlinear relationships effectively
  • Works well with multiple input features
  • Is resistant to overfitting compared with a single decision tree
  • Provides feature importance information
  • Can produce fast predictions suitable for interactive simulations
  • Works effectively with structured vehicle telemetry data

๐Ÿ”ฎ Future Enhancements

Future versions of PreCrash-AI can include:

  • Integration with real V2V communication hardware
  • Real-world vehicle telemetry
  • GPS-based vehicle tracking
  • Road-condition information
  • Real-time map integration
  • Driver behaviour analysis
  • Pedestrian collision-risk prediction
  • Cyclist collision-risk prediction
  • Deep learning-based prediction models
  • Edge AI deployment for low-latency predictions
  • Integration with Advanced Driver Assistance Systems (ADAS)
  • Real vehicle sensor integration
  • Larger and more realistic traffic environments

๐Ÿ›ก๏ธ Applications

Potential applications of the project include:

  • Intelligent Transportation Systems
  • Advanced Driver Assistance Systems
  • Connected Vehicles
  • V2V Safety Systems
  • Smart Mobility
  • Autonomous Vehicle Research
  • Collision Avoidance Research
  • Automotive AI
  • Traffic Safety Simulation

โš ๏ธ Disclaimer

PreCrash-AI is developed for educational, research, and simulation purposes.

The current system is a prototype and should not be directly deployed in safety-critical production vehicles without extensive real-world testing, validation, automotive-grade hardware integration, and appropriate safety certification.


๐Ÿ‘ฉโ€๐Ÿ’ป Author

Thanvitha Ippagunta

GitHub: thanvitha-ippagunta


โญ Support

If you find this project useful or interesting, consider giving the repository a โญ on GitHub.

About

AI-powered V2V collision-risk prediction with a real-time 3D traffic simulation, Random Forest regression, live risk analytics, and proactive safety alerts.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages