Пример #1
0
def evaluate_raw_authentication(training=False,
                                verbose=False,
                                filename='results/raw_scores.csv'):
    df1 = pd.read_csv("input_csv/zju_session1_frames_raw.csv", header=None)
    df2 = pd.read_csv("input_csv/zju_session2_frames_raw.csv", header=None)

    df1 = normalize_rows(df1, st.NormalizationType.ZSCORE)
    df2 = normalize_rows(df2, st.NormalizationType.ZSCORE)

    features1 = df1
    features2 = df2

    auc1, eer1 = evaluate_authentication(features1, verbose)
    auc2, eer2 = evaluate_authentication(features2, verbose)
    auc_cross, eer_cross = evaluate_authentication_cross_day(
        features1, features2, verbose)

    # dictionary of lists
    dict = {
        'AUC1': auc1,
        'EER1': eer1,
        'AUC2': auc2,
        'EER2': eer2,
        'AUC_cross': auc_cross,
        'EER_cross': eer_cross
    }
    df = pd.DataFrame(dict)
    df.to_csv(filename, index=False)
def evaluate_raw_authentication(verbose=False,
                                filename='results/raw_scores.csv'):
    representation_type = RepresentationType.RAW
    df1 = pd.read_csv("input_csv_gait/zju_session1_frames_raw.csv",
                      header=None)
    df2 = pd.read_csv("input_csv_gait/zju_session2_frames_raw.csv",
                      header=None)

    df1 = normalize_rows(df1, st.NormalizationType.ZSCORE)
    df2 = normalize_rows(df2, st.NormalizationType.ZSCORE)

    features1 = df1
    features2 = df2

    roc_data_filename = 'results/roc_session1_' + str(
        representation_type.value) + '_' + str(data_type.value) + '.csv'
    auc1, eer1 = evaluate_authentication(features1,
                                         data_type,
                                         representation_type,
                                         verbose=verbose,
                                         roc_data=True,
                                         roc_data_filename=roc_data_filename)
    roc_data_filename = 'results/roc_session2_' + str(
        representation_type.value) + '_' + str(data_type.value) + '.csv'
    auc2, eer2 = evaluate_authentication(features1,
                                         data_type,
                                         representation_type,
                                         verbose=verbose,
                                         roc_data=True,
                                         roc_data_filename=roc_data_filename)
    roc_data_filename = 'results/roc_cross_session_' + str(
        representation_type.value) + '_' + str(data_type.value) + '.csv'
    auc_cross, eer_cross = evaluate_authentication_cross_day(
        features1,
        features2,
        data_type,
        representation_type,
        verbose=verbose,
        roc_data=True,
        roc_data_filename=roc_data_filename)

    scores_filename = 'results/auc_eer_users_' + str(
        representation_type.value) + '_' + str(data_type.value) + '.csv'
    dict = {
        'AUC1': auc1,
        'EER1': eer1,
        'AUC2': auc2,
        'EER2': eer2,
        'AUC_cross': auc_cross,
        'EER_cross': eer_cross
    }
    df = pd.DataFrame(dict)
    df.to_csv(scores_filename, index=False)
Пример #3
0
def evaluate_autoencoder_authentication(
        training=False,
        augm=False,
        augm_type=AugmentationType.RND,
        verbose=False,
        filename='results/autoencoder_scores.csv'):
    if augm == True:
        if augm_type == AugmentationType.RND:
            model_name = "gait_autoencoder_fcn_rnd.h5"
        else:
            model_name = "gait_autoencoder_fcn_cshift.h5"
    else:
        model_name = "gait_autoencoder_fcn.h5"
    if training == True:
        df_idnet = pd.read_csv("input_csv/idnet.csv", header=None)
        df_idnet = normalize_rows(df_idnet, st.NormalizationType.ZSCORE)
        if augm == True:
            df_idnet = get_augmented_dataset(df_idnet, augm_type)
        train_autoencoder(df_idnet, model_name=model_name, num_epochs=100)

    encoder_name = "encoder_" + model_name

    df1 = pd.read_csv("input_csv/zju_session1_frames_raw.csv", header=None)
    df2 = pd.read_csv("input_csv/zju_session2_frames_raw.csv", header=None)

    df1 = normalize_rows(df1, st.NormalizationType.ZSCORE)
    df2 = normalize_rows(df2, st.NormalizationType.ZSCORE)

    features1 = get_autoencoder_output_features(df1, encoder_name)
    features2 = get_autoencoder_output_features(df2, encoder_name)

    auc1, eer1 = evaluate_authentication(features1, verbose)
    auc2, eer2 = evaluate_authentication(features2, verbose)
    auc_cross, eer_cross = evaluate_authentication_cross_day(
        features1, features2, verbose)

    # dictionary of lists
    dict = {
        'AUC1': auc1,
        'EER1': eer1,
        'AUC2': auc2,
        'EER2': eer2,
        'AUC_cross': auc_cross,
        'EER_cross': eer_cross
    }
    df = pd.DataFrame(dict)
    df.to_csv(filename, index=False)
