在训练yolov5的时候输出:
analyzing anchors . bestpossiblerecall (BPR )=0.8838.attemptingtogenerateimprovedanchors,please wait .
warning : extremelysmallobjectsfound.2274 of 14719 labelsare4pixelsinwidthorheight。
runningkmeansfor9anchors on 14700 points .
thr=0. 25:9927 bestpossiblerecall,5.10 anchors past thr
n=9,img_size=480,metric _ all=0.348/0.766-mean/best,past _ thr=0.515-mean 336010,3,18,6,24
evolvinganchorswithgeneticalgorithm 3360 fitness=0.78553360100 %|(() )
thr=0. 25:9972 bestpossiblerecall,5.23 anchors past thr
n=9,img_size=480,metric _ all=0.358/0.785-mean/best,past _ thr=0.524-mean 336011,2,16,5,22
newanchorssavedtomodel.updatemodel *.yamltousetheseanchorsinthefuture。
您可以在train.py的line206 check_anchors函数中找到此函数。 check_anchors函数位于utils/general.py中。
Yolov5最初在模型配置文件(如yolov5l.py )中具有缺省anchors。 这些anchors是基于COCO数据集,以640640的图像大小来定位框架的大小。 Yolov5会自动根据新数据集的labels自动了解anchors的大小。 利用k均值和遗传学习算法分析自定义数据集,得到适合于自定义数据集内对象边界框预测的预设锚帧。
首先计算bestpossiblerecall(BPR )
再用kmean_anchors函数进行k均值和遗传学习算法更新anchors。