我对非最大抑制如何工作的理解是,它抑制了 Jaccard 重叠小于阈值(例如 0.5)的所有重叠框。要考虑的框是有信心的分数(可能是 0.2 或其他东西)。因此,如果有得分超过 0.2 的框(例如得分为 0.3,重叠为 0.4),则不会抑制框。
这样一来,一个物体会被很多个框、一个高分框、很多个低置信度框预测,但是我发现模型对一个物体只预测一个框。有人可以启发我吗?
我目前从https://github.com/sgrvinod/a-PyTorch-Tutorial-to-Object-Detection查看 ssd
这是代码。
#Finding Jaccap Overlap and sorting scotes
class_scores, sort_ind = class_scores.sort(dim=0, descending=True)
class_decoded_locs = class_decoded_locs[sort_ind] # (n_min_score, 4)
overlap = find_jaccard_overlap(class_decoded_locs, class_decoded_locs)
suppress = torch.zeros((n_above_min_score), dtype=torch.uint8).to(device)
for box in range(class_decoded_locs.size(0)):
# If this box is already marked for suppression
if suppress[box] == 1:
continue
suppress = torch.max(suppress, overlap[box] > max_overlap)
suppress[box] = 0