Skip to content
Snippets Groups Projects
Commit c01ab3b1 authored by Wenwei Zhang's avatar Wenwei Zhang Committed by Kai Chen
Browse files

fix scale factor bug (#1730)

* fix scale factor bug

* reformat

* clean code
parent 8cf2de8a
No related branches found
No related tags found
No related merge requests found
......@@ -155,7 +155,9 @@ class BBoxHead(nn.Module):
if isinstance(scale_factor, float):
bboxes /= scale_factor
else:
bboxes /= torch.from_numpy(scale_factor).to(bboxes.device)
scale_factor = torch.from_numpy(scale_factor).to(bboxes.device)
bboxes = (bboxes.view(bboxes.size(0), -1, 4) /
scale_factor).view(bboxes.size()[0], -1)
if cfg is None:
return bboxes, scores
......
import torch
from mmdet.core import (bbox2roi, bbox_mapping, merge_aug_bboxes,
merge_aug_masks, merge_aug_proposals, multiclass_nms)
......@@ -114,6 +116,9 @@ class MaskTestMixin(object):
else:
# if det_bboxes is rescaled to the original image size, we need to
# rescale it back to the testing scale to obtain RoIs.
if rescale and not isinstance(scale_factor, float):
scale_factor = torch.from_numpy(scale_factor).to(
det_bboxes.device)
_bboxes = (
det_bboxes[:, :4] * scale_factor if rescale else det_bboxes)
mask_rois = bbox2roi([_bboxes])
......
......@@ -159,6 +159,8 @@ class FCNMaskHead(nn.Module):
scale_factor = 1.0
for i in range(bboxes.shape[0]):
if not isinstance(scale_factor, (float, np.ndarray)):
scale_factor = scale_factor.cpu().numpy()
bbox = (bboxes[i, :] / scale_factor).astype(np.int32)
label = labels[i]
w = max(bbox[2] - bbox[0] + 1, 1)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment