在我之前的博客中关于车辆检测、无人机航拍车辆检测、遥感车辆检测计数等都有实践性质的文章,感兴趣的话可以看下:
《基于目标检测的无人机航拍场景下小目标检测实践》
《基于YOLOv6m目标检测模型开发构建大雾天气下行人车辆检测识别分析系统》
《基于目标检测实现遥感场景下的车辆检测计数》
这里也是在做车辆相关的检测识别,只不过有两个不同点:
场景不同,这里的场景为红外场景下由无人机航拍获取的数据
目的效果不同,这里主要是开发构建车辆实例分割识别模型
首先看下效果图:
接下来看下数据集:
实例标注数据内容如下:
0 0.175 0.17415730337078653 0.24047619047619048 0.17275280898876405 0.23809523809523808 0.20224719101123595 0.17261904761904762 0.20365168539325842
0 0.1869047619047619 0.2148876404494382 0.25476190476190474 0.21207865168539325 0.25 0.2443820224719101 0.1880952380952381 0.24859550561797752
0 0.18571428571428572 0.2612359550561798 0.25476190476190474 0.25702247191011235 0.2571428571428571 0.2893258426966292 0.18333333333333332 0.29353932584269665
0 0.19166666666666668 0.30337078651685395 0.26785714285714285 0.300561797752809 0.26785714285714285 0.3342696629213483 0.19285714285714287 0.3342696629213483
0 0.2 0.44241573033707865 0.2654761904761905 0.4311797752808989 0.2726190476190476 0.45646067415730335 0.2011904761904762 0.4705056179775281
0 0.20476190476190476 0.48314606741573035 0.2726190476190476 0.4803370786516854 0.2785714285714286 0.5140449438202247 0.20357142857142857 0.5126404494382022
0 0.544047619047619 0.8286516853932584 0.6059523809523809 0.8286516853932584 0.6071428571428571 0.8623595505617978 0.5464285714285714 0.8595505617977528
0 0.5333333333333333 0.7724719101123596 0.6035714285714285 0.7724719101123596 0.6047619047619047 0.8047752808988764 0.5380952380952381 0.8089887640449438
0 0.5357142857142857 0.7219101123595506 0.611904761904762 0.7176966292134831 0.6142857142857143 0.7584269662921348 0.5392857142857143 0.7626404494382022
0 0.5321428571428571 0.6797752808988764 0.6 0.6783707865168539 0.6035714285714285 0.7120786516853933 0.5357142857142857 0.7176966292134831
0 0.5297619047619048 0.6376404494382022 0.5988095238095238 0.6376404494382022 0.5976190476190476 0.672752808988764 0.530952380952381 0.6713483146067416
0 0.5333333333333333 0.523876404494382 0.5928571428571429 0.523876404494382 0.594047619047619 0.5519662921348315 0.5333333333333333 0.5603932584269663
0 0.5297619047619048 0.4789325842696629 0.5916666666666667 0.4789325842696629 0.594047619047619 0.5098314606741573 0.5297619047619048 0.5154494382022472
0 0.5226190476190476 0.43820224719101125 0.5928571428571429 0.43820224719101125 0.5928571428571429 0.4705056179775281 0.5238095238095238 0.47331460674157305
0 0.5226190476190476 0.3946629213483146 0.5976190476190476 0.3960674157303371 0.5988095238095238 0.42837078651685395 0.5226190476190476 0.43820224719101125
0 0.5202380952380953 0.35252808988764045 0.5952380952380952 0.34691011235955055 0.5952380952380952 0.3848314606741573 0.5202380952380953 0.38764044943820225
0 0.5190476190476191 0.24719101123595505 0.5833333333333334 0.24578651685393257 0.5833333333333334 0.2808988764044944 0.5214285714285715 0.2808988764044944
0 0.5142857142857142 0.199438202247191 0.5869047619047619 0.2050561797752809 0.5857142857142857 0.23735955056179775 0.5178571428571429 0.2401685393258427
0 0.5154761904761904 0.15730337078651685 0.5833333333333334 0.1544943820224719 0.5857142857142857 0.1896067415730337 0.5107142857142857 0.1952247191011236
0 0.7047619047619048 0.300561797752809 0.7761904761904762 0.2991573033707865 0.7797619047619048 0.3300561797752809 0.7083333333333334 0.3342696629213483
0 0.6976190476190476 0.34269662921348315 0.7726190476190476 0.34129213483146065 0.7761904761904762 0.37219101123595505 0.6988095238095238 0.3806179775280899
0 0.7011904761904761 0.38764044943820225 0.7797619047619048 0.3848314606741573 0.7785714285714286 0.41713483146067415 0.7071428571428572 0.42696629213483145
0 0.6904761904761905 0.4339887640449438 0.7607142857142857 0.42837078651685395 0.763095238095238 0.46207865168539325 0.6928571428571428 0.4648876404494382
0 0.7023809523809523 0.577247191011236 0.7797619047619048 0.5674157303370787 0.7821428571428571 0.6025280898876404 0.705952380952381 0.6123595505617978
0 0.6988095238095238 0.6460674157303371 0.7773809523809524 0.6348314606741573 0.7821428571428571 0.6699438202247191 0.7035714285714286 0.6769662921348315
0 0.7226190476190476 0.6896067415730337 0.7916666666666666 0.6952247191011236 0.7916666666666666 0.7303370786516854 0.7166666666666667 0.7247191011235955
0 0.8035714285714286 0.6867977528089888 0.8738095238095238 0.7191011235955056 0.8904761904761904 0.6882022471910112 0.8154761904761905 0.6544943820224719
0 0.1988095238095238 0.5351123595505618 0.26785714285714285 0.5337078651685393 0.26904761904761904 0.5688202247191011 0.19523809523809524 0.5646067415730337
0 0.2011904761904762 0.800561797752809 0.2630952380952381 0.7949438202247191 0.26071428571428573 0.8314606741573034 0.20238095238095238 0.8300561797752809
模型配置如下:
#Parameters
nc: 1 # number of classes
depth_multiple: 0.33 # model depth multiple
width_multiple: 0.25 # layer channel multiple
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
#Backbone
backbone:
# [from, number, module, args]
[[-1, 1, Conv, [64, 6, 2, 2]], # 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, 6, 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, 3, C3, [1024]],
[-1, 1, SPPF, [1024, 5]], # 9
]
#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)
]
默认100次的迭代训练,日志输出如下:
接下来看下结果详情:
【F1值曲线】
【PR曲线】
【数据可视化】
【混淆矩阵】
batch计算实例:
模型评估结果如下:
Class Images Instances Box(P R mAP50 mAP50-95) Mask(P R mAP50 mAP50-95): 100%|??????????| 94/94 [01:59<00:00, 1.
all 3000 53267 0.974 0.957 0.988 0.699 0.961 0.94 0.972 0.575
从性能指标上来看效果还是蛮不错的。