(11-3)基于深度学习的实时地图导航:计算交并比+训练模型

10.5.5  计算交并比

文件metrics.py定义了基于 PyTorch 的交并比(IoU)度量类和 IoU 度量的子类,用于计算预测与标签之间的交并比,并可以根据给定阈值和可见度遮罩进行计算。

class BaseIoUMetric(Metric):
    """
    计算给定阈值下的交并比
    """
    def __init__(self, thresholds=[0.4, 0.5]):
        super().__init__(dist_sync_on_step=False, compute_on_step=False)
 
        thresholds = torch.FloatTensor(thresholds)
 
        self.add_state('thresholds', default=thresholds, dist_reduce_fx='mean')
        self.add_state('tp', de

猜你喜欢

转载自blog.csdn.net/asd343442/article/details/143312676