README.md 8.3 KB
Newer Older
Eric.Lee2021's avatar
update  
Eric.Lee2021 已提交
1
# YOLO V3
Eric.Lee2021's avatar
update  
Eric.Lee2021 已提交
2
物体检测,包括手部检测、人脸检测、人检测、安全帽检测,交通工具检测,因为数据集的独立所以分别为5个独立模型。  
Eric.Lee2021's avatar
update  
Eric.Lee2021 已提交
3

Eric.Lee2021's avatar
update  
Eric.Lee2021 已提交
4 5 6
## 项目介绍    
### 1、手部检测  
手部检测示例如下 :    
Eric.Lee2021's avatar
update  
Eric.Lee2021 已提交
7
* 图片示例:  
Eric.Lee2021's avatar
Eric.Lee2021 已提交
8
![image](samples/sample.png)    
Eric.Lee2021's avatar
update  
Eric.Lee2021 已提交
9
* 视频示例:  
Eric.Lee2021's avatar
Eric.Lee2021 已提交
10
![video](samples/sample.gif)    
Eric.Lee2021's avatar
update  
Eric.Lee2021 已提交
11

Eric.Lee2021's avatar
update  
Eric.Lee2021 已提交
12 13
* 相关拓展应用的手的21关键点检测回归的项目地址:https://codechina.csdn.net/EricLee/handpose_x
* 手部检测+21点手关键点完整pipeline的项目地址:https://codechina.csdn.net/EricLee/dpcas
Eric.Lee2021's avatar
update  
Eric.Lee2021 已提交
14 15 16
### 2、脸部检测  
脸部检测示例如下 :     
* 视频示例:    
Eric.Lee2021's avatar
Eric.Lee2021 已提交
17
![videoface](samples/face.gif)    
Eric.Lee2021's avatar
update  
Eric.Lee2021 已提交
18

Eric.Lee2021's avatar
Eric.Lee2021 已提交
19
### 3、人检测  
Eric.Lee2021's avatar
update  
Eric.Lee2021 已提交
20 21
人检测示例如下 :      
* 视频示例:     
Eric.Lee2021's avatar
Eric.Lee2021 已提交
22
![videoPerson](samples/person.gif)      
Eric.Lee2021's avatar
Eric.Lee2021 已提交
23

Eric.Lee2021's avatar
Eric.Lee2021 已提交
24 25
### 4、安全帽检测    
安全帽检测示例如下 :      
Eric.Lee2021's avatar
update  
Eric.Lee2021 已提交
26
* 视频示例:   
Eric.Lee2021's avatar
Eric.Lee2021 已提交
27
![videoHat](samples/hat.gif)      
Eric.Lee2021's avatar
Eric.Lee2021 已提交
28

Eric.Lee2021's avatar
update  
Eric.Lee2021 已提交
29 30
### 5、交通工具检测
包括:bicycle,car,motorcycle,airplane,bus,train,truck,boat     
Eric.Lee2021's avatar
Eric.Lee2021 已提交
31
示例如下 :      
Eric.Lee2021's avatar
update  
Eric.Lee2021 已提交
32
* 视频示例:  
Eric.Lee2021's avatar
Eric.Lee2021 已提交
33
![auto](samples/auto.gif)    
Eric.Lee2021's avatar
Eric.Lee2021 已提交
34

Eric.Lee2021's avatar
Eric.Lee2021 已提交
35 36 37
### 6、左右手检测
示例如下 :      
* 视频示例:  
Eric.Lee2021's avatar
Eric.Lee2021 已提交
38
![LR_hand](samples/LR_hand.gif)    
Eric.Lee2021's avatar
Eric.Lee2021 已提交
39

Eric.Lee2021's avatar
update  
Eric.Lee2021 已提交
40 41 42 43 44 45
## 项目配置  
* 作者开发环境:  
* Python 3.7  
* PyTorch >= 1.5.1  

