def _compute_cor_loc(self,
                       detected_boxes,
                       detected_scores,
                       detected_class_labels,
                       groundtruth_boxes,
                       groundtruth_class_labels,
                       detected_masks=None,
                       groundtruth_masks=None):
    """Compute CorLoc score for object detection result.

    Args:
      detected_boxes: A float numpy array of shape [N, 4], representing N
        regions of detected object regions. Each row is of the format [y_min,
        x_min, y_max, x_max]
      detected_scores: A float numpy array of shape [N, 1], representing the
        confidence scores of the detected N object instances.
      detected_class_labels: A integer numpy array of shape [N, 1], repreneting
        the class labels of the detected N object instances.
      groundtruth_boxes: A float numpy array of shape [M, 4], representing M
        regions of object instances in ground truth
      groundtruth_class_labels: An integer numpy array of shape [M, 1],
        representing M class labels of object instances in ground truth
      detected_masks: (optional) A uint8 numpy array of shape [N, height,
        width]. If not None, the scores will be computed based on masks.
      groundtruth_masks: (optional) A uint8 numpy array of shape [M, height,
        width].

    Returns:
      is_class_correctly_detected_in_image: a numpy integer array of
          shape [C, 1], indicating whether the correponding class has a least
          one instance being correctly detected in the image

    Raises:
      ValueError: If detected masks is not None but groundtruth masks are None,
        or the other way around.
    """
    if (detected_masks is not None and
        groundtruth_masks is None) or (detected_masks is None and
                                       groundtruth_masks is not None):
      raise ValueError(
          'If `detected_masks` is provided, then `groundtruth_masks` should '
          'also be provided.')

    is_class_correctly_detected_in_image = np.zeros(
        self.num_groundtruth_classes, dtype=int)
    for i in range(self.num_groundtruth_classes):
      (gt_boxes_at_ith_class, gt_masks_at_ith_class,
       detected_boxes_at_ith_class, detected_scores_at_ith_class,
       detected_masks_at_ith_class) = self._get_ith_class_arrays(
           detected_boxes, detected_scores, detected_masks,
           detected_class_labels, groundtruth_boxes, groundtruth_masks,
           groundtruth_class_labels, i)
      is_class_correctly_detected_in_image[i] = (
          self._compute_is_class_correctly_detected_in_image(
              detected_boxes=detected_boxes_at_ith_class,
              detected_scores=detected_scores_at_ith_class,
              groundtruth_boxes=gt_boxes_at_ith_class,
              detected_masks=detected_masks_at_ith_class,
              groundtruth_masks=gt_masks_at_ith_class))

    return is_class_correctly_detected_in_image
Compute CorLoc score for object detection result.

    Args:
      detected_boxes: A float numpy array of shape [N, 4], representing N
        regions of detected object regions. Each row is of the format [y_min,
        x_min, y_max, x_max]
      detected_scores: A float numpy array of shape [N, 1], representing the
        confidence scores of the detected N object instances.
      detected_class_labels: A integer numpy array of shape [N, 1], repreneting
        the class labels of the detected N object instances.
      groundtruth_boxes: A float numpy array of shape [M, 4], representing M
        regions of object instances in ground truth
      groundtruth_class_labels: An integer numpy array of shape [M, 1],
        representing M class labels of object instances in ground truth
      detected_masks: (optional) A uint8 numpy array of shape [N, height,
        width]. If not None, the scores will be computed based on masks.
      groundtruth_masks: (optional) A uint8 numpy array of shape [M, height,
        width].

    Returns:
      is_class_correctly_detected_in_image: a numpy integer array of
          shape [C, 1], indicating whether the correponding class has a least
          one instance being correctly detected in the image

    Raises:
      ValueError: If detected masks is not None but groundtruth masks are None,
        or the other way around.
    
inference_api/src/main/object_detection/utils/per_image_evaluation.py