code: def _compute_ap(recall, precision):
      """Compute the average precision, given the recall and precision curves.
  
      Code originally from https://github.com/rbgirshick/py-faster-rcnn.
  
      # Arguments
          recall:    The recall curve (list).
          precision: The precision curve (list).
      # 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
  
file_path: ImageAI/imageai_tf_deprecated/Detection/keras_retinanet/utils/eval.py
imports: from .anchors import compute_overlap
  from .visualization import draw_detections, draw_annotations
  from tensorflow import keras
  import numpy
  import os
  import time
  import cv2
  import progressbar
label_desc: Use image node_id 1 for calling a global function with example usage: _compute_ap(recall, precision) and returns: ap