widerface官方的ground truth文件是mat格式的,因为要测试自己的数据,gt文件是txt格式的,所以要修改一下测AP的方法。
测AP的原代码中的部分函数可以直接使用,修改读gt文件和获取gt中人脸框的部分即可,修改部分如下
def evatxt(pred, gt_file, iou_thresh):pred = get_preds(pred)norm_score(pred)boxes_list = get_gt_boxes_from_txt(gt_file)thresh_num = 1000aps = []count_face = 0pr_curve = np.zeros((thresh_num, 2)).astype('float') # control calcultate how many sampleserror_count = 0for boxes in boxes_list:try:image_name = boxesevent_name = image_name.split('/')[0]image_name = image_name.split('/')[1]name_all = event_name + '\' + image_name[:-4]pred_list = pred[event_name]pred_info = pred_list[name_all]except:error_count += 1continuegt_boxes = boxes_list[boxes].astype('float')if len(pred_info) == 0 or len(gt_boxes) == 0:error_count += 1continuecount_face += len(gt_boxes)pred_recall, proposal_list = image_eval(pred_info, gt_boxes, iou_thresh)_img_pr_info = img_pr_info(thresh_num, pred_info, proposal_list, pred_recall)pr_curve += _img_pr_infoprint(boxes)pr_curve = dataset_pr_info(thresh_num, pr_curve, count_face)propose = pr_curve[:, 0]recall = pr_curve[:, 1]ap = voc_ap(recall, propose)aps.append(ap)print("==================== Results ====================")print("Val AP: {}".format(aps[0]))print("=================================================")
本文发布于:2024-01-28 17:15:31,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/17064333368988.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |