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

Commit 78c29fc

Browse files
committed
Support fpn
1 parent 8a3bd80 commit 78c29fc

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

detectron/modeling/FPN.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ def add_topdown_lateral_module(
293293
bias_init=const_fill(0.0)
294294
)
295295
# Top-down 2x upsampling
296-
td = model.net.UpsampleNearest(fpn_top, fpn_bottom + '_topdown', scale=2)
296+
td = model.net.ResizeNearest(fpn_top, fpn_bottom + '_topdown', width_scale=2., height_scale=2.)
297297
# Sum lateral and top-down
298298
model.net.Sum([lat, td], fpn_bottom)
299299

tools/convert_pkl_to_pb.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,17 @@ def convert_gen_proposals(
172172
spatial_scale = mutils.get_op_arg_valf(op, 'spatial_scale', None)
173173
assert spatial_scale is not None
174174

175+
lvl = int(op.input[0][-1]) if op.input[0][-1].isdigit() else None
176+
175177
inputs = [x for x in op.input]
176-
anchor_name = 'anchor'
178+
anchor_name = 'anchor{}'.format(lvl) if lvl else 'anchor'
177179
inputs.append(anchor_name)
178-
blobs[anchor_name] = get_anchors(spatial_scale)
180+
blobs[anchor_name] = \
181+
get_anchors(
182+
spatial_scale,
183+
(cfg.FPN.RPN_ANCHOR_START_SIZE * 2.**(lvl - cfg.FPN.RPN_MIN_LEVEL),)
184+
) \
185+
if lvl else get_anchors(spatial_scale, cfg.RPN.SIZES)
179186
print('anchors {}'.format(blobs[anchor_name]))
180187

181188
ret = core.CreateOperator(
@@ -192,10 +199,10 @@ def convert_gen_proposals(
192199
return ret, anchor_name
193200

194201

195-
def get_anchors(spatial_scale):
202+
def get_anchors(spatial_scale, anchor_sizes):
196203
anchors = generate_anchors.generate_anchors(
197204
stride=1. / spatial_scale,
198-
sizes=cfg.RPN.SIZES,
205+
sizes=anchor_sizes,
199206
aspect_ratios=cfg.RPN.ASPECT_RATIOS).astype(np.float32)
200207
return anchors
201208

0 commit comments

Comments
 (0)