用yolov5做人脸检测的数据集下输入分别率是224在stride分别为32168下的anchors是多少
由于yolov5默认使用COCO数据集的anchors,因此需要先计算COCO数据集中人脸的平均宽度和高度。根据统计,COCO数据集中人脸的平均宽度为0.15,平均高度为0.25。
在输入分辨率为224的情况下,stride分别为32,16,8时,对应的网格大小为7x7,14x14,28x28,因此需要计算每个网格的anchors。
对于每个网格,yolov5使用3个anchors进行预测,因此需要计算每个网格的3个anchors的宽度和高度。根据yolov5的公式,每个anchor的宽度和高度分别为:
width = anchor_scale * sqrt(anchor_ratio) height = anchor_scale / sqrt(anchor_ratio)
其中,anchor_scale是预设的尺度,anchor_ratio是预设的长宽比。
按照yolov5的默认设置,anchor_scale取值为[1.0, 1.0, 2.0, 0.5, 0.5],anchor_ratio取值为[1.0, 0.5, 2.0]。因此,对于每个网格,可以计算出3个anchors的宽度和高度。
以stride为32的情况为例,对于每个网格,需要计算3个anchors的宽度和高度。假设当前网格的左上角坐标为(x, y),则第一个anchor的中心坐标为(x+0.5, y+0.5),第二个anchor的中心坐标为(x+1.5, y+0.5),第三个anchor的中心坐标为(x+2.5, y+0.5)。对于每个anchor,可以计算出其宽度和高度,然后将宽度和高度按照COCO数据集中人脸的平均宽度和高度进行缩放。
具体地,第一个anchor的宽度和高度为:
width_1 = 1.0 * sqrt(1.0) * 0.15 / 224 * 32 = 0.023 height_1 = 1.0 / sqrt(1.0) * 0.25 / 224 * 32 = 0.036
第二个anchor的宽度和高度为:
width_2 = 1.0 * sqrt(0.5) * 0.15 / 224 * 32 = 0.016 height_2 = 1.0 / sqrt(0.5) * 0.25 / 224 * 32 = 0.050
第三个anchor的宽度和高度为:
width_3 = 1.0 * sqrt(2.0) * 0.15 / 224 * 32 = 0.032 height_3 = 1.0 / sqrt(2.0) * 0.25 / 224 * 32 = 0.025
因此,stride为32时,每个网格的3个anchors的宽度和高度分别为:
anchor 1: width=0.023, height=0.036 anchor 2: width=0.016, height=0.050 anchor 3: width=0.032, height=0.025
同样的方式可以计算出stride为16和8时每个网格的3个anchors的宽度和高度。
原文地址: https://www.cveoy.top/t/topic/bQvr 著作权归作者所有。请勿转载和采集!