def evaluate_authentication_session2(augm=False,
                                     verbose=False,
                                     augm_type=AugmentationType.RND):
    # RAW
    df1 = pd.read_csv("input_csv_gait/zju_session2_frames_raw.csv",
                      header=None)
    df1 = normalize_rows(df1, st.NormalizationType.ZSCORE)

    representation_type = RepresentationType.RAW
    roc_data_filename1 = 'results/roc_session2_' + str(
        representation_type.value) + '_' + str(data_type.value) + '.csv'
    evaluate_authentication(df1,
                            data_type,
                            representation_type,
                            verbose,
                            roc_data=True,
                            roc_data_filename=roc_data_filename1)

    # AE
    representation_type = RepresentationType.AE
    fcn_filters = 128
    model_name = generate_model_name(representation_type=RepresentationType.AE,
                                     fcn_filters=fcn_filters,
                                     augm=augm,
                                     augm_type=augm_type)
    encoder_name = "encoder_" + model_name
    features1 = get_autoencoder_output_features(df1, encoder_name)
    roc_data_filename2 = 'results/roc_session2_' + str(
        representation_type.value) + '_' + str(data_type.value) + '.csv'
    evaluate_authentication(features1,
                            data_type,
                            representation_type,
                            verbose,
                            roc_data=True,
                            roc_data_filename=roc_data_filename2)

    # EE
    representation_type = RepresentationType.EE
    model_name = generate_model_name(representation_type=RepresentationType.EE,
                                     fcn_filters=fcn_filters,
                                     augm=augm,
                                     augm_type=augm_type)
    features1 = get_model_output_features(df1, model_name)
    roc_data_filename3 = 'results/roc_session2_' + str(
        representation_type.value) + '_' + str(data_type.value) + '.csv'
    evaluate_authentication(features1,
                            data_type,
                            representation_type,
                            verbose,
                            roc_data=True,
                            roc_data_filename=roc_data_filename3)

    # plot ROC
    roc_filename = 'Same-day evaluation: session2'
    title = 'ROC curve ' + str(data_type.value)
    plot_ROCs(roc_data_filename1,
              roc_data_filename2,
              roc_data_filename3,
              title=title,
              outputfilename=roc_filename)
def evaluate_autoencoder_authentication(
        training=False,
        fcn_filters=128,
        augm=False,
        augm_type=AugmentationType.RND,
        verbose=False,
        filename='results/autoencoder_scores.csv'):
    representation_type = RepresentationType.AE
    model_name = generate_model_name(representation_type,
                                     fcn_filters=fcn_filters,
                                     augm=augm,
                                     augm_type=augm_type)
    if training == True:
        df_idnet = pd.read_csv("input_csv_gait/idnet_raw.csv", header=None)
        df_idnet = normalize_rows(df_idnet, st.NormalizationType.ZSCORE)
        if augm == True:
            df_idnet = get_augmented_dataset(df_idnet, augm_type)
        train_autoencoder(df_idnet,
                          model_name=model_name,
                          fcn_filters=fcn_filters)

    encoder_name = "encoder_" + model_name

    df1 = pd.read_csv("input_csv_gait/zju_session1_frames_raw.csv",
                      header=None)
    df2 = pd.read_csv("input_csv_gait/zju_session2_frames_raw.csv",
                      header=None)

    df1 = normalize_rows(df1, st.NormalizationType.ZSCORE)
    df2 = normalize_rows(df2, st.NormalizationType.ZSCORE)

    features1 = get_autoencoder_output_features(df1, encoder_name)
    features2 = get_autoencoder_output_features(df2, encoder_name)

    roc_data_filename = 'results/roc_session1_' + str(
        representation_type.value) + '_' + str(data_type.value) + '.csv'
    auc1, eer1 = evaluate_authentication(features1,
                                         data_type,
                                         representation_type,
                                         verbose=verbose,
                                         roc_data=True,
                                         roc_data_filename=roc_data_filename)
    roc_data_filename = 'results/roc_session2_' + str(
        representation_type.value) + '_' + str(data_type.value) + '.csv'
    auc2, eer2 = evaluate_authentication(features1,
                                         data_type,
                                         representation_type,
                                         verbose=verbose,
                                         roc_data=True,
                                         roc_data_filename=roc_data_filename)
    roc_data_filename = 'results/roc_cross_session_' + str(
        representation_type.value) + '_' + str(data_type.value) + '.csv'
    auc_cross, eer_cross = evaluate_authentication_cross_day(
        features1,
        features2,
        data_type,
        representation_type,
        verbose=verbose,
        roc_data=True,
        roc_data_filename=roc_data_filename)

    scores_filename = 'results/auc_eer_users_' + str(
        representation_type.value) + '_' + str(data_type.value) + '.csv'
    dict = {
        'AUC1': auc1,
        'EER1': eer1,
        'AUC2': auc2,
        'EER2': eer2,
        'AUC_cross': auc_cross,
        'EER_cross': eer_cross
    }
    df = pd.DataFrame(dict)
    df.to_csv(scores_filename, index=False)