'Converts prediction tensors to final detections.
This function converts raw predictions tensors to final detection results by
slicing off the background class, decoding box predictions and applying
non max suppression and clipping to the image window.
See base class for output format conventions.  Note also that by default,
scores are to be interpreted as logits, but if a score_conversion_fn is
used, then scores are remapped (and may thus have a different
interpretation).
Args:
prediction_dict: a dictionary holding prediction tensors with
1) box_encodings: 4-D float tensor of shape [batch_size, num_anchors,
box_code_dimension] containing predicted boxes.
2) class_predictions_with_background: 2-D float tensor of shape
[batch_size, num_anchors, num_classes+1] containing class predictions
(logits) for each of the anchors.  Note that this tensor *includes*
background class predictions.
Returns:
detections: a dictionary containing the following fields
detection_boxes: [batch, max_detection, 4]
detection_scores: [batch, max_detections]
detection_classes: [batch, max_detections]
num_detections: [batch]
Raises:
ValueError: if prediction_dict does not contain `box_encodings` or
`class_predictions_with_background` fields.'

def postprocess(self, prediction_dict):

    if (('box_encodings' not in prediction_dict) or ('class_predictions_with_background' not in prediction_dict)):
        raise ValueError('prediction_dict    does    not    contain    expected    entries.')
    with tf.name_scope('Postprocessor'):
        box_encodings = prediction_dict['box_encodings']
        class_predictions = prediction_dict['class_predictions_with_background']
        detection_boxes = self._batch_decode(box_encodings)
        detection_boxes = tf.expand_dims(detection_boxes, axis=2)
        class_predictions_without_background = tf.slice(class_predictions, [0, 0, 1], [(-1), (-1), (-1)])
        detection_scores = self._score_conversion_fn(class_predictions_without_background)
        clip_window = tf.constant([0, 0, 1, 1], tf.float32)
        (nmsed_boxes, nmsed_scores, nmsed_classes, _, num_detections) = self._non_max_suppression_fn(detection_boxes, detection_scores, clip_window=clip_window)
        return {'detection_boxes': nmsed_boxes, 'detection_scores': nmsed_scores, 'detection_classes': nmsed_classes, 'num_detections': tf.to_float(num_detections)}
