Skip to content

Commit

Permalink
Don't send unused variables to RCNN target module
Browse files Browse the repository at this point in the history
  • Loading branch information
vierja committed Jul 5, 2017
1 parent 3a0163f commit 3eedc17
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion frcnn/rcnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def _build(self, pooled_layer, proposals, gt_boxes, im_shape):
bbox_offsets = self._bbox_layer(net)

proposals_target, bbox_target = self._rcnn_target(
proposals, prob, gt_boxes, im_shape)
proposals, gt_boxes)

objects, objects_labels, objects_labels_prob = self._rcnn_proposal(
proposals, bbox_offsets, prob)
Expand Down
22 changes: 18 additions & 4 deletions frcnn/rcnn_target.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,37 @@ def __init__(self, num_classes, name='rcnn_proposal'):
self._background_threshold_high = 0.5
self._background_threshold_low = 0.1

def _build(self, proposals, scores, gt_boxes, im_shape):
def _build(self, proposals, gt_boxes):
"""
Returns:
TODO: Review implementetion with py-faster-rcnn ProposalTargetLayer
TODO: It is possible to have two correct classes for a proposal?
"""
(proposals_label, bbox_targets) = tf.py_func(
self.proposal_target_layer,
[proposals, scores, gt_boxes, im_shape],
[tf.float32] * 2
[proposals, gt_boxes],
[tf.float32, tf.float32]
)

return proposals_label, bbox_targets

def proposal_target_layer(self, proposals, scores, gt_boxes, im_shape):
def proposal_target_layer(self, proposals, gt_boxes):
"""
First we need to calculate the true class of proposals based on gt_boxes.
Args:
proposals:
Shape (num_proposals, 5) -> (batch, x1, y1, x2, y2)
Are assumed to be inside the image.
gt_boxes:
Shape (num_gt, 4) -> (x1, y1, x2, y2)
Returns:
proposals_labels: (-1, 0, label) for each proposal.
Shape (num_proposals,)
bbox_targets: 4d bbox targets.
Shape (num_proposals, 4)
"""
np.random.seed(0) # TODO: For reproducibility.

Expand Down

0 comments on commit 3eedc17

Please sign in to comment.