def _compute_is_class_correctly_detected_in_image(self,
                                                    detected_boxes,
                                                    detected_scores,
                                                    groundtruth_boxes,
                                                    detected_masks=None,
                                                    groundtruth_masks=None):
    """Compute CorLoc score for a single class.

    Args:
      detected_boxes: A numpy array of shape [N, 4] representing detected box
        coordinates
      detected_scores: A 1-d numpy array of length N representing classification
        score
      groundtruth_boxes: A numpy array of shape [M, 4] representing ground truth
        box coordinates
      detected_masks: (optional) A np.uint8 numpy array of shape [N, height,
        width]. If not None, the scores will be computed based on masks.
      groundtruth_masks: (optional) A np.uint8 numpy array of shape [M, height,
        width].

    Returns:
      is_class_correctly_detected_in_image: An integer 1 or 0 denoting whether a
          class is correctly detected in the image or not
    """
    if detected_boxes.size > 0:
      if groundtruth_boxes.size > 0:
        max_score_id = np.argmax(detected_scores)
        mask_mode = False
        if detected_masks is not None and groundtruth_masks is not None:
          mask_mode = True
        if mask_mode:
          detected_boxlist = np_box_mask_list.BoxMaskList(
              box_data=np.expand_dims(detected_boxes[max_score_id], axis=0),
              mask_data=np.expand_dims(detected_masks[max_score_id], axis=0))
          gt_boxlist = np_box_mask_list.BoxMaskList(
              box_data=groundtruth_boxes, mask_data=groundtruth_masks)
          iou = np_box_mask_list_ops.iou(detected_boxlist, gt_boxlist)
        else:
          detected_boxlist = np_box_list.BoxList(
              np.expand_dims(detected_boxes[max_score_id, :], axis=0))
          gt_boxlist = np_box_list.BoxList(groundtruth_boxes)
          iou = np_box_list_ops.iou(detected_boxlist, gt_boxlist)
        if np.max(iou) >= self.matching_iou_threshold:
          return 1
    return 0
Compute CorLoc score for a single class.

    Args:
      detected_boxes: A numpy array of shape [N, 4] representing detected box
        coordinates
      detected_scores: A 1-d numpy array of length N representing classification
        score
      groundtruth_boxes: A numpy array of shape [M, 4] representing ground truth
        box coordinates
      detected_masks: (optional) A np.uint8 numpy array of shape [N, height,
        width]. If not None, the scores will be computed based on masks.
      groundtruth_masks: (optional) A np.uint8 numpy array of shape [M, height,
        width].

    Returns:
      is_class_correctly_detected_in_image: An integer 1 or 0 denoting whether a
          class is correctly detected in the image or not
    
inference_api/src/main/object_detection/utils/per_image_evaluation.py