Skip to content

Commit

Permalink
fix input to nms
Browse files Browse the repository at this point in the history
  • Loading branch information
jhung0 committed Aug 24, 2017
1 parent 682cff4 commit cd06e8b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 3 additions & 2 deletions keras_rcnn/layers/detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ def call(self, x, **kwargs):
# unscale back to raw image space

boxes = rois / metadata[0][2]

import pdb
pdb.set_trace()
# Apply bounding-box regression deltas
pred_boxes = keras_rcnn.backend.bbox_transform_inv(boxes, pred_deltas)

Expand All @@ -61,7 +62,7 @@ def call(self, x, **kwargs):
pred_boxes = keras_rcnn.backend.gather_nd(pred_boxes, keras.backend.concatenate([keras.backend.expand_dims(indices), keras.backend.expand_dims(indices_boxes)], axis=1))
pred_boxes = keras.backend.reshape(pred_boxes, (-1, 4))

indices = keras_rcnn.backend.non_maximum_suppression(pred_boxes, pred_scores_classes, keras.backend.shape(pred_boxes)[1], self.TEST_NMS)
indices = keras_rcnn.backend.non_maximum_suppression(pred_boxes, pred_scores_classes, keras.backend.shape(pred_boxes)[0], self.TEST_NMS)
pred_scores = keras.backend.gather(pred_scores, indices)
pred_boxes = keras.backend.gather(pred_boxes, indices)

Expand Down
6 changes: 5 additions & 1 deletion tests/layers/test_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,9 @@ def test_call(self):

metadata = keras.backend.variable([[224, 224, 1.5]])

proposal_target.call([proposals, pred_boxes, pred_scores, metadata])
boxes, classes = proposal_target.call([proposals, pred_boxes, pred_scores, metadata])

assert keras.backend.eval(boxes).shape == keras.backend.eval(pred_boxes).shape

assert keras.backend.eval(classes).shape == keras.backend.eval(boxes).shape

0 comments on commit cd06e8b

Please sign in to comment.