Example #1
0
    def plotDETcurve(self):
        """
        This method is used to plot the DET (Detection Error Tradeoff) and 
        save it on the disk.
        """
        # Read test scores
        filename = "ubm_scores_{}.h5".format(self.NUM_GAUSSIANS)
        scores_dir = os.path.join(self.BASE_DIR, "result", filename)
        scores_gmm_ubm = sidekit.Scores.read(scores_dir)
        # Read the key
        key = sidekit.Key.read_txt(os.path.join(self.BASE_DIR, "task", "test_trials.txt"))

        # Make DET plot
        logging.info("Drawing DET Curve")
        dp = sidekit.DetPlot(window_style='sre10', plot_title='Scores GMM-UBM')
        dp.set_system_from_scores(scores_gmm_ubm, key, sys_name='GMM-UBM')
        dp.create_figure()
        # DET type
        if self.conf['DET_curve'] == "rocch":
            dp.plot_rocch_det(idx=0)
        elif self.conf['DET_curve'] == "steppy":
            dp.plot_steppy_det(idx=0)
        else:
            raise NameError("Unsupported DET-curve-plotting method!!")
        dp.plot_DR30_both(idx=0) #dotted line for Doddington's Rule
        prior = sidekit.logit_effective_prior(0.001, 1, 1)
        dp.plot_mindcf_point(prior, idx=0) #minimum dcf point
        # Save the graph
        graphname = "DET_GMM_UBM_{}.png".format(self.NUM_GAUSSIANS)
        dp.__figure__.savefig(os.path.join(self.BASE_DIR, "result", graphname))
Example #2
0
def compute_eer(args):
    print('Compute eer', end='')
    key = sidekit.Key(os.getcwd() + '/task/dev_key.h5')
    score = sidekit.Scores(os.getcwd() + '/task/dev_score.h5')
    print('\rCompute eer done')

    dp = sidekit.DetPlot()
    prior = sidekit.logit_effective_prior(0.01, 1, 1)
    dp.set_system_from_scores(score, key)
    minDCF, _, __, ___, eer = sidekit.bosaris.detplot.fast_minDCF(
        dp.__tar__[0], dp.__non__[0], prior, normalize=True)

    with open('task/dev_result.txt', 'w') as f:
        f.write('eer    :    {:7.2%}\n'.format(eer))
        f.write('minDCF :    {:7.2%}\n'.format(minDCF))
    return eer, minDCF
Example #3
0
    def plotDETcurve(self):
        # Read test scores
        filename = "ubm_scores_{}.h5".format(self.NUM_GUASSIANS)
        scores_dir = os.path.join(self.BASE_DIR, "result", filename)
        scores_gmm_ubm = sidekit.Scores.read(scores_dir)
        # Read the key
        key = sidekit.Key.read_txt(os.path.join(self.BASE_DIR, "task", "test_trials.txt"))

        # Make DET plot
        logging.info("Drawing DET Curve")
        dp = sidekit.DetPlot(window_style='sre10', plot_title='Scores GMM-UBM')
        dp.set_system_from_scores(scores_gmm_ubm, key, sys_name='GMM-UBM')
        dp.create_figure()
        dp.plot_rocch_det(0)
        dp.plot_DR30_both(idx=0)
        prior = sidekit.logit_effective_prior(0.01, 10, 1)
        dp.plot_mindcf_point(prior, idx=0)
        graphname = "DET_GMM_UBM_{}.png".format(self.NUM_GUASSIANS)
        dp.__figure__.savefig(os.path.join(self.BASE_DIR, "result", graphname))
Example #4
0
# Compute all trials and save scores in HDF5 format

print('Compute trial scores')
scores_gmm_ubm = sidekit.gmm_scoring(ubm,
                                     enroll_sv,
                                     test_ndx,
                                     features_server,
                                     num_thread=nbThread)
scores_gmm_ubm.write('scores/scores_gmm-ubm_rsr2015_male.h5')

# Plot DET curve and compute minDCF and EER

print('Plot the DET curve')
# Set the prior following NIST-SRE 2008 settings
prior = sidekit.logit_effective_prior(0.01, 10, 1)

