'Adds box predictors to RPN feature map to predict proposals.
Note resulting tensors will not have been postprocessed.
Args:
rpn_box_predictor_features: A 4-D float32 tensor with shape
[batch, height, width, depth] to be used for predicting proposal boxes
and corresponding objectness scores.
Returns:
box_encodings: 3-D float tensor of shape
[batch_size, num_anchors, self._box_coder.code_size] containing
predicted boxes.
objectness_predictions_with_background: 3-D float tensor of shape
[batch_size, num_anchors, 2] containing class
predictions (logits) for each of the anchors.  Note that this
tensor *includes* background class predictions (at class index 0).
Raises:
RuntimeError: if the anchor generator generates anchors corresponding to
multiple feature maps.  We currently assume that a single feature map
is generated for the RPN.'

def _predict_rpn_proposals(self, rpn_box_predictor_features):

    num_anchors_per_location = self._first_stage_anchor_generator.num_anchors_per_location()
    if (len(num_anchors_per_location) != 1):
        raise RuntimeError('anchor_generator    is    expected    to    generate    anchors    corresponding    to    a    single    feature    map.')
    box_predictions = self._first_stage_box_predictor.predict(rpn_box_predictor_features, num_anchors_per_location[0], scope=self.first_stage_box_predictor_scope)
    box_encodings = box_predictions[box_predictor.BOX_ENCODINGS]
    objectness_predictions_with_background = box_predictions[box_predictor.CLASS_PREDICTIONS_WITH_BACKGROUND]
    return (tf.squeeze(box_encodings, axis=2), objectness_predictions_with_background)
