code: def voc_ap(rec, prec):
      # correct AP calculation
      # first append sentinel values at the end
      # print ('rec:', rec)
      # print ('pre:', prec)
      mrec = np.concatenate(([0.0], rec, [1.0]))
      mpre = np.concatenate(([0.0], prec, [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_round(np.sum((mrec[i + 1] - mrec[i]) * mpre[i + 1]))
      return ap
  
imports: from __future__ import absolute_import
  import os
  import tqdm
  import pickle
  import datetime
  import argparse
  import numpy
  from scipy.io import loadmat
label_desc: Use image node_id 14 for calling a global function with example usage: voc_ap(rec, prec) and returns: ap