# Initialize the DET plot to 2008 settings
dp = sidekit.DetPlot(window_style='sre10', plot_title='GMM-UBM_RSR2015_male')
dp.set_system_from_scores(scores_gmm_ubm, key, sys_name='GMM-UBM')
dp.create_figure()
dp.plot_rocch_det(0)
dp.plot_DR30_both(idx=0)
dp.plot_mindcf_point(prior, idx=0)

print('Plot DET curves')
prior = sidekit.logit_effective_prior(0.001, 1, 1)
minDCF, Pmiss, Pfa, prbep, eer = sidekit.bosaris.detplot.fast_minDCF(
    dp.__tar__[0], dp.__non__[0], prior, normalize=True)
print("UBM-GMM 128g, minDCF = {}, eer = {}".format(minDCF, eer))
Example #5
0
            itNb=(it, 0, 0),
            minDiv=True,
            ubm=None,
            batch_size=1000,
            numThread=nbThread)
        scores_plda_efr1 = sidekit.iv_scoring.PLDA_scoring(
            enroll_iv_sn1, test_iv_sn1, test_ndx, mean1, F1, G1, Sigma1)
        scores_plda_efr1.save(
            'scores/scores_plda_rank_400_it10_efr1_sre10_coreX-coreX_m.h5')

if plot:
    print('Plot the DET curve')
    # Set the prior following NIST-SRE 2010 settings
    prior = sidekit.effective_prior(0.001, 1, 1)
    # Initialize the DET plot to 2010 settings
    dp = sidekit.DetPlot(windowStyle='sre10',
                         plotTitle='I-Vectors SRE 2010-ext male, cond 5')

    dp.set_system_from_scores(scores_cos, keysX[4], sys_name='Cosine')
    dp.set_system_from_scores(scores_cos_wccn,
                              keysX[4],
                              sys_name='Cosine WCCN')
    dp.set_system_from_scores(scores_cos_lda, keysX[4], sys_name='Cosine LDA')
    dp.set_system_from_scores(scores_cos_lda_wcnn,
                              keysX[4],
                              sys_name='Cosine WCCN LDA')

    dp.set_system_from_scores(scores_mah_efr1,
                              keysX[4],
                              sys_name='Mahalanobis EFR')

    dp.set_system_from_scores(scores_2cov, keysX[4], sys_name='2 Covariance')
    nap_iv_sn1 = copy.deepcopy(nap_iv)
    enroll_iv_sn1 = copy.deepcopy(enroll_iv)
    test_iv_sn1 = copy.deepcopy(test_iv)

    nap_iv_sn1.spectral_norm_stat1(meanSN[:1], CovSN[:1])
    enroll_iv_sn1.spectral_norm_stat1(meanSN[:1], CovSN[:1])
    test_iv_sn1.spectral_norm_stat1(meanSN[:1], CovSN[:1])

    print('Run PLDA rank = {}, {} iterations with Spherical Norm'.format(400, 10))
    mean1, F1, G1, H1, Sigma1 = nap_iv_sn1.factor_analysis(400, rank_G=0, rank_H=None,
                            re_estimate_residual=True,
                            itNb=(10,0,0), minDiv=True, ubm=None,
                            batch_size=1000, numThread=nbThread)
    scores_plda_sn1 = sidekit.iv_scoring.PLDA_scoring(enroll_iv_sn1, test_iv_sn1, test_ndx, mean1, F1, G1, Sigma1)
    scores_plda_sn1.save('scores/scores_plda_eigh_rank_{}_it{}_lapack_sn1_sre10_coreX-coreX_m_mfcc.h5'.format(400, 10))


    print('Plot PLDA scoring DET curves')
    prior = sidekit.effective_prior(0.001, 1, 1)
    # Initialize the DET plot to 2008 settings
    dp = sidekit.DetPlot(windowStyle='sre10', plotTitle='I-Vectors SRE 2010 male')
       
    dp.set_system_from_scores(scores_plda_sn1, keysX[4], sys_name='Cond 5')
        
    dp.set_system_from_scores(scores_2cov, keys[4], sys_name='PLDA Spherical Norm')
    dp.create_figure()
    dp.plot_rocch_det(0)
    dp.plot_DR30_both(idx=0)
    dp.plot_mindcf_point(prior, idx=0)