YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
CCTV Accident Detection with YOLO and Streamlit
This project is a CCTV accident detection application using the YOLO model, Streamlit, and Google Generative AI. The app analyzes video footage to detect accidents, generates detailed reports, and provides a user-friendly interface for viewing and managing accident reports.
Features
- Real-time Accident Detection: Uses the YOLO model to detect accidents in video footage.
- Video Annotation: Annotates the video with detected objects and displays it in a Streamlit app.
- Automated Report Generation: Generates and saves accident reports with details like class, confidence score, and timestamp.
- Accident Description: Uses Google Generative AI to generate a professional accident description based on the detected incident.
- Report Management: Displays saved reports and associated images, with an option to generate or view detailed descriptions.
Project Structure
Prerequisites
- Python 3.7+
best_model_without_freeze.pt(YOLO model weights)- Google API key for Generative AI (stored in a
.envfile)
Installation
Clone the repository:
git clone https://github.com/your_username/cctv-accident-detection.git cd cctv-accident-detectionInstall the required libraries:
pip install -r requirements.txtSet up the
.envfile: Create a.envfile in the project root and add your Google API key:GOOGLE_API_KEY=your_api_key_hereDownload the YOLO model weights: Place the
best_model_without_freeze.ptfile in the project root.
Running the Application
Start the Streamlit app:
streamlit run main.pyNavigate to the app: Open your browser and go to
http://localhost:8501.
Usage
Video & Prediction Page:
- Upload a video file to analyze.
- The app will display the annotated video and detect accidents.
- If an accident is detected, a report is generated and saved.
Reports Page:
- View saved accident reports with details like class, confidence, and timestamp.
- See associated images for each report.
- Generate or view accident descriptions using Google Generative AI.
Example
- Detected Accident Report:
Class: Accident Confidence: 0.85 Time: 2024-10-13_14-30-00 Description: Two vehicles involved, with visible damage on the front of one vehicle. Road conditions are wet, and traffic is partially blocked.
Dependencies
opencv-pythonstreamlitpandasultralyticsnumpygoogle-generativeaipython-dotenv
Future Enhancements
- Add support for different video formats.
- Implement email notifications for generated accident reports.
- Integrate with a cloud storage service for report storage.
Contributing
- Fork the repository.
- Create a new branch (
git checkout -b feature/YourFeature). - Commit your changes (
git commit -m 'Add some feature'). - Push to the branch (
git push origin feature/YourFeature). - Open a Pull Request.
License
This project is licensed under the MIT License.
Acknowledgements
- Thank you, Tuwaiq Academy for your guidance and for fostering an environment that allowed us to successfully complete this project.
- YOLO (You Only Look Once)
- Streamlit
- Google Generative AI