當前位置: 首頁>>代碼示例>>Python>>正文


Python verification.evaluate方法代碼示例

本文整理匯總了Python中verification.evaluate方法的典型用法代碼示例。如果您正苦於以下問題:Python verification.evaluate方法的具體用法?Python verification.evaluate怎麽用?Python verification.evaluate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在verification的用法示例。


在下文中一共展示了verification.evaluate方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: main

# 需要導入模塊: import verification [as 別名]
# 或者: from verification import evaluate [as 別名]
def main(args):
    with tf.Graph().as_default():
        with tf.Session() as sess:
            # prepare validate datasets
            ver_list = []
            ver_name_list = []
            for db in args.eval_datasets:
                print('begin db %s convert.' % db)
                data_set = load_data(db, args.image_size, args)
                ver_list.append(data_set)
                ver_name_list.append(db)

            # Load the model
            load_model(args.model)

            # Get input and output tensors, ignore phase_train_placeholder for it have default value.
            inputs_placeholder = tf.get_default_graph().get_tensor_by_name("input:0")
            embeddings = tf.get_default_graph().get_tensor_by_name("embeddings:0")

            # image_size = images_placeholder.get_shape()[1]  # For some reason this doesn't work for frozen graphs
            embedding_size = embeddings.get_shape()[1]

            for db_index in range(len(ver_list)):
                # Run forward pass to calculate embeddings
                print('\nRunnning forward pass on {} images'.format(ver_name_list[db_index]))
                start_time = time.time()
                data_sets, issame_list = ver_list[db_index]
                nrof_batches = data_sets.shape[0] // args.test_batch_size
                emb_array = np.zeros((data_sets.shape[0], embedding_size))

                for index in range(nrof_batches):
                    start_index = index * args.test_batch_size
                    end_index = min((index + 1) * args.test_batch_size, data_sets.shape[0])

                    feed_dict = {inputs_placeholder: data_sets[start_index:end_index, ...]}
                    emb_array[start_index:end_index, :] = sess.run(embeddings, feed_dict=feed_dict)

                tpr, fpr, accuracy, val, val_std, far = evaluate(emb_array, issame_list, nrof_folds=args.eval_nrof_folds)
                duration = time.time() - start_time
                print("total time %.3fs to evaluate %d images of %s" % (duration, data_sets.shape[0], ver_name_list[db_index]))
                print('Accuracy: %1.3f+-%1.3f' % (np.mean(accuracy), np.std(accuracy)))
                print('Validation rate: %2.5f+-%2.5f @ FAR=%2.5f' % (val, val_std, far))
                print('fpr and tpr: %1.3f %1.3f' % (np.mean(fpr, 0), np.mean(tpr, 0)))

                auc = metrics.auc(fpr, tpr)
                print('Area Under Curve (AUC): %1.3f' % auc)
                eer = brentq(lambda x: 1. - x - interpolate.interp1d(fpr, tpr)(x), 0., 1.)
                print('Equal Error Rate (EER): %1.3f' % eer) 
開發者ID:sirius-ai,項目名稱:MobileFaceNet_TF,代碼行數:50,代碼來源:test_nets.py


注:本文中的verification.evaluate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。