Commit e2594f17 authored by Kai Chen's avatar Kai Chen
Browse files

Merge branch 'master' into registry

parents bbe64038 e72a9fd5
...@@ -69,7 +69,7 @@ class MaxIoUAssigner(BaseAssigner): ...@@ -69,7 +69,7 @@ class MaxIoUAssigner(BaseAssigner):
if bboxes.shape[0] == 0 or gt_bboxes.shape[0] == 0: if bboxes.shape[0] == 0 or gt_bboxes.shape[0] == 0:
raise ValueError('No gt or bboxes') raise ValueError('No gt or bboxes')
bboxes = bboxes[:, :4] bboxes = bboxes[:, :4]
overlaps = bbox_overlaps(bboxes, gt_bboxes) overlaps = bbox_overlaps(gt_bboxes, bboxes)
if (self.ignore_iof_thr > 0) and (gt_bboxes_ignore is not None) and ( if (self.ignore_iof_thr > 0) and (gt_bboxes_ignore is not None) and (
gt_bboxes_ignore.numel() > 0): gt_bboxes_ignore.numel() > 0):
...@@ -98,19 +98,18 @@ class MaxIoUAssigner(BaseAssigner): ...@@ -98,19 +98,18 @@ class MaxIoUAssigner(BaseAssigner):
if overlaps.numel() == 0: if overlaps.numel() == 0:
raise ValueError('No gt or proposals') raise ValueError('No gt or proposals')
num_bboxes, num_gts = overlaps.size(0), overlaps.size(1) num_gts, num_bboxes = overlaps.size(0), overlaps.size(1)
# 1. assign -1 by default # 1. assign -1 by default
assigned_gt_inds = overlaps.new_full( assigned_gt_inds = overlaps.new_full(
(num_bboxes, ), -1, dtype=torch.long) (num_bboxes, ), -1, dtype=torch.long)
assert overlaps.size() == (num_bboxes, num_gts)
# for each anchor, which gt best overlaps with it # for each anchor, which gt best overlaps with it
# for each anchor, the max iou of all gts # for each anchor, the max iou of all gts
max_overlaps, argmax_overlaps = overlaps.max(dim=1) max_overlaps, argmax_overlaps = overlaps.max(dim=0)
# for each gt, which anchor best overlaps with it # for each gt, which anchor best overlaps with it
# for each gt, the max iou of all proposals # for each gt, the max iou of all proposals
gt_max_overlaps, gt_argmax_overlaps = overlaps.max(dim=0) gt_max_overlaps, gt_argmax_overlaps = overlaps.max(dim=1)
# 2. assign negative: below # 2. assign negative: below
if isinstance(self.neg_iou_thr, float): if isinstance(self.neg_iou_thr, float):
...@@ -129,7 +128,7 @@ class MaxIoUAssigner(BaseAssigner): ...@@ -129,7 +128,7 @@ class MaxIoUAssigner(BaseAssigner):
for i in range(num_gts): for i in range(num_gts):
if gt_max_overlaps[i] >= self.min_pos_iou: if gt_max_overlaps[i] >= self.min_pos_iou:
if self.gt_max_assign_all: if self.gt_max_assign_all:
max_iou_inds = overlaps[:, i] == gt_max_overlaps[i] max_iou_inds = overlaps[i, :] == gt_max_overlaps[i]
assigned_gt_inds[max_iou_inds] = i + 1 assigned_gt_inds[max_iou_inds] = i + 1
else: else:
assigned_gt_inds[gt_argmax_overlaps[i]] = i + 1 assigned_gt_inds[gt_argmax_overlaps[i]] = i + 1
......
...@@ -146,6 +146,7 @@ class SSDHead(AnchorHead): ...@@ -146,6 +146,7 @@ class SSDHead(AnchorHead):
self.target_stds, self.target_stds,
cfg, cfg,
gt_labels_list=gt_labels, gt_labels_list=gt_labels,
label_channels=1,
sampling=False, sampling=False,
unmap_outputs=False) unmap_outputs=False)
if cls_reg_targets is None: if cls_reg_targets is None:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment