交通标识识别在之前的实践中做过,但是用的主要是SSD,比较少接触到yolo系列的模型,这里主要就是想基于YOLO开发构建交通标识检测识别系统,首先看下效果图:
数据集的话主要是来源于互联网采集还有GSRSB等公开数据集的整合。想了解数据集相关的可以查看我之前的文章,这里就不再赘述了。
使用的是s系列的模型开发构建的,如下:
# parameters nc: 80 # number of classes depth_multiple: 0.33 # model depth multiple width_multiple: 0.50 # layer channel multiple # anchors anchors: - [10,13, 16,30, 33,23] # P3/8 - [30,61, 62,45, 59,119] # P4/16 - [116,90, 156,198, 373,326] # P5/32 # YOLOv5 backbone backbone: # [from, number, module, args] [[-1, 1, Focus, [64, 3]], # 0-P1/2 [-1, 1, Conv, [128, 3, 2]], # 1-P2/4 [-1, 3, C3, [128]], [-1, 1, Conv, [256, 3, 2]], # 3-P3/8 [-1, 9, C3, [256]], [-1, 1, Conv, [512, 3, 2]], # 5-P4/16 [-1, 9, C3, [512]], [-1, 1, Conv, [1024, 3, 2]], # 7-P5/32 [-1, 1, SPP, [1024, [5, 9, 13]]], [-1, 3, C3, [1024, False]], # 9 ] # YOLOv5 head head: [[-1, 1, Conv, [512, 1, 1]], [-1, 1, nn.Upsample, [None, 2, 'nearest']], [[-1, 6], 1, Concat, [1]], # cat backbone P4 [-1, 3, C3, [512, False]], # 13 [-1, 1, Conv, [256, 1, 1]], [-1, 1, nn.Upsample, [None, 2, 'nearest']], [[-1, 4], 1, Concat, [1]], # cat backbone P3 [-1, 3, C3, [256, False]], # 17 (P3/8-small) [-1, 1, Conv, [256, 3, 2]], [[-1, 14], 1, Concat, [1]], # cat head P4 [-1, 3, C3, [512, False]], # 20 (P4/16-medium) [-1, 1, Conv, [512, 3, 2]], [[-1, 10], 1, Concat, [1]], # cat head P5 [-1, 3, C3, [1024, False]], # 23 (P5/32-large) [[17, 20, 23], 1, Detect, [nc, anchors]], # Detect(P3, P4, P5) ]
训练数据配置文件如下:
train: dataset/images/train val: dataset/images/val # number of classes nc: 45 # class names names: ["i2","i4","i5","il100","il60","il80","io","ip","p10","p11","p12","p19","p23","p26","p27","p3","p5","p6","pg", "ph4","ph4.5","ph5","pl100","pl120","pl20","pl30","pl40","pl5","pl50","pl60","pl70","pl80","pm20","pm30","pm55", "pn","pne","po","pr40","w13","w32","w55","w57","w59","wo"]
一共有45个类别。
默认设定100次epoch的迭代计算,结果详情如下:
【F1值曲线】
【Precision曲线】
【PR曲线】
【Recall曲线】
训练可视化如下:
batch计算实例如下:
基于yolov5-lite的开发流程与yolov5整体详细,模型文件如下:
# parameters nc: 80 # number of classes depth_multiple: 1.0 # model depth multiple width_multiple: 1.0 # layer channel multiple # anchors anchors: - [ 10,13, 16,30, 33,23 ] # P3/8 - [ 30,61, 62,45, 59,119 ] # P4/16 - [ 116,90, 156,198, 373,326 ] # P5/32 # custom backbone backbone: # [from, number, module, args] [ [ -1, 1, CBH, [ 32, 3, 2 ] ], # 0-P2/4 [ -1, 1, LC_Block, [ 64, 2, 3, False ] ], # 1-P3/8 [ -1, 1, LC_Block, [ 64, 1, 3, False ] ], # 2-P4/16 [ -1, 1, LC_Block, [ 128, 2, 3, False ] ], # 3 [ -1, 1, LC_Block, [ 128, 1, 3, False ] ], # 4-P5/32 [ -1, 1, LC_Block, [ 128, 1, 3, False ] ], # 5 [ -1, 1, LC_Block, [ 128, 1, 3, False ] ], # 6 [ -1, 1, LC_Block, [ 256, 2, 3, False ] ], # 7-P5/32 [ -1, 1, LC_Block, [ 256, 1, 5, False ] ], [ -1, 1, LC_Block, [ 256, 1, 5, False ] ], [ -1, 1, LC_Block, [ 256, 1, 5, False ] ], # 10-P5/32 [ -1, 1, LC_Block, [ 256, 1, 5, False ] ], [ -1, 1, LC_Block, [ 256, 1, 5, False ] ], # 12-P5/32 [ -1, 1, LC_Block, [ 512, 2, 5, True ] ], [ -1, 1, LC_Block, [ 512, 1, 5, True ] ], # 14-P5/32 [ -1, 1, LC_Block, [ 512, 1, 5, True ] ], # 15 [ -1, 1, LC_Block, [ 512, 1, 5, True ] ], # 16 [ -1, 1, Dense, [ 512, 1, 0.2 ] ], ] # v5Lite-c head head: [ [-1, 1, Conv, [256, 1, 1]], # 18 [ -1, 1, nn.Upsample, [ None, 2, 'nearest' ] ], [ [ -1, 12 ], 1, Concat, [ 1 ] ], # cat backbone P4 [-1, 1, C3, [256, False]], # 21 [-1, 1, Conv, [128, 1, 1]], # 22 [ -1, 1, nn.Upsample, [ None, 2, 'nearest' ] ], [ [ -1, 6 ], 1, Concat, [ 1 ] ], # cat backbone P3 [-1, 1, C3, [128, False]], # 25 (P3/8-small) [ -1, 1, LC_Block, [ 128, 2, 5, True ] ], # 26 [ [ -1, 22 ], 1, Concat, [ 1 ] ], # cat head P4 [-1, 1, C3, [256, False]], # 28 (P4/16-medium) [ -1, 1, LC_Block, [ 256, 2, 5, True ] ], # 29 [ [ -1, 18 ], 1, Concat, [ 1 ] ], # cat head P5 [-1, 1, C3, [512, False]], # 31 (P5/32-large) [ [ 25, 28, 31 ], 1, Detect, [ nc, anchors ] ], # Detect(P3, P4, P5) ]
其余的就不再赘述了