class_docstr: Evaluate detection result of a single image.
class_docstr_tok: ["Evaluate","detection","result","of","a","single","image","."]
docstr: Labels boxes detected with the same class from the same image as tp/fp.
  
  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
    groundtruth_is_difficult_list: A boolean numpy array of length M denoting
        whether a ground truth box is a difficult instance or not. If a
        groundtruth box is difficult, every detection matching this box
        is ignored.
    groundtruth_is_group_of_list: A boolean numpy array of length M denoting
        whether a ground truth box has group-of tag. If a groundtruth box
        is group-of box, every detection matching this box is ignored.
    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:
    Two arrays of the same size, containing all boxes that were evaluated as
    being true positives or false positives; if a box matched to a difficult
    box or to a group-of box, it is ignored.
  
    scores: A numpy array representing the detection scores.
    tp_fp_labels: a boolean numpy array indicating whether a detection is a
        true positive.
docstr_tok: ["Labels","boxes","detected","with","the","same","class","from","the","same","image","as","tp\/fp",".","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","groundtruth_is_difficult_list",":","A","boolean","numpy","array","of","length","M","denoting","whether","a","ground","truth","box","is","a","difficult","instance","or","not",".","If","a","groundtruth","box","is","difficult",",","every","detection","matching","this","box","is","ignored",".","groundtruth_is_group_of_list",":","A","boolean","numpy","array","of","length","M","denoting","whether","a","ground","truth","box","has","group-of","tag",".","If","a","groundtruth","box","is","group-of","box",",","every","detection","matching","this","box","is","ignored",".","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",":","Two","arrays","of","the","same","size",",","containing","all","boxes","that","were","evaluated","as","being","true","positives","or","false","positives",";","if","a","box","matched","to","a","difficult","box","or","to","a","group-of","box",",","it","is","ignored",".","scores",":","A","numpy","array","representing","the","detection","scores",".","tp_fp_labels",":","a","boolean","numpy","array","indicating","whether","a","detection","is","a","true","positive","."]
code: def _compute_tp_fp_for_single_class(
      self,
      detected_boxes,
      detected_scores,
      groundtruth_boxes,
      groundtruth_is_difficult_list,
      groundtruth_is_group_of_list,
      detected_masks=None,
      groundtruth_masks=None,
  ):
      """Labels boxes detected with the same class from the same image as tp/fp.
  
      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
        groundtruth_is_difficult_list: A boolean numpy array of length M denoting
            whether a ground truth box is a difficult instance or not. If a
            groundtruth box is difficult, every detection matching this box
            is ignored.
        groundtruth_is_group_of_list: A boolean numpy array of length M denoting
            whether a ground truth box has group-of tag. If a groundtruth box
            is group-of box, every detection matching this box is ignored.
        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:
        Two arrays of the same size, containing all boxes that were evaluated as
        being true positives or false positives; if a box matched to a difficult
        box or to a group-of box, it is ignored.
  
        scores: A numpy array representing the detection scores.
        tp_fp_labels: a boolean numpy array indicating whether a detection is a
            true positive.
      """
      if detected_boxes.size == 0:
          return np.array([], dtype=float), np.array([], dtype=bool)
  
      (
          iou,
          _,
          scores,
          num_detected_boxes,
      ) = self._get_overlaps_and_scores_box_mode(
          detected_boxes=detected_boxes,
          detected_scores=detected_scores,
          groundtruth_boxes=groundtruth_boxes,
          groundtruth_is_group_of_list=groundtruth_is_group_of_list,
      )
  
      if groundtruth_boxes.size == 0:
          return scores, np.zeros(num_detected_boxes, dtype=bool)
  
      tp_fp_labels = np.zeros(num_detected_boxes, dtype=bool)
      is_matched_to_difficult_box = np.zeros(
          num_detected_boxes, dtype=bool
      )
      is_matched_to_group_of_box = np.zeros(
          num_detected_boxes, dtype=bool
      )
  
      # The evaluation is done in two stages:
      # 1. All detections are matched to non group-of boxes; true positives are
      #    determined and detections matched to difficult boxes are ignored.
      # 2. Detections that are determined as false positives are matched against
      #    group-of boxes and ignored if matched.
  
      # Tp-fp evaluation for non-group of boxes (if any).
      if iou.shape[1] > 0:
          groundtruth_nongroup_of_is_difficult_list = (
              groundtruth_is_difficult_list[
                  ~groundtruth_is_group_of_list
              ]
          )
          max_overlap_gt_ids = np.argmax(iou, axis=1)
          is_gt_box_detected = np.zeros(iou.shape[1], dtype=bool)
          for i in range(num_detected_boxes):
              gt_id = max_overlap_gt_ids[i]
              if iou[i, gt_id] >= self.matching_iou_threshold:
                  if not groundtruth_nongroup_of_is_difficult_list[
                      gt_id
                  ]:
                      if not is_gt_box_detected[gt_id]:
                          tp_fp_labels[i] = True
                          is_gt_box_detected[gt_id] = True
                  else:
                      is_matched_to_difficult_box[i] = True
  
      return (
          scores[
              ~is_matched_to_difficult_box & ~is_matched_to_group_of_box
          ],
          tp_fp_labels[
              ~is_matched_to_difficult_box & ~is_matched_to_group_of_box
          ],
      )
  
file_path: SlowFast/ava_evaluation/per_image_evaluation.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import numpy
  from .None import np_box_list, np_box_list_ops, np_box_mask_list, np_box_mask_list_ops
label_desc: Use image node_id 5 for calling the PerImageEvaluation obj's underlying member method code with example usage: obj._compute_tp_fp_for_single_class(detected_boxes, detected_scores, groundtruth_boxes, groundtruth_is_difficult_list, groundtruth_is_group_of_list, detected_masks, groundtruth_masks) and returns: scores,  tp_fp_labels, np,  np, scores,  np