'Compute evaluation result.
Returns:
average_precision_per_class: float numpy array of average precision for
each class.
mean_ap: mean average precision of all classes, float scalar
precisions_per_class: List of precisions, each precision is a float numpy
array
recalls_per_class: List of recalls, each recall is a float numpy array
corloc_per_class: numpy float array
mean_corloc: Mean CorLoc score for each class, float scalar'

def evaluate(self):

    if (self.num_gt_instances_per_class == 0).any():
        logging.warn('The    following    classes    have    no    ground    truth    examples:    %s', np.squeeze(np.argwhere((self.num_gt_instances_per_class == 0))))
    for class_index in range(self.num_class):
        if (self.num_gt_instances_per_class[class_index] == 0):
            continue
        scores = np.concatenate(self.scores_per_class[class_index])
        tp_fp_labels = np.concatenate(self.tp_fp_labels_per_class[class_index])
        (precision, recall) = metrics.compute_precision_recall(scores, tp_fp_labels, self.num_gt_instances_per_class[class_index])
        self.precisions_per_class.append(precision)
        self.recalls_per_class.append(recall)
        average_precision = metrics.compute_average_precision(precision, recall)
        self.average_precision_per_class[class_index] = average_precision
    self.corloc_per_class = metrics.compute_cor_loc(self.num_gt_imgs_per_class, self.num_images_correctly_detected_per_class)
    mean_ap = np.nanmean(self.average_precision_per_class)
    mean_corloc = np.nanmean(self.corloc_per_class)
    return (self.average_precision_per_class, mean_ap, self.precisions_per_class, self.recalls_per_class, self.corloc_per_class, mean_corloc)
