def eval_svm(iv_file, class2int_file, test_file, preproc_file, model_file, score_file, vector_score_file, eval_type, **kwargs): if preproc_file is not None: preproc = TransformList.load(preproc_file) else: preproc = None tdr_args = TDR.filter_args(**kwargs) tdr = TDR(iv_file, class2int_file, test_file, preproc, **tdr_args) x, ndx = tdr.read() model = SVM.load(model_file) t1 = time.time() scores = model.predict(x, eval_type) dt = time.time() - t1 num_trials = scores.shape[0]*scores.shape[1] logging.info('Elapsed time: %.2f s. Elapsed time per trial: %.2f ms.' % (dt, dt/num_trials*1000)) s = TrialScores(ndx.model_set, ndx.seg_set, scores.T) s.save(score_file) if vector_score_file is not None: h5 = HDW(vector_score_file) h5.write(ndx.seg_set, '', scores)
def eval_plda(iv_file, ndx_file, enroll_file, test_file, preproc_file, model_file, score_file, plda_type, **kwargs): if preproc_file is not None: preproc = TransformList.load(preproc_file) else: preproc = None tdr_args = TDR.filter_args(**kwargs) tdr = TDR(iv_file, ndx_file, enroll_file, test_file, preproc, **tdr_args) x_e, x_t, enroll, ndx = tdr.read() model = F.load_plda(plda_type, model_file) t1 = time.time() scores = model.llr_1vs1(x_e, x_t) dt = time.time() - t1 num_trials = x_e.shape[0] * x_t.shape[0] logging.info('Elapsed time: %.2f s. Elapsed time per trial: %.2f ms.' % (dt, dt/num_trials*1000)) s = TrialScores(enroll, ndx.seg_set, scores) s.save(score_file)
def eval_cos(iv_file, ndx_file, enroll_file, test_file, preproc_file, score_file, **kwargs): if preproc_file is not None: preproc = TransformList.load(preproc_file) else: preproc = None tdr_args = TDR.filter_args(**kwargs) tdr = TDR(iv_file, ndx_file, enroll_file, test_file, preproc, **tdr_args) x_e, x_t, enroll, ndx = tdr.read() lnorm = LNorm() x_e = lnorm.predict(x_e) x_t = lnorm.predict(x_t) t1 = time.time() scores = np.dot(x_e, x_t.T) dt = time.time() - t1 num_trials = x_e.shape[0] * x_t.shape[0] logging.info('Elapsed time: %.2f s. Elapsed time per trial: %.2f ms.' % (dt, dt/num_trials*1000)) s = TrialScores(enroll, ndx.seg_set, scores) s.save(score_file)
def eval_plda(iv_file, ndx_file, enroll_file, test_file, preproc_file, model_file, score_file, pool_method, **kwargs): if preproc_file is not None: preproc = TransformList.load(preproc_file) else: preproc = None tdr_args = TDR.filter_args(**kwargs) tdr = TDR(iv_file, ndx_file, enroll_file, test_file, preproc, **tdr_args) x_e, x_t, enroll, ndx = tdr.read() enroll, ids_e = np.unique(enroll, return_inverse=True) model = F.load_plda(plda_type, model_file) t1 = time.time() scores = model.llr_Nvs1(x_e, x_t, method=pool_method, ids1=ids_e) dt = time.time() - t1 num_trials = len(enroll) * x_t.shape[0] logging.info('Elapsed time: %.2f s. Elapsed time per trial: %.2f ms.' % (dt, dt / num_trials * 1000)) s = TrialScores(enroll, ndx.seg_set, scores) s.save(score_file)
def convert(input_file, output_file, class_file): r = DRF.create(input_file) seg_set, score_mat = r.read(0, squeeze=True) with open(class_file, 'r') as f: model_set = [line.rstrip().split()[0] for line in f] scores = TrialScores(model_set, seg_set, score_mat.T) scores.save(output_file)
def eval_pdda(iv_file, ndx_file, enroll_file, test_file, preproc_file, model_file, score_file, pool_method, eval_method, num_samples_y, num_samples_z, num_samples_elbo, qy_only, **kwargs): set_float_cpu('float32') if preproc_file is not None: preproc = TransformList.load(preproc_file) else: preproc = None tdr_args = TDR.filter_args(**kwargs) tdr = TDR(iv_file, ndx_file, enroll_file, test_file, preproc, **tdt_args) x_e, x_t, enroll, ndx = tdr.read() enroll, ids_e = np.unique(enroll, return_inverse=True) if qy_only: model = TVAEY.load(model_file) model.build(max_seq_length=2, num_samples=num_samples_y) else: model = TVAEYZ.load(model_file) model.build(max_seq_length=2, num_samples_y=num_samples_y, num_samples_z=num_samples_z) t1 = time.time() scores = model.eval_llr_Nvs1(x_e, ids_e, x_t, pool_method=pool_method, eval_method=eval_method, num_samples=num_samples_elbo) dt = time.time() - t1 num_trials = len(enroll) * x_t.shape[0] logging.info('Elapsed time: %.2f s. Elapsed time per trial: %.2f ms.' % (dt, dt/num_trials*1000)) s = TrialScores(enroll, ndx.seg_set, scores) s.save(score_file)