# Yolov5 for Fire Detection
Fire detection task aims to identify fire or flame in a video and put a bounding box around it. This repo includes a demo on how to build a fire detection detector using YOLOv5.
<p align="center">
<img src="results/result.gif" />
</p>
#### Install
Clone this repo and use the following script to install [YOLOv5](https://github.com/ultralytics/yolov5).
```
# Clone
git clone https://github.com/spacewalk01/Yolov5-Fire-Detection
cd Yolov5-Fire-Detection
# Install yolov5
git clone https://github.com/ultralytics/yolov5
cd yolov5
pip install -r requirements.txt
```
#### Training
I set up ```train.ipynb``` script for training the model from scratch. To train the model, download [Fire-Dataset](https://drive.google.com/file/d/1TQKA9nzo0BVwtmojmSusDt5j02KWzIu9/view?usp=sharing) and put it in ```datasets``` folder. This dataset contains samples from both [Fire & Smoke](https://www.kaggle.com/dataclusterlabs/fire-and-smoke-dataset) and [Fire & Guns](https://www.kaggle.com/atulyakumar98/fire-and-gun-dataset) datasets on Kaggle. I filtered out images and annotations that contain smokes & guns as well as images with low resolution, and then changed fire annotation's label in annotation files.
```
python train.py --img 640 --batch 16 --epochs 10 --data ../fire_config.yaml --weights yolov5s.pt --workers 0
```
#### Prediction
If you train your own model, use the following command for detection:
```
python detect.py --source ../input.mp4 --weights runs/train/exp/weights/best.pt --conf 0.2
```
Or you can use the pretrained model located in ```models``` folder for detection as follows:
```
python detect.py --source ../input.mp4 --weights ../models/best.pt --conf 0.2
```
## Results
The following charts were produced after training YOLOv5s with input size 640x640 on the fire dataset for 10 epochs.
| P Curve | PR Curve | R Curve |
| :-: | :-: | :-: |
|  |  |  |
#### Prediction Results
The fire detection results were fairly good even though the model was trained only for a few epochs. However, I observed that the trained model tends to predict red emergency light on top of police car as fire. It might be due to the fact that the training dataset contains only a few hundreds of negative samples. We may fix such problem and further improve the performance of the model by adding images with non-labeled fire objects as negative samples. The [authors](https://github.com/ultralytics/yolov5/wiki/Tips-for-Best-Training-Results) who created YOLOv5 recommend using about 0-10% background images to help reduce false positives.
| Ground Truth | Prediction |
| :-: | :-: |
|  |  |
|  |  |
#### Feature Visualization
It is desirable for AI engineers to know what happens under the hood of object detection models. Visualizing features in deep learning models can help us a little bit understand how they make predictions. In YOLOv5, we can visualize features using ```--visualize``` argument as follows:
```
python detect.py --weights runs/train/exp/weights/best.pt --img 640 --conf 0.2 --source ../datasets/fire/val/images/0.jpg --visualize
```
| Input | Feature Maps |
| :-: | :-: |
|  |  |
## Reference
I borrowed and modified [YOLOv5-Custom-Training.ipynb](https://github.com/ultralytics/yolov5/wiki/Train-Custom-Data) script for training YOLOv5 model on the fire dataset. For more information on training YOLOv5, please refer to its homepage.
* https://github.com/robmarkcole/fire-detection-from-images
* https://github.com/ultralytics/yolov5
* https://github.com/AlexeyAB/darknet
没有合适的资源?快使用搜索试试~ 我知道了~
使用yolov5实现火灾图像识别的代码+数据集+模型

共19个文件
png:6个
jpg:5个
md:2个

1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 99 浏览量
2023-09-20
16:59:54
上传
评论 1
收藏 30.45MB ZIP 举报
温馨提示
使用yolov5实现火灾图像识别的代码+数据集+模型 根据datasets文件里的下载链接下载数据集,然后进行训练 python train.py --img 640 --batch 16 --epochs 10 --data ../fire_config.yaml --weights yolov5s.pt --workers 0
资源推荐
资源详情
资源评论


























收起资源包目录
























共 19 条
- 1
资源评论


云哲-吉吉2021
- 粉丝: 4295
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- 电气自动化施工组织设计方案.doc
- (源码)基于HTML与CSS的前端学习网站.zip
- 社区嵌入式医养结合养老服务综合体实践案例分享.pptx
- 青少年网络安全与新媒介素养调查报告.doc
- 综合布线有线电视系统设计.pptx
- 项目管理学习题与答案.docx
- 信息安全风险评估检查流程操作系统安全评估检查表HPUNIX.doc
- 软考初级信息处理技术员上半年下午试题及答案.doc
- 用matlab绘制汽车功率平衡图.docx
- 建设工程项目管理重点笔记.doc
- PLC控制在我国热处理设备中的应用与发展.doc
- 亚洲互动传播网络.pptx
- 电子签名系统安全性.doc
- 电子政务与网络微博.ppt
- 2022年系统集成学习归纳.doc
- 项目管理应遵循的八个原则.doc
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制
