detection代码位于code\SSD_pytorch-master\layers\functions\detection.py
在代码中定义了Detect类用于对结果进行解码。在代码中有注释
At test time, Detect is the final layer of SSD
也就是,detect只用于在预测中,是SSD的最后一层。它的作用有以下几点:
1)Decode location preds,解码预测框位置
2)apply non-maximum suppression to location predictions based on conf scores and threshold to a top_k number of output predictions for both confidence score and locations.
根据阈值过滤类别置信度,使用NMS算法定位预测框。最后根据top_k输出最后的预测结果。
在def init()中初始化了阈值等参数
然后看def forward
首先,它传入的参数 loc_data, conf_data, prior_data是ssd.py也就是训练过程中产生的loc,conf的预测值和prior boxes的信息。怎么从训练到预测呢?训练的时候学习到哪些参数,预测的时候怎么用?
priorbox是将每个特征图中得到的priorbox的坐标以中心偏移量的形式表现出来。
理解这个要先理解encode和decode函数
decode函数用于从预测中使用先验对在训练时为偏移量回归所做编码进行解码,它的输入是loc,reg的预测以及prior的信息,输出是解码后的边框预测信息这里的variances用于???