计算机视觉交流群:677855967,欢迎大家加入交流。
继上一篇博文https://blog.csdn.net/yuanlunxi/article/details/84673425分析了hardexample mining之后,我们留下了一个问题,就是为何ssd检测模型训练过程中会出现正负样本为0的情况?在查阅了一番资料之后,今天决定把这个问题杀了祭天,不正之处,多拍板转。
要弄清楚这个问题,首先我们必须清楚ssd检测模型的中match策略:照例,先看论文找原理;再去源码看实现细节。
论文原理:很简短的一个介绍:
译文:在生成的anchor和gt box中,match分两步:1:对所有的gtbox选择与它iou最大的anchor(default box)进行匹配;2:对所有的anchor,选择任何与它iou大于0.5的gtbox进行匹配。
这里思考个问题:当一个anchor与两个gtbox的iou阈值大于0.5时,这个anchor是如何match的呢?
带着这个问题我们去看看源码:SSD训练时选择是ArgMaxMatcher()这个类:看一下这个累的源码:也可以戳 argmax_matcher.py
class ArgMaxMatcher(matcher.Matcher):
"""Matcher based on highest value.
This class computes matches from a similarity matrix. Each column is matched
to a single row.
To support object detection target assignment this class enables setting both
matched_threshold (upper threshold) and unmatched_threshold (lower thresholds)
defining three categories of similarity which define whether examples are
positive, negative, or ignored:
(1) similarity >= matched_threshold: Highest similarity. Matched/Positive!
(2) matched_threshold > similarity >= unmatched_threshold: Medium similarity.
Depending on negatives_lower_than_unmatched, this is either
Unmatched/Negative OR Ignore.
(3) unmatched_threshold > similarity: Lowest similarity. Depending on flag
negatives_lower_than_unmatched, either Unmatched/Negative OR Ignore.
For ignored matches this class sets the values in the Match object to -2.
"&