Skip to content
This repository has been archived by the owner on Nov 21, 2023. It is now read-only.

Commit

Permalink
Support fpn
Browse files Browse the repository at this point in the history
  • Loading branch information
daquexian committed May 15, 2018
1 parent 8a3bd80 commit 78c29fc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion detectron/modeling/FPN.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def add_topdown_lateral_module(
bias_init=const_fill(0.0)
)
# Top-down 2x upsampling
td = model.net.UpsampleNearest(fpn_top, fpn_bottom + '_topdown', scale=2)
td = model.net.ResizeNearest(fpn_top, fpn_bottom + '_topdown', width_scale=2., height_scale=2.)
# Sum lateral and top-down
model.net.Sum([lat, td], fpn_bottom)

Expand Down
15 changes: 11 additions & 4 deletions tools/convert_pkl_to_pb.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,17 @@ def convert_gen_proposals(
spatial_scale = mutils.get_op_arg_valf(op, 'spatial_scale', None)
assert spatial_scale is not None

lvl = int(op.input[0][-1]) if op.input[0][-1].isdigit() else None

inputs = [x for x in op.input]
anchor_name = 'anchor'
anchor_name = 'anchor{}'.format(lvl) if lvl else 'anchor'
inputs.append(anchor_name)
blobs[anchor_name] = get_anchors(spatial_scale)
blobs[anchor_name] = \
get_anchors(
spatial_scale,
(cfg.FPN.RPN_ANCHOR_START_SIZE * 2.**(lvl - cfg.FPN.RPN_MIN_LEVEL),)
) \
if lvl else get_anchors(spatial_scale, cfg.RPN.SIZES)
print('anchors {}'.format(blobs[anchor_name]))

ret = core.CreateOperator(
Expand All @@ -192,10 +199,10 @@ def convert_gen_proposals(
return ret, anchor_name


def get_anchors(spatial_scale):
def get_anchors(spatial_scale, anchor_sizes):
anchors = generate_anchors.generate_anchors(
stride=1. / spatial_scale,
sizes=cfg.RPN.SIZES,
sizes=anchor_sizes,
aspect_ratios=cfg.RPN.ASPECT_RATIOS).astype(np.float32)
return anchors

Expand Down

0 comments on commit 78c29fc

Please sign in to comment.