代码位置: utils\metrics\fitness.py
yolov5默认是在coco上训练的,因此mAP@0.5:0.95权重占比较大
def fitness(x):
# Model fitness as a weighted combination of metrics
w = [0.0, 0.0, 0.1, 0.9] # weights for [P, R, mAP@0.5, mAP@0.5:0.95]
return (x[:, :4] * w).sum(1)
但是实际环境下,我们更多使用mAP@0.5作为度量指标,因此可以调整两者权重占比。
def fitness(x):
# Model fitness as a weighted combination of metrics
w = [0.0, 0.0, 0.9, 0.1] # weights for [P, R, mAP@0.5, mAP@0.5:0.95]
return (x[:, :4] * w).sum(1)