A real-time fire detection system using Convolutional Neural Networks (CNNs).
The system instantly detects fires from live camera feeds (default: laptop webcam), triggers audible alerts, and automatically logs fire events.
- Real-Time Detection: Detects fire instantly from webcam or IP camera feeds.
- Cross-Platform Support: Works with laptop webcams (default) and optional Android phone cameras.
- Event Logging: Automatically logs fire detection events in
fire_alerts.log. - Audio Alerts: Plays a simple beep alarm when fire is detected.
- Lightweight Model: Trained CNN model optimized for fast inference.
— Core programming language
— CNN model training & inference
— High-level model building
— Video capture & image preprocessing
— Numerical operations
— Plotting training results
— Evaluation metrics
RealTime-Fire-Detector/
│
├── dataset_sample/ # Small sample images (fire / non-fire)
├── models/
│ └── forest_fire_cnn.h5 # Trained CNN model (from models.rar)
├── notebooks/
│ └── train_fire_model.ipynb
├── fire_detection.py # Real-time detection code
├── requirements.txt # Python dependencies
├── README.md
└── LICENSE
Python 3.10+ is required along with the following packages:
tensorflow>=2.12.0
keras>=2.12.0
opencv-python
numpy
matplotlib
scikit-learn
jupyter
ipykernel
pip install -r requirements.txtconda create -n ds_env python=3.10
conda activate ds_env
pip install -r requirements.txtSimply run:
python fire_detection.pyThe system will automatically use your laptop’s built-in webcam (device index
0). Fire detection results will appear on screen, and a beep alert will sound if fire is detected. Pressqto quit the program.
- Install the IP Webcam app on your phone.
- Connect your PC and phone to the same Wi-Fi network.
- Start IP Webcam → choose MJPEG / Browser stream.
- Update the URL in
fire_detection.py:
url = "http://<your-phone-ip>:8080/video"- Run the detection script:
python fire_detection.pyThe trained CNN model for real-time fire detection can be downloaded here:
Extract the
.rarfile to getforest_fire_cnn.h5before runningfire_detection.py.
- Any small flame (candle, lighter, or fire video) can be used for testing.
- No need to demonstrate an actual forest fire.
- Ensure good lighting and camera clarity for accurate detection.
- Recommended for educational, safety simulation, or prototyping purposes.
Contributions are welcome! If you have improvements, optimizations, or bug fixes, feel free to submit a pull request or open an issue.
This project is licensed under the MIT License. See the LICENSE file for details.
This project demonstrates the power of computer vision and deep learning for real-world safety applications. It showcases practical experience with TensorFlow, Keras, and OpenCV, as well as deploying models for real-time live video analysis.