## 数据集   
Eric.Lee2021's avatar
update  
Eric.Lee2021 已提交
46
### 1、手部检测数据集   
Eric.Lee2021's avatar
Eric.Lee2021 已提交
47
该项目数据集采用 TV-Hand 和 COCO-Hand (COCO-Hand-Big 部分) 进行制作。  
Eric.Lee2021's avatar
update  
Eric.Lee2021 已提交
48 49
TV-Hand 和 COCO-Hand数据集官网地址 http://vision.cs.stonybrook.edu/~supreeth/   
```   
Eric.Lee2021's avatar
update  
Eric.Lee2021 已提交
50 51 52
感谢数据集贡献者。    
Paper:  
Contextual Attention for Hand Detection in the Wild. S. Narasimhaswamy, Z. Wei, Y. Wang, J. Zhang, and M. Hoai, IEEE International Conference on Computer Vision, ICCV 2019.   
Eric.Lee2021's avatar
update  
Eric.Lee2021 已提交
53
```
Eric.Lee2021's avatar
update  
Eric.Lee2021 已提交
54
* [该项目制作的训练集的数据集下载地址(百度网盘 Password: c680 )](https://pan.baidu.com/s/1H0YH8jMEXeIcubLEv0W_yw)   
Eric.Lee2021's avatar
update  
Eric.Lee2021 已提交
55 56

### 2、脸部检测数据集   
Eric.Lee2021's avatar
Eric.Lee2021 已提交
57
该项目采用的是开源数据集 WIDERFACE,其地址为 http://shuoyang1213.me/WIDERFACE/  
Eric.Lee2021's avatar
Eric.Lee2021 已提交
58 59
```  
@inproceedings{yang2016wider,
Eric.Lee2021's avatar
Eric.Lee2021 已提交
60 61 62 63
Author = {Yang, Shuo and Luo, Ping and Loy, Chen Change and Tang, Xiaoou},
Booktitle = {IEEE Conference on Computer Vision and Pattern Recognition (CVPR)},
Title = {WIDER FACE: A Face Detection Benchmark},
Year = {2016}}
Eric.Lee2021's avatar
Eric.Lee2021 已提交
64 65
```  
* [该项目制作的训练集的数据集下载地址(百度网盘 Password: r77x )](https://pan.baidu.com/s/1Jsm1qPPzAW46LRW5nUClzQ)   
Eric.Lee2021's avatar
update  
Eric.Lee2021 已提交
66

Eric.Lee2021's avatar
Eric.Lee2021 已提交
67
### 3、人检测数据集     
Eric.Lee2021's avatar
update  
Eric.Lee2021 已提交
68
该项目采用的是开源数据集 COCO ,其地址为 https://cocodataset.org/   
Eric.Lee2021's avatar
Eric.Lee2021 已提交
69
* [该项目制作的训练集的数据集下载地址(百度网盘 Password: ilv9 )](https://pan.baidu.com/s/1Y1LA8Coc902zrDgmVqAU3A)      
Eric.Lee2021's avatar
Eric.Lee2021 已提交
70

Eric.Lee2021's avatar
Eric.Lee2021 已提交
71 72 73 74
### 4、安全帽检测数据集     
该项目采用的是数据集 VOC2028 ,其地址为 https://github.com/njvisionpower/Safety-Helmet-Wearing-Dataset     
* [该项目制作的训练集的数据集下载地址(百度网盘 Password: y694 )](https://pan.baidu.com/s/1m1ysN5r0wYlIUY6FW1XkHg)      

Eric.Lee2021's avatar
update  
Eric.Lee2021 已提交
75 76
### 5、交通工具数据集  
该项目采用的是开源数据集 COCO ,其地址为 https://cocodataset.org/   
Eric.Lee2021's avatar
Eric.Lee2021 已提交
77
* [该项目制作的训练集的数据集下载地址(百度网盘 Password: pz64 )](https://pan.baidu.com/s/1rDFmWgeUiBaU_1DT917DwA)    
Eric.Lee2021's avatar
update  
Eric.Lee2021 已提交
78 79 80 81 82 83 84 85 86 87 88 89
  该项目制作数据集类型及对应的实例数量如下所示:  
```
  bicycle : 4955
  car : 30785
  motorcycle : 6021
  airplane : 3833
  bus : 4327
  train : 3159
  truck : 7050
  boat : 7590
```

Eric.Lee2021's avatar
update  
Eric.Lee2021 已提交
90 91
### 6、DeepFashion2数据集
* 数据集的描述和申请地址:https://github.com/switchablenorms/DeepFashion2
E
Eric.Lee 已提交
92 93
### 7、左右手检测数据集
* 获取数据集地址 : http://fouheylab.eecs.umich.edu/~dandans/projects/100DOH/  
Eric.Lee2021's avatar
update  
Eric.Lee2021 已提交
94
### 所有数据集的数据格式  
Eric.Lee2021's avatar
Eric.Lee2021 已提交
95
size是全图分辨率, (x,y) 是目标物体中心对于全图的归一化坐标,w,h是目标物体边界框对于全图的归一化宽、高。   
Eric.Lee2021's avatar
update  
Eric.Lee2021 已提交
96

Eric.Lee2021's avatar
update  
Eric.Lee2021 已提交
97 98 99 100 101 102 103 104 105 106 107 108
```  
dw = 1./(size[0])  
dh = 1./(size[1])  
x = (box[0] + box[1])/2.0 - 1  
y = (box[2] + box[3])/2.0 - 1  
w = box[1] - box[0]  
h = box[3] - box[2]  
x = x*dw  
w = w*dw  
y = y*dh  
h = h*dh  
```  
Eric.Lee2021's avatar
update  
Eric.Lee2021 已提交
109

Eric.Lee2021's avatar
update  
Eric.Lee2021 已提交
110
为了更好了解标注数据格式,可以通过运行 show_yolo_anno.py 脚本进行制作数据集的格式。注意配置脚本里的path和path_voc_names,path为标注数据集的相关文件路径,path_voc_names为数据集配置文件。
Eric.Lee2021's avatar
update  
Eric.Lee2021 已提交
111
### 制作自己的训练数据集
Eric.Lee2021's avatar
update  
Eric.Lee2021 已提交
112
* 如下所示,每一行代表一个物体实例,第一列是标签,后面是归一化的中心坐标(x,y),和归一化的宽(w)和高(h),且每一列信息空格间隔。归一化公式如上,同时可以通过show_yolo_anno.py进行参数适配后,可视化验证其正确性。
Eric.Lee2021's avatar
update  
Eric.Lee2021 已提交
113 114 115 116 117 118 119 120 121
```
label     x                  y                   w                  h
0 0.6200393316313977 0.5939000244140625 0.17241466452130497 0.14608001708984375
0 0.38552491996544863 0.5855700073242187 0.14937006832733554 0.1258599853515625
0 0.32889763138738515 0.701989990234375 0.031338589085055775 0.0671400146484375
0 0.760577424617577 0.69422998046875 0.028556443261975064 0.0548599853515625
0 0.5107086662232406 0.6921500244140625 0.018792660530470802 0.04682000732421875
0 0.9295538153861138 0.67602001953125 0.03884511231750328 0.01844000244140625
```
Eric.Lee2021's avatar
update  
Eric.Lee2021 已提交
122 123

## 预训练模型   
Eric.Lee2021's avatar
Eric.Lee2021 已提交
124 125 126 127
### 1、COCO 预训练模型  
* [预训练模型下载地址(百度网盘 Password: egdg )](https://pan.baidu.com/s/1KTvktMA38lsVYUjQ0sh5HQ)     

### 2、手部检测预训练模型    
128
* 包括yolo预训练模型图像输入尺寸416,yolo-tiny预训练模型图像输入尺寸为512。  
Eric.Lee2021's avatar
Eric.Lee2021 已提交
129
* [预训练模型下载地址(百度网盘 Password: 7mk0 )](https://pan.baidu.com/s/1hqzvz0MeFX0EdpWXUV6aFg)     
Eric.Lee2021's avatar
update  
Eric.Lee2021 已提交
130

Eric.Lee2021's avatar
Eric.Lee2021 已提交
131
### 3、脸部检测预训练模型    
Eric.Lee2021's avatar
Eric.Lee2021 已提交
132 133
* [预训练模型下载地址(百度网盘 Password: l2a3 )](https://pan.baidu.com/s/1xVtZUMD94DiT9FQQ66xG1A)     

Eric.Lee2021's avatar
Eric.Lee2021 已提交
134
### 4、人检测预训练模型    
Eric.Lee2021's avatar
Eric.Lee2021 已提交
135 136
* [预训练模型下载地址(百度网盘 Password: ise9 )](https://pan.baidu.com/s/1mxiI-tOpE3sU-9TVPJmPWw)     

Eric.Lee2021's avatar
Eric.Lee2021 已提交
137
### 5、安全帽检测预训练模型    
Eric.Lee2021's avatar
add  
Eric.Lee2021 已提交
138 139
* [预训练模型下载地址(百度网盘 Password: inu8 )](https://pan.baidu.com/s/1rWUEsPnOTdmfJW4xM8m3Eg)    

Eric.Lee2021's avatar
Eric.Lee2021 已提交
140
### 6、交通工具预训练模型
141
* [预训练模型下载地址(百度网盘 Password: 9qlx )](https://pan.baidu.com/s/1IwTnQYulFetY-AS1woMMaQ)   
Eric.Lee2021's avatar
update  
Eric.Lee2021 已提交
142

143 144 145 146
### 7、左右手检测-预训练模型
* [预训练模型下载地址(百度网盘 Password: 3ae7 )](https://pan.baidu.com/s/1aMXMKWe6ehHUBab2rJM3hg)   

### 8、DeepFashion2预训练模型
Eric.Lee2021's avatar
update  
Eric.Lee2021 已提交
147 148
* [预训练模型下载地址(百度网盘 Password:  )]()    
* DeepFashion2 包括13类物体,具体cfg分类如下,该预训练模型对应的标签编号从上到下为 ( 0~12 ) :
Eric.Lee2021's avatar
update  
Eric.Lee2021 已提交
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
```
short_sleeve_top
long_sleeve_top
short_sleeve_outwear
long_sleeve_outwear
vest
sling
shorts
trousers
skirt
short_sleeve_dress
long_sleeve_dress
vest_dress
sling_dress
```

Eric.Lee2021's avatar
update  
Eric.Lee2021 已提交
165
## 项目使用方法     
Eric.Lee2021's avatar
update  
Eric.Lee2021 已提交
166

Eric.Lee2021's avatar
update  
Eric.Lee2021 已提交
167 168
### 数据集可视化    
* 根目录下运行命令: show_yolo_anno.py   (注意脚本内相关参数配置 )   
Eric.Lee2021's avatar
update  
Eric.Lee2021 已提交
169

Eric.Lee2021's avatar
update  
Eric.Lee2021 已提交
170 171
### 模型训练     
* 根目录下运行命令: python train.py     (注意脚本内相关参数配置 )   
Eric.Lee2021's avatar
update  
Eric.Lee2021 已提交
172

173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197
* 注意:加载训练的配置参数的关键代码段如下,cfg/transport.data为训练coco交通工具数据集的配置参数文件。
```
if __name__ == '__main__':
    train(data_cfg = "cfg/transport.data")
```

* cfg文件夹下的 "*.data"文件包含了重要的配置信息,以"cfg/transport.data"为例如下:
```
cfg_model=yolo # 模型选择:yolo  / yolo tiny
classes=8 # 数据集的类别
gpus = 0 # GPU 的选择
num_workers = 8 # 训练时数据迭代(增强)器的进程数
batch_size = 8 # 训练时每一个批次的图片量设定,该例子是8张图片
img_size = 416 # 模型的默认输入图片尺寸是 416*416
multi_scale = True # 是否在训练中采用多尺度增强方式,该例子为使用
epochs = 100 # 训练总周期,完整遍历一次数据集为一个周期
train=./yolo_transport_train/anno/train.txt # 训练集的train.txt路径
valid=./yolo_transport_train/anno/train.txt # 验证集的train.txt路径,目前训练代码中并没有加入验证功能代码
names=./cfg/transport.names # 该数据集对应的具体分类名字,需要与其标签对应
finetune_model = ./weights-yolov3-transport/latest_416.pt # 采用的预训练模型
lr_step = 10,20,30 # 训练时对应的特定epoch时更新学习率
lr0 = 0.001 # 训练时的初始化学习率

```

Eric.Lee2021's avatar
update  
Eric.Lee2021 已提交
198
### 模型推理    
Eric.Lee2021's avatar
update  
Eric.Lee2021 已提交
199
* 根目录下运行命令: python predict.py   (注意脚本内相关参数配置  )