Skip to content

Commit

Permalink
Allow overriding "regresion weights" used in GenerateProposalsOp
Browse files Browse the repository at this point in the history
Summary:
Detectron code is inconsistent about when it uses (1, 1, 1, 1) as the
regression weights vs. `cfg.MODEL.BBOX_REG_WEIGHTS` (which has a default
value of (10, 10, 5, 5)). This change allows the caller to make the call
(heh!) about what to use.

Reviewed By: rbgirshick

Differential Revision: D9981875

fbshipit-source-id: 8798408bd2592486eb1a2e40ccb70b9bedfdbf46
  • Loading branch information
ashwinb authored and facebook-github-bot committed Sep 21, 2018
1 parent 3a4f2b5 commit e8942c8
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions detectron/ops/generate_proposals.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,17 @@
class GenerateProposalsOp(object):
"""Output object detection proposals by applying estimated bounding-box
transformations to a set of regular boxes (called "anchors").
See comment in utils/boxes:bbox_transform_inv for details abouts the
optional `reg_weights` parameter.
"""

def __init__(self, anchors, spatial_scale, train):
def __init__(self, anchors, spatial_scale, train, reg_weights=(1.0, 1.0, 1.0, 1.0)):
self._anchors = anchors
self._num_anchors = self._anchors.shape[0]
self._feat_stride = 1. / spatial_scale
self._train = train
self._reg_weights = reg_weights

def forward(self, inputs, outputs):
"""See modeling.detector.GenerateProposals for inputs/outputs
Expand Down Expand Up @@ -144,8 +148,7 @@ def proposals_for_one_image(
scores = scores[order]

# Transform anchors into proposals via bbox transformations
proposals = box_utils.bbox_transform(
all_anchors, bbox_deltas, (1.0, 1.0, 1.0, 1.0))
proposals = box_utils.bbox_transform(all_anchors, bbox_deltas, self._reg_weights)

# 2. clip proposals to image (may result in proposals with zero area
# that will be removed in the next step)
Expand Down

0 comments on commit e8942c8

Please sign in to comment.