def compute_recall_at_k(tp_fp_list, num_gt, k):
  """Computes Recall@k, MedianRank@k, where k is the top-scoring labels.

  Args:
    tp_fp_list: a list of numpy arrays; each numpy array corresponds to the all
        detection on a single image, where the detections are sorted by score in
        descending order. Further, each numpy array element can have boolean or
        float values. True positive elements have either value >0.0 or True;
        any other value is considered false positive.
    num_gt: number of groundtruth anotations.
    k: number of top-scoring proposals to take.

  Returns:
    recall: recall evaluated on the top k by score detections.
  """

  tp_fp_eval = []
  for i in range(len(tp_fp_list)):
    tp_fp_eval.append(tp_fp_list[i][0:min(k, tp_fp_list[i].shape[0])])

  tp_fp_eval = np.concatenate(tp_fp_eval)

  return np.sum(tp_fp_eval) / num_gt
Computes Recall@k, MedianRank@k, where k is the top-scoring labels.

  Args:
    tp_fp_list: a list of numpy arrays; each numpy array corresponds to the all
        detection on a single image, where the detections are sorted by score in
        descending order. Further, each numpy array element can have boolean or
        float values. True positive elements have either value >0.0 or True;
        any other value is considered false positive.
    num_gt: number of groundtruth anotations.
    k: number of top-scoring proposals to take.

  Returns:
    recall: recall evaluated on the top k by score detections.
  
inference_api/src/main/object_detection/utils/metrics.py