The following screenshots showcase the key features and interfaces of the SafeCityAI application:
The main dashboard provides an overview of accident statistics, emergency service contacts, and key metrics for quick assessment of road safety in Bangalore.
A comprehensive AI-powered platform for accident prevention and road safety in Bangalore. This system integrates real-time weather data, historical accident records, and machine learning predictions to help citizens navigate safely and report hazardous conditions.
This project is developed as part of the เคธเคฎAI - Time for AI competition, which challenges participants to code, create, and innovate with Artificial Intelligence. SafeCityAI demonstrates how AI can be leveraged to create safer urban environments and potentially save lives through predictive analytics and community engagement.
- Detailed Visualization: View accident-prone areas across Bangalore with severity indicators
- Filtering Options: Filter hotspots by severity, incident count, accident type, and time of day
- Multiple Map Views: Switch between marker, heatmap, and cluster visualizations
- Detailed Information: Click on markers to see comprehensive accident data and contributing factors
The interactive map visualizes accident hotspots across Bangalore with color-coded markers indicating severity levels, allowing users to identify high-risk areas at a glance.
- Source-Destination Selection: Choose starting and ending points in Bangalore
- Safety-Optimized Routes: Get routes that avoid high-accident areas
- Risk Assessment: View safety scores for suggested routes
- Accident Hotspot Avoidance: Automatically routes around known dangerous areas
- Time and Distance Estimates: Compare safety vs. convenience trade-offs
- Real-time Monitoring: Live camera feeds from high-risk areas across Bangalore
- YOLOv8 Detection: State-of-the-art object detection for vehicles and crashes
- Bounding Box Visualization: Real-time tracking of vehicles with confidence scores
- Crash Analysis: Automatic identification of accidents based on vehicle proximity and motion
- Multi-Camera Support: Simultaneous monitoring of multiple locations with different video feeds
- Instant Alerts: Immediate notification when incidents are detected
- Emergency Response: Automatic dispatch of emergency services
- Incident Analytics: Review and analysis of detected incidents with detailed metrics
- Local Video Processing: Automatic detection and use of videos from the Crash-1500 directory
Real-time video surveillance with YOLO-based crash detection across multiple camera feeds in Bangalore
- Risk Prediction: AI-powered prediction of accident likelihood based on multiple factors
- City-wide Risk Map: Color-coded visualization of risk levels across the entire city
- Emerging Hotspot Detection: Identification of new high-risk areas before they become problematic
- Personalized Safety Recommendations: Contextual safety advice based on current conditions
The city-wide risk prediction map uses AI to visualize accident risk levels across Bangalore with a heat map overlay. Red areas indicate high-risk zones, yellow shows moderate risk, and green represents lower risk areas. Red markers pinpoint specific accident hotspots.
The recent updates section keeps users informed about road work, traffic signal changes, and other important traffic-related announcements with timestamps.
- Real-time Weather Data: Current weather conditions and forecasts for Bangalore
- Weather-related Safety Alerts: Automatic warnings when weather conditions may affect road safety
- Forecast Integration: 7-day weather forecast to help plan safer travel
- Condition-specific Safety Tips: Tailored advice for different weather conditions
Real-time weather data showing temperature (23.9ยฐC), humidity (65%), and wind speed (2.5 km/h) with clear sky conditions.
3-day weather forecast for March-April 2025 showing upcoming conditions: slight rain showers on Monday (April 14), overcast on Tuesday (April 15), and thunderstorm with slight hail on Wednesday (April 16).
Context-aware driving safety tips that update based on current and forecasted weather conditions, helping drivers navigate safely during adverse weather.
- Issue Reporting: Allow citizens to report road hazards and safety issues
- Location Selection: Interactive map for precise location reporting
- Media Upload: Support for uploading photos of hazardous conditions
- Status Tracking: Follow the status of reported issues
Recent community reports showing citizen-submitted hazards with location details, issue type, severity level, and report status. Reports from April 2025 include a pothole on Outer Ring Road, a broken traffic signal, and waterlogging after rain.
- One-click Emergency Contact: Quick access to emergency services at the top of every page
- Direct Calling: Integrated calling functionality for immediate assistance
- Multiple Services: Access to Police, Fire, Ambulance, and General Emergency services
The emergency services bar at the top of the application provides quick access to important contact numbers (112 for Police, 108 for Ambulance, 100 for Emergency, 101 for Fire) for immediate assistance in case of accidents.
- Support for English, Hindi, and Kannada languages
- Easy language switching via the top navigation bar
- Localized emergency information and safety tips
The application footer displays copyright information (ยฉ 2025) and acknowledges that the system was created for the เคธเคฎAI - Time for AI competition, reinforcing the project's forward-looking vision.
- Accident Data: Historical records of accident-prone areas in Bangalore
- Weather Data: Real-time and forecast data from Open-Meteo API
- Citizen Reports: Crowdsourced information about road hazards and safety issues
- Risk Prediction Model: Analyzes multiple factors to predict accident likelihood
- Hotspot Identification: Uses clustering algorithms to identify accident-prone areas
- Weather Impact Analysis: Correlates weather conditions with accident frequency
- Emerging Risk Detection: Identifies new patterns in accident data to predict future hotspots
- Frontend: Streamlit for interactive web interface
- Data Processing: Pandas for data manipulation and analysis
- Visualization: Folium for maps, Plotly for interactive charts
- Machine Learning: Scikit-learn for predictive models
- APIs: Open-Meteo for weather data
The application follows a modular architecture with clear separation of concerns:
- Data Layer: Handles data loading, processing, and storage
- Logic Layer: Implements business logic, predictions, and data analysis
- Presentation Layer: Manages the user interface and visualization components
- Python 3.8 or higher
- Git
-
Clone this repository:
git clone https://github.com/Aditya-Ranjan1234/SafeCityAI.git cd SafeCityAI -
Create a virtual environment and activate it:
python -m venv venv # On Windows venv\Scripts\activate # On macOS/Linux source venv/bin/activate
-
Install the required packages:
pip install -r requirements.txt
Note: The application uses several key dependencies:
- Streamlit: For the interactive web interface
- Folium: For interactive maps and route visualization
- NetworkX: For route planning algorithms
- OpenCV: For video processing and accident detection
- Plotly: For data visualization
- Scikit-learn: For machine learning predictions
-
Download the CarCrash dataset for accident detection (optional):
git clone https://github.com/Cogito2012/CarCrashDataset.git
-
Configure environment variables (if needed):
- Rename
.env.exampleto.env - Add your API keys for weather services
- Rename
-
Run the Streamlit application:
streamlit run app.py
-
Open your web browser and navigate to:
http://localhost:8501
To deploy on Streamlit Cloud and avoid the libGL.so.1 error:
-
Make sure your
requirements.txtfile includes all necessary dependencies. -
The application has built-in fallback mechanisms to handle missing OpenCV dependencies.
-
If you encounter the
libGL.so.1error, you can install the required system packages on your server:# For Ubuntu/Debian apt-get update && apt-get install -y libgl1-mesa-glx libglib2.0-0 # For Amazon Linux/CentOS yum update -y && yum install -y mesa-libGL
-
Alternatively, use the provided Dockerfile for containerized deployment:
# Build and run using Docker docker build -t safecityai . docker run -p 8501:8501 safecityai
-
Access the application at:
http://localhost:8501
โโโ app.py # Main Streamlit application
โโโ sample.py # Standalone crash detection interface
โโโ requirements.txt # Python dependencies
โโโ Dockerfile # Docker configuration for containerized deployment
โโโ docker-compose.yml # Docker Compose configuration for easy deployment
โโโ WORKFLOW.md # Detailed workflow documentation
โโโ .env # Environment variables (API keys)
โโโ src/ # Source code
โ โโโ components/ # UI components
โ โ โโโ emergency_services.py # Emergency services components
โ โ โโโ map_components.py # Map visualization components
โ โ โโโ stats_components.py # Statistical visualization components
โ โ โโโ weather_components.py # Weather visualization components
โ โโโ data/ # Data files
โ โ โโโ bangalore_accident_data.csv # Accident hotspot data
โ โ โโโ videos/ # Video files for surveillance demo
โ โโโ pages/ # Application pages
โ โ โโโ home_page.py # Home page
โ โ โโโ accident_map_page.py # Accident map page
โ โ โโโ ml_predictions_page.py # ML predictions page
โ โ โโโ route_planning_page.py # Safe route planning page
โ โ โโโ video_surveillance_page.py # Video surveillance page
โ โ โโโ weather_page.py # Weather and alerts page
โ โ โโโ report_page.py # Issue reporting page
โ โโโ utils/ # Utility modules
โ โโโ config.py # Configuration settings
โ โโโ data_loader.py # Data loading utilities
โ โโโ video_detection.py # Video processing and accident detection
โ โโโ yolo_detection.py # YOLOv8-based crash detection
โโโ CarCrashDataset/ # Reference dataset for accident detection
โโโ screenshots/ # Application screenshots for documentation
โโโ images/ # Application screenshots for README
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- เคธเคฎAI - Time for AI for the opportunity to showcase this project
- Open-Meteo for providing free weather API
- Streamlit for the excellent web application framework
- Folium for the interactive mapping capabilities
- CarCrashDataset for providing reference data for accident detection
- NetworkX for the graph algorithms used in route planning
- YOLOv8 for state-of-the-art object detection
In addition to the main application, this project includes a standalone crash detection interface (sample.py) that allows users to upload and analyze traffic videos for crashes.
- Video Upload: Upload any traffic video for crash analysis
- YOLOv8 Processing: Frame-by-frame analysis with state-of-the-art object detection
- Real-time Visualization: Watch the detection process with bounding boxes
- Crash Frame Identification: Pinpoints the exact moment of collision
- Detailed Analysis: Provides confidence scores, timestamps, and severity assessment
- Emergency Recommendations: Suggests actions to take when a crash is detected
To run the standalone crash detection interface:
streamlit run sample.pyThis will open a web interface where you can upload traffic videos for crash analysis.