This repository contains a real-time fire detection model based on the YOLO (You Only Look Once) architecture. The model is designed to identify fire outbreaks quickly and accurately, making it a critical tool for early fire detection and prevention.
- Real-Time Detection: Identifies fire in live video streams or pre-recorded footage with high accuracy.
- YOLO Architecture: Leverages the power of YOLO for fast and efficient object detection.
- Customizable: Easily adaptable for different use cases by retraining the model with domain-specific datasets.
- Scalable: Suitable for implementation in drones, surveillance systems, or IoT devices.
Before using this repository, ensure you have the following installed:
- Python 3.7 or higher
- OpenCV
- PyTorch
- NumPy
- Matplotlib
- Other dependencies listed in
requirements.txt
To install the required dependencies, run:
pip install -r requirements.txt- Collect Fire and Non-Fire Images: Gather a dataset of images containing fire and non-fire scenarios.
- Annotate Data: Use tools like LabelImg to annotate the dataset with bounding boxes for fire regions.
- Organize Data:
- Place annotated images in the
data/imagesfolder. - Store annotation files in
data/annotations.
- Place annotated images in the
To train the YOLO-based fire detection model, follow these steps:
-
Prepare Configuration Files:
- Adjust YOLO configuration files for your dataset (classes, input size, etc.).
-
Start Training:
python train.py --data data/fire.yaml --cfg cfg/yolov5s.yaml --weights yolov5s.pt --epochs 50
-
Monitor Progress:
- Training logs will display metrics like loss, mAP, and confidence thresholds.
Run the model on test images or videos to evaluate performance:
python detect.py --weights runs/train/exp/weights/best.pt --source data/test/video.mp4Replace data/test/video.mp4 with the path to your test file.
To deploy the model in a real-time application:
- Setup Camera Feed: Use OpenCV to capture video streams.
- Integrate Model: Load the trained YOLO weights and process each frame for fire detection.
- Trigger Alerts: Implement notifications or alarms when fire is detected.
fire-detection-model/
│
├── data/
│ ├── images/ # Training and test images
│ ├── annotations/ # Annotation files
│ ├── test/ # Test videos or images
│
├── models/ # YOLO model configuration files
├── runs/ # Trained models and results
├── utils/ # Utility scripts for data preprocessing
│
├── train.py # Training script
├── detect.py # Inference script
├── requirements.txt # Dependencies
├── README.md # Project documentation
The model achieves high detection accuracy and low false positive rates on the test dataset. Below are some example outputs:
| Metric | Value |
|---|---|
| Precision | 95.2% |
| Recall | 93.5% |
| [email protected] | 94.7% |
- Support for multi-class fire detection (e.g., smoke, flame size, etc.).
- Integration with IoT devices for automated response systems.
- Optimization for edge computing devices.
Contributions are welcome! Feel free to submit issues or pull requests for enhancements, bug fixes, or additional features.
This project is licensed under the MIT License. See the LICENSE file for details.
- YOLO for the detection framework.
- Open-source contributors for pre-trained weights and tools.