GNU General Public License v3.0

项目介绍

RichardoMrMu/yolov5-helmet-detection-python 是一个托管在 GitHub 上的开源项目,主要使用 Python 编写,采用 GNU General Public License v3.0 许可证,目前获得 29 个 Star、11 次 Fork。

仓库全名
RichardoMrMu/yolov5-helmet-detection-python
开源许可证
GNU General Public License v3.0
Star 数
29
Fork 数
11
未关闭 Issue
3

README 摘要

yolov5-helmet-detection-python A Python implementation of Yolov5 to detect head or helmet in the wild 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 artical. If you want to try to train your own model, you can see yolov5-helmet-detection-python. Follow the readme to get your own…

完整内容见 GitHub 原始 README 或本页 。

常见问题

yolov5-helmet-detection-python 用什么语言开发?

主要使用 Python 编写,采用 GNU General Public License v3.0 许可证,目前有 29 个 Star。

yolov5-helmet-detection-python 可以免费商用吗?

仓库标注的许可证为 GNU General Public License v3.0,商用前请先阅读仓库 LICENSE 文件确认授权范围。

如何获取 yolov5-helmet-detection-python 的源码?

可以直接克隆仓库:git clone https://github.com/RichardoMrMu/yolov5-helmet-detection-python.git,默认分支为 main;安装与运行步骤见仓库 README。

yolov5-helmet-detection-python 最近还在维护吗?

仓库最近一次更新为 2021年11月12日,当前有 3 个未关闭 Issue;Star 数为 29,可作为社区活跃度的参考。

关于

A Python training and inference implementation of Yolov5 helmet detection in Jetson Xavier nx and Jetson nano

描述取自 GitHub 官方 API,中文内容由 GitRead 中文社区 编辑团队整理。

简要分析

热度分
53
价值分
20
活跃状态
活跃

README

yolov5-helmet-detection-python

A Python implementation of Yolov5 to detect head or helmet in the wild 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 artical.

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

Dataset

You can get the dataset from this aistudio url. And the head & helmet detect project pdpd version can be found in this url. It is an amazing project.

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
  │   ├── fire_000001.xml
  │   ├── fire_000002.xml
  │   ├── fire_000003.xml
  │   |   ...
  ├── images
  │   ├── fire_000001.jpg
  │   ├── fire_000003.jpg
  │   ├── fire_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/fire/cocolike/val/'
root = "./data/yolodata/fire/"
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 
  │       ├── fire_000001.xml
  |       ├──   ...
  │   ├── train
  │       ├── fire_000002.xml
  |       ├──   ...
  │   
  ├── images
  │   ├── val 
  │       ├── fire_000001.jpg
  |       ├──   ...
  │   ├── train
  │       ├── fire_000003.jpg
  |       ├──   ...
  ├── label_list.txt
  ├── train.txt
  └── valid.txt

Datafile

{porject}/yolov5/data/ add your own yaml files like helmet.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/helmet/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: 2  # number of classes
names: ['head','helmet']  # 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/helmet/cocolike/images --weights ./runs/train/exp/weights/best.pt

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

评论

暂无评论