code: def compute_ap(recall, precision):
      """
      Computes the average precision, given the recall and precision curves.
      Code originally from https://github.com/rbgirshick/py-faster-rcnn.
  
      Args:
          recall (list): The recall curve.
          precision (list): The precision curve.
  
      Returns:
          The average precision as computed in py-faster-rcnn.
      """
      # correct AP calculation
      # first append sentinel values at the end
      mrec = np.concatenate(([0.0], recall, [1.0]))
      mpre = np.concatenate(([0.0], precision, [0.0]))
  
      # compute the precision envelope
      for i in range(mpre.size - 1, 0, -1):
          mpre[i - 1] = np.maximum(mpre[i - 1], mpre[i])
  
      # to calculate area under PR curve, look for points
      # where X axis (recall) changes value
      i = np.where(mrec[1:] != mrec[:-1])[0]
  
      # and sum (\Delta recall) * prec
      ap = np.sum((mrec[i + 1] - mrec[i]) * mpre[i + 1])
      return ap
  
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 7 for calling a global function with example usage: compute_ap(recall, precision) and returns: ap