This project implements a fire and smoke detection system using the YOLO (You Only Look Once) object detection model. The system is built with the Ultralytics YOLO library and is designed to detect smoke and fire in images and videos.
The notebook (fire-detection-using-yolo-model.ipynb) demonstrates the complete pipeline from data preprocessing to model deployment.
- 🧹 Data Cleaning: Automatically identifies and removes corrupted or problematic images.
- 🖥️ YOLO Model Training: Trains a custom YOLO model for smoke and fire detection.
- 📊 Model Validation: Evaluates the trained model on validation and test sets.
- 🖼️ Visualization: Displays sample images with bounding boxes for detected objects.
- 💾 Export: Saves trained models in multiple formats (PyTorch, ONNX, etc.).
Before running this project, ensure you have:
- 🐍 Python 3.8+
- 📓 Jupyter Notebook or JupyterLab
- ⚡ A CUDA-compatible GPU (recommended for faster training)
- 💽 Sufficient disk space for datasets and models
-
Clone or Download the Repository
- Ensure the project files are in your workspace, specifically in the
Fire Detection systemfolder.
- Ensure the project files are in your workspace, specifically in the
-
Install Required Packages
- Run:
!pip install ultralytics - Other dependencies (OpenCV, NumPy, Matplotlib, etc.) are usually pre-installed.
- Run:
-
Set Up Environment
- Activate your virtual environment if using one.
- For GPU support, ensure PyTorch with CUDA is installed (Ultralytics handles this).
The project uses the "Smoke Fire Detection YOLO" dataset for training object detection models.
- Removes bad images listed in
bad_list. - Detects corrupted images with OpenCV.
- Copies valid images and labels to a clean directory.
- Generates a report CSV of actions taken.
-
Open
fire-detection-using-yolo-model.ipynbin Jupyter. -
Execute cells in order:
- 📥 Import libraries
- 🛣️ Define paths
- 🗑️ List bad images
- 📂 Create directories & clean data
- 📑 Generate data report
- 📝 Create
data.yaml - 🖼️ Visualize sample images
- 📦 Install Ultralytics
- 🔄 Import YOLO
- 🚀 Load pre-trained model
- 🏋️ Train the model
- ✅ Validate the model
-
Adjust training parameters in
model.train()(e.g., epochs, image size). -
Modify class names in
data.yamlif needed (smokeandfire).
- Evaluate metrics: mAP, precision, recall.
- Test on new data by updating paths.
- 🛣️ Path Issues: Update
/kaggle/input/paths for local setup. - 💾 Memory Errors: Reduce batch size or image size.
- 🐍 Installation Issues: Upgrade pip:
pip install --upgrade pip. - 🗑️ Corrupted Data: Check
data_clean_report.csv.
- Fork the repo and submit pull requests.
- Report issues or suggest features via GitHub.
- Dataset: Smoke Fire Detection YOLO Dataset (Kaggle)
- Library: Ultralytics YOLO
- Inspired by various open-source object detection projects
HOSEN ARAFAT
Software Engineer, China
GitHub: https://github.com/arafathosense
Researcher: Artificial Intelligence, Machine Learning, Deep Learning, Computer Vision, Image Processing