Skip to content

Commit

Permalink
add compatibility in other dataset.
Browse files Browse the repository at this point in the history
  • Loading branch information
unsky authored Jan 11, 2018
1 parent 1df9451 commit 2f3e5c3
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/rpn/proposal_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,22 @@ def forward(self, bottom, top):
if len(keep) < post_nms_topN:
pad = npr.choice(keep, size=post_nms_topN - len(keep))
keep = np.hstack((keep, pad))

# pad to ensure output size remains unchanged
if len(keep) < post_nms_topN:
try:
pad = npr.choice(keep, size=post_nms_topN - len(keep))
except:
proposals = np.zeros((post_nms_topN, 4), dtype=np.float32)
proposals[:,2] = 16
proposals[:,3] = 16
batch_inds = np.zeros((proposals.shape[0], 1), dtype=np.float32)
blob = np.hstack((batch_inds, proposals.astype(np.float32, copy=False)))
top[0].reshape(*(blob.shape))
top[0].data[...] = blob
return
keep = np.hstack((keep, pad))

proposals = proposals[keep, :]
scores = scores[keep]

Expand Down

0 comments on commit 2f3e5c3

Please sign in to comment.