1 Star 0 Fork 1

ryvius_key / yolov5-smoke-detection-python

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

yolov5-smoke-detection-python

A Python implementation of Yolov5 to detect whether peaple smoking in Jetson Xavier nx and Jetson nano In Jetson Xavier Nx, it can achieve 33 FPS.

You can see video play in BILIBILI, or YOUTUBE.

if you have problem in this project, you can see this CSDN artical.

If you want to try to train your own model, you can see yolov5-smoke-detection-python. Follow the readme to get your own model.

Dataset

https://pan.baidu.com/s/1vmjV1HwhcMOdUqFhKwH4Mg,提取码:pqsv

Data

This pro needs dataset like

../datasets/coco128/images/im0.jpg  #image
../datasets/coco128/labels/im0.txt  #label

Download the dataset and unzip it.

unzip annnotations.zip
unzip images.zip

You can get this.

 ├── dataset
	├── annotations
  │   ├── mask_000001.xml
  │   ├── mask_000002.xml
  │   ├── mask_000003.xml
  │   |   ...
  ├── images
  │   ├── mask_000001.jpg
  │   ├── mask_000003.jpg
  │   ├── mask_000003.jpg
  │   |   ...
  ├── label_list.txt
  ├── train.txt
  └── valid.txt

You should turn xml files to txt files. You also can see this. Open script/sw2yolo.py, Change save_path to your own save path,root as your data path, and list_file as val_list.txt and train_list.txt path.

list_file = "./val_list.txt"
xmls_path,imgs_path = get_file_path(list_file)

# 将train_list中的xml 转成 txt, img放到img中
save_path = './data/yolodata/smoke/cocolike/val/'
root = "./data/yolodata/smoke/"
train_img_root = root 

Then you need script/yolov5-split-label-img.py to split img and txt file.

mkdir images
mkdir lables
mv ./train/images/* ./images/train
mv ./train/labels/* ./labels/train
mv ./val/iamges/* ./images/val
mv ./val/lables/* ./lables/val

Finally You can get this.

 ├── cocolike
	├── lables
  │   ├── val 
  │       ├── smoke_000001.xml
  |       ├──   ...
  │   ├── train
  │       ├── smoke_000002.xml
  |       ├──   ...

  ├── images
  │   ├── val 
  │       ├── smoke_000001.jpg
  |       ├──   ...
  │   ├── train
  │       ├── smoke_000003.jpg
  |       ├──   ...
  ├── label_list.txt
  ├── train.txt
  └── valid.txt

Datafile

{porject}/yolov5/data/ add your own yaml files like smoke.yaml.

# YOLOv5 🚀 by Ultralytics, GPL-3.0 license
# COCO128 dataset https://www.kaggle.com/ultralytics/coco128 (first 128 images from COCO train2017)
# Example usage: python train.py --data coco128.yaml
# parent
# ├── yolov5
# └── datasets
#     └── coco128  downloads here


# Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
path: /home/data/tbw_data/face-dataset/yolodata/smoke/cocolike/  # dataset root dir
train: images/train  # train images (relative to 'path') 128 images
val: images/val  # val images (relative to 'path') 128 images
test:  # test images (optional)

# Classes
nc: 1  # number of classes
names: ['smoke']  # class names

Train

Change {project}/train.py's data path as your own data yaml path. Change batch-size as a suitable num. Change device if you have 2 or more gpu devices. Then

python train.py

Test

Use detect.py to test.

python detect.py --source ./data/yolodata/mask/cocolike/images --weights ./runs/train/exp/weights/best.pt

You can see {project}/runs/detect/ has png results.

MIT License Copyright (c) 2021 RichardoMrMu Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

A Python implementation of Yolov5 to detect whether peaple smoking in Jetson Xavier nx and Jetson nano 展开 收起
Python
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Python
1
https://gitee.com/ryvius_key/yolov5-smoke-detection-python.git
git@gitee.com:ryvius_key/yolov5-smoke-detection-python.git
ryvius_key
yolov5-smoke-detection-python
yolov5-smoke-detection-python
main

搜索帮助

53164aa7 5694891 3bd8fe86 5694891