class_docstr: Calculate detection mean average precision.
  Currently support two types: 11point and integral
  
  Args:
      class_num (int): The class number.
      overlap_thresh (float): The threshold of overlap
          ratio between prediction bounding box and 
          ground truth bounding box for deciding 
          true/false positive. Default 0.5.
      map_type (str): Calculation method of mean average
          precision, currently support '11point' and
          'integral'. Default '11point'.
      is_bbox_normalized (bool): Whether bounding boxes
          is normalized to range[0, 1]. Default False.
      evaluate_difficult (bool): Whether to evaluate
          difficult bounding boxes. Default False.
      catid2name (dict): Mapping between category id and category name.
      classwise (bool): Whether per-category AP and draw
          P-R Curve or not.
class_docstr_tok: ["Calculate","detection","mean","average","precision",".","Currently","support","two","types",":","11point","and","integral","Args",":","class_num","(","int",")",":","The","class","number",".","overlap_thresh","(","float",")",":","The","threshold","of","overlap","ratio","between","prediction","bounding","box","and","ground","truth","bounding","box","for","deciding","true\/false","positive",".","Default","0.5.","map_type","(","str",")",":","Calculation","method","of","mean","average","precision",",","currently","support","'11point","'","and","'integral","'",".","Default","'11point","'",".","is_bbox_normalized","(","bool",")",":","Whether","bounding","boxes","is","normalized","to","range","[","0",",","1","]",".","Default","False",".","evaluate_difficult","(","bool",")",":","Whether","to","evaluate","difficult","bounding","boxes",".","Default","False",".","catid2name","(","dict",")",":","Mapping","between","category","id","and","category","name",".","classwise","(","bool",")",":","Whether","per-category","AP","and","draw","P-R","Curve","or","not","."]
docstr: Accumulate metric results and calculate mAP
docstr_tok: ["Accumulate","metric","results","and","calculate","mAP"]
code: def accumulate(self):
      """
      Accumulate metric results and calculate mAP
      """
      mAP = 0.0
      valid_cnt = 0
      eval_results = []
      for score_pos, count in zip(
          self.class_score_poss, self.class_gt_counts
      ):
          if count == 0:
              continue
          if len(score_pos) == 0:
              valid_cnt += 1
              continue
  
          accum_tp_list, accum_fp_list = self._get_tp_fp_accum(
              score_pos
          )
          precision = []
          recall = []
          for ac_tp, ac_fp in zip(accum_tp_list, accum_fp_list):
              precision.append(float(ac_tp) / (ac_tp + ac_fp))
              recall.append(float(ac_tp) / count)
  
          one_class_ap = 0.0
          if self.map_type == "11point":
              max_precisions = [0.0] * 11
              start_idx = len(precision) - 1
              for j in range(10, -1, -1):
                  for i in range(start_idx, -1, -1):
                      if recall[i] < float(j) / 10.0:
                          start_idx = i
                          if j > 0:
                              max_precisions[j - 1] = max_precisions[j]
                              break
                      else:
                          if max_precisions[j] < precision[i]:
                              max_precisions[j] = precision[i]
              one_class_ap = sum(max_precisions) / 11.0
              mAP += one_class_ap
              valid_cnt += 1
          elif self.map_type == "integral":
              import math
  
              prev_recall = 0.0
              for i in range(len(precision)):
                  recall_gap = math.fabs(recall[i] - prev_recall)
                  if recall_gap > 1e-6:
                      one_class_ap += precision[i] * recall_gap
                      prev_recall = recall[i]
              mAP += one_class_ap
              valid_cnt += 1
          else:
              logger.error(
                  "Unspported mAP type {}".format(self.map_type)
              )
              sys.exit(1)
          eval_results.append(
              {
                  "class": self.classes[valid_cnt - 1],
                  "ap": one_class_ap,
                  "precision": precision,
                  "recall": recall,
              }
          )
      self.eval_results = eval_results
      self.mAP = mAP / float(valid_cnt) if valid_cnt > 0 else mAP
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  import os
  import sys
  import numpy
  import itertools
  import paddle
  from ppdet.modeling.rbox_utils import poly2rbox_np
  from ppdet.utils.logger import setup_logger
label_desc: Use image node_id 4 for calling the DetectionMAP obj's underlying member method code with example usage: obj.accumulate() without return types