import tensorflow as tf

      # the post-processed predictions to generate masks.
      # Generate detections one image at a time.
      class_outputs, box_outputs, box_rois = (
          mask_rcnn_architecture.faster_rcnn_fn(
              fpn_feats, rpn_score_outputs, rpn_box_outputs,
              all_anchors, features['image_info'], params,
              is_training=False))

      batch_size, _, _ = class_outputs.get_shape().as_list()
      detections = []
      softmax_class_outputs = tf.nn.softmax(class_outputs)
      for i in range(batch_size):
        detections.append(
            anchors.generate_detections_per_image_op(
                softmax_class_outputs[i], box_outputs[i], box_rois[i],
                features['source_ids'][i], features['image_info'][i],
                params['test_detections_per_image'],
                params['test_rpn_post_nms_topn'], params['test_nms'],
                params['bbox_reg_weights'])
            )
