def eval_ap(iou, iou_idx, cls, gt, predition): ap = evaluate.ap(predition, iou[0], gt) sys.stdout.flush() return cls, iou_idx, ap
for cls in prediction_by_cls: all_prediction += cls print("NMS performed.") # calculate ious = np.arange(0.1, 1.0, 0.1) aps = np.zeros((len(ious), label_count)) ars = np.zeros((len(ious), label_count)) f1s = np.zeros((len(ious), )) miou = evaluate.miou_per_v(all_prediction, all_groundtruth) for i, iou in enumerate(ious): for cls in range(label_count): ap, ar = evaluate.ap(prediction_by_cls[cls], iou, groundtruth_by_cls[cls]) aps[i][cls] = ap ars[i][cls] = ar f1 = evaluate.f1(all_prediction, iou, all_groundtruth) f1s[i] = f1 map_ = np.mean(aps, axis=1) mar = np.mean(ars, axis=1) print("Criteria solved.") # print title = "C3D Detection Performance" datas = [["IoU threshold"], ["mean AP"], ["mean AR"], ["F1 criterion"]] for i, iou in enumerate(ious): datas[0].append("{:.2f}".format(iou))