Top AI Repos — open-source AI, indexed and scored
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Base on YOLOv5 Head Person Helmet Detection on Construction Sites,基于目标检测工地安全帽和禁入危险区域识别系统,🚀😆附 YOLOv5 训练自己的数据集超详细教程🚀😆2021.3新增可视化界面❗❗
| Date | Stars |
|---|---|
| 2026-07-24 | 2616 |
| 2026-07-25 | 2617 |
| 2026-07-28 | 2616 |
| 2026-07-30 | 2617 |
| 2026-08-06 | 2617 |
Today
— stars today
This week
— stars this week
This month
— stars this month
Momentum
0.0
growth rate 0.00%/day
# Smart_Construction
[](https://github.com/PeterH0323/Smart_Construction/stargazers)
**如果帮到您请给个 star :star2::star2::star2:,您的 star:star2: 是我最大的鼓励!**
**如果您觉得我的项目不错,可以将我的 Github 链接随便转发;但如果您想发文章,请将我的 Github 链接放到文章开头的位置,谢谢!开源不易,请尊重每个人的汗水!**
该项目是使用 `YOLOv5 v2.x` 的程序来训练在智能工地安全领域中头盔目标检测的应用
## 可视化界面演示(2021.3 上新!):
:boom::boom::boom:新增可视化界面上线啦!!!!来一波演示!!!:boom::boom::boom:
使用文档: [如何使用可视化工具](./doc/Visualize_Tool_Tutorial.md)
<p align="center">
<img alt="tool_gif" src="./doc/visualize_tool_gif_v2_1.gif" width="55%">
</p>
## 纯图片再来一波演示!
<p align="center">
<img alt="output_1" src="./doc/output_1.jpg" width="45%">
<img alt="output_2" src="./doc/output_2.jpg" width="45%">
</p>
<p align="center">
<img alt="output_3" src="./doc/output_3.jpg" width="45%">
<img alt="output_4" src="./doc/output_4.jpg" width="45%">
</p>
## 指标
### yolov5s 为基础训练,`epoch = 50`
|分类|P|R|mAP0.5|
|---|---|---|---|
|总体|0.884|0.899|0.888|
|人体|0.846|0.893|0.877|
|头|0.889|0.883|0.871|
|安全帽|0.917|0.921|0.917|
对应的**权重文件**:[百度云](https://pan.baidu.com/s/1ELPhtW-Q4G8UqEr4YrV_5A),提取码: `b981`
---
### yolov5m 为基础训练,`epoch = 100`
|分类|P|R|mAP0.5|
|---|---|---|---|
|总体|0.886|0.915|0.901|
|人体|0.844|0.906|0.887|
|头|0.9|0.911|0.9|
|安全帽|0.913|0.929|0.916|
对应的**权重文件**:[百度云](https://pan.baidu.com/s/10hlKrgpxVsw4d_vHnPHwEA),提取码: `psst`
---
### yolov5l 为基础训练,`epoch = 100`
|分类|P|R|mAP0.5|
|---|---|---|---|
|总体|0.892|0.919|0.906|
|人体|0.856|0.914|0.897|
|头|0.893|0.913|0.901|
|安全帽|0.927|0.929|0.919|
对应的**权重文件**:[百度云](https://pan.baidu.com/s/1iMZkRNXY1fowpQCcapFDqw),提取码: `a66e`
---
# 1.YOLO v5训练自己数据集教程
使用的数据集:[Safety-Helmet-Wearing-Dataset](https://github.com/njvisionpower/Safety-Helmet-Wearing-Dataset) ,感谢这位大神的开源数据集!
> 本文结合 [YOLOv5官方教程](https://github.com/ultralytics/yolov5/wiki/Train-Custom-Data) 来写
## 环境准备
首先确保自己的环境:
```text
Python>=3.7
Pytorch==1.5.x
PyQt5==5.15.3
PyQtChart==5.15.3
PyQt5-tools
GPUtil
```
或者使用我的环境(推荐)
```shell script
pip install -r requirements.txt
```
## 官方权重
我已上传到一份到百度云:[下载链接](https://pan.baidu.com/s/1mSIjDAzfiJd1fqSxIYzRDA) , 密码: `44qm`
## 训练自己的数据
#### 提示:
**关于增加数据集分类的方法,请看【[5. 增加数据集的分类](#5-增加数据集的分类)】**
---
### 1.1 创建自己的数据集配置文件
因为我这里只是判断 【人没有带安全帽】、【人有带安全帽】、【人体】 3个类别 ,基于 `data/coco128.yaml` 文件,创建自己的数据集配置文件 `custom_data.yaml`
```yaml
# 训练集和验证集的 labels 和 image 文件的位置
train: ./score/images/train
val: ./score/images/val
# number of classes
nc: 3
# class names
names: ['person', 'head', 'helmet']
```
### 1.2 创建每个图片对应的标签文件
你可以使用 `data/gen_data/gen_head_helmet.py` 来将` VOC` 的数据集转换成 `YOLOv5` 训练需要用到的格式。
使用标注工具类似于 [Labelbox](https://labelbox.com/) 、[CVAT](https://github.com/opencv/cvat) 、[精灵标注助手](http://www.jinglingbiaozhu.com/) 标注之后,需要生成每个图片对应的 `.txt` 文件,其规范如下:
- 每一行都是一个目标
- 类别序号是零索引开始的(从0开始)
- 每一行的坐标 `class x_center y_center width height` 格式
- 框坐标必须采用**归一化的 xywh**格式(从0到1)。如果您的框以像素为单位,则将`x_center`和`width`除以图像宽度,将`y_center`和`height`除以图像高度。代码如下:
```python
import numpy as np
def convert(size, box):
"""
将标注的 xml 文件生成的【左上角x,左上角y,右下角x,右下角y】标注转换为yolov5训练的坐标
:param size: 图片的尺寸: [w,h]
:param box: anchor box 的坐标 [左上角x,左上角y,右下角x,右下角y,]
:return: 转换后的 [x,y,w,h]
"""
x1 = int(box[0])
y1 = int(box[1])
x2 = int(box[2])
y2 = int(box[3])
dw = np.float32(1. / int(size[0]))
dh = np.float32(1. / int(size[1]))
w = x2 - x1
h = y2 - y1
x = x1 + (w / 2)
y = y1 + (h / 2)
x = x * dw
w = w * dw
y = y * dh
h = h * dh
return [x, y, w, h]
```
生成的 `.txt` 文件放置的名字是图片的名字,放置在 label 文件夹中,例如:
```text
./score/images/train/00001.jpg # image
./score/labels/train/00001.txt # label
```
生成的 `.txt` 例子:
```text
1 0.1830000086920336 0.1396396430209279 0.13400000636465847 0.15915916301310062
1 0.5240000248886645 0.29129129834473133 0.0800000037997961 0.16816817224025726
1 0.6060000287834555 0.29579580295830965 0.08400000398978591 0.1771771814674139
1 0.6760000321082771 0.25375375989824533 0.10000000474974Excerpt of 8,689 characters
Read on GitHubHinGwenWoong · China
164
Would you bet a product on this? Bounded 0–100 and slow moving.
matched fp:0a29429bceb6b456, topic:object-detection, topic:yolo
matched fp:0a29429bceb6b456, topic:pytorch