code: def evaluate_class(ids, scores, boxes, annotations, files, ovthresh):
      if scores.shape[0] == 0:
          return 0.0, np.zeros(len(ids)), np.zeros(len(ids))
  
      # extract gt objects for this class
      diff = [
          np.array([0 for obj in annotations[filename]])
          for filename in files
      ]
      total = sum([sum(x == 0) for x in diff])
      detected = dict(zip(files, [[False] * len(x) for x in diff]))
  
      # sort by confidence
      sorted_ind = np.argsort(-scores)
      ids = ids[sorted_ind]
      boxes = boxes[sorted_ind, :]
  
      # go down dets and mark TPs and FPs
      tp_list = []
      fp_list = []
      for d in range(len(ids)):
          actual = np.array([x["bbox"] for x in annotations[ids[d]]])
          difficult = np.array([0 for x in annotations[ids[d]]])
  
          if actual.size > 0:
              iw = np.maximum(
                  np.minimum(actual[:, 2], boxes[d, 2])
                  - np.maximum(actual[:, 0], boxes[d, 0])
                  + 1,
                  0,
              )
              ih = np.maximum(
                  np.minimum(actual[:, 3], boxes[d, 3])
                  - np.maximum(actual[:, 1], boxes[d, 1])
                  + 1,
                  0,
              )
              inters = iw * ih
              overlaps = inters / (
                  area(actual) + area(boxes[d, :]) - inters
              )
              jmax = np.argmax(overlaps)
              ovmax = overlaps[jmax]
          else:
              ovmax = -np.inf
  
          tp = 0.0
          fp = 0.0
          if ovmax > ovthresh:
              if difficult[jmax] == 0:
                  if not detected[ids[d]][jmax]:
                      tp = 1.0
                      detected[ids[d]][jmax] = True
                  else:
                      fp = 1.0
          else:
              fp = 1.0
          tp_list.append(tp)
          fp_list.append(fp)
  
      tp = np.cumsum(tp_list)
      fp = np.cumsum(fp_list)
      recall = tp / float(total)
      precision = tp / np.maximum(tp + fp, np.finfo(np.float64).eps)
      ap = np.mean(
          [
              0
              if np.sum(recall >= t) == 0
              else np.max(precision[recall >= t])
              for t in np.linspace(0, 1, 11)
          ]
      )
  
      return ap, precision, recall
  
file_path: tensornets/tensornets/datasets/coco.py
imports: from __future__ import division
  import os
  import json
  import numpy
label_desc: Use image node_id 6 for calling a global function with example usage: evaluate_class(ids, scores, boxes, annotations, files, ovthresh) and returns: ap,  precision,  recall, int,  np,  np