insightface测试recognition验证集效果全过程

本过程在insightface代码下作实验,源代码参考
https://github.com/deepinsight/insightface#pretrained-models
实验测试recognition下的eval验证

1数据准备

数据准备参考博文:insightface数据制作全过程记录
https://blog.youkuaiyun.com/CLOUD_J/article/details/98769515

2eval验证

在/recognition/eval下verification.py文件
在这里插入图片描述

python3 verification.py --data-dir ../../datasets/lfw --model ../../models/model-r50-am-lfw/model,0 --nfolds 10

运行时出现了点问题,主要在于我们之前准备数据集时没有打乱数据导致正样本挤在一起,会使这一部分数据负样本为0,我们计算正确率会用负样本识别正确比上总负样样本数,分母出现0,所以做了更改calculate_val_far函数

def calculate_val_far(threshold, dist, actual_issame):
    predict_issame = np.less(dist, threshold)
    true_accept = np.sum(np.logical_and(predict_issame, actual_issame))
    false_accept = np.sum(np.logical_and(predict_issame, np.logical_not(actual_issame)))
    n_same = np.sum(actual_issame)
    n_diff = np.sum(np.logical_not(actual_issame))
    #print(true_accept, false_accept)
    #print(n_same, n_diff)
    if n_same == 0:
        val = 1
    else:
        val = float(true_accept) / float(n_same)
    if n_diff == 0:
        far = 0
    else:
        far = float(false_accept) / float(n_diff)
    return val, far

3代码解析

3.1主函数

主函数首先做了模型载入,数据载入bin文件,然后对载入的模型分别做测试,检测各个模型数据效果。
核心在这里,遍历ver_list不同数据集,遍历nets不同模型

if args.mode==0:
    for i in range(len(ver_list)):
      results = []
      for model in nets:
        acc1, std1, acc2, std2, xnorm, embeddings_list = test(ver_list[i], model, args.batch_size, args.nfolds)
        print('[%s]XNorm: %f' % (ver_name_list[i], xnorm))
        print('[%s]Accuracy: %1.5f+-%1.5f' % (ver_name_list[i], acc1, std1))
        print('[%s]Accuracy-Flip: %1.5f+-%1.5f' % (ver_name_list[i], acc2, std2))
        results.append(acc2)
      print('Max of [%s] is %1.5f' % (ver_name_list[i], np.max(results)))
  elif args.mode==
评论 10
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值