def main(): nr_person = 20 fpaths = get_training_data_fpaths() X_train, y_train, X_test, y_test = datautil.read_data(fpaths, nr_person) print("loading gmms ...") gmmset = load_gmmset(y_train, nr_person) # ubm = GMM.load(config.ubm_model_file) # ubm = None # gmmset = GMMSet(32,ubm=ubm, concurrency=8, # verbosity=1, nr_iteration=100, # threshold=1e-2) # gmmset.fit(X_train, y_train) print("predicting ...") import time start = time.time() import cProfile y_pred = gmmset.predict(X_test) print(time.time() - start) nr_total = len(y_test) nr_correct = len(filter(lambda x: x[0] == x[1], zip(y_pred, y_test))) print("{} {}/{}".format(float(nr_correct) / nr_total, nr_correct, nr_total)) print("nr_person: {}".format(nr_person))
def main(): nr_person = 20 fpaths = get_training_data_fpaths() X_train, y_train, X_test, y_test = datautil.read_data( fpaths, nr_person) print "loading gmms ..." gmmset = load_gmmset(y_train, nr_person) # print "training ..." # ubm = GMM.load(config.ubm_model_file) # ubm = None # gmmset = GMMSet(32,ubm=ubm, concurrency=8, # verbosity=1, nr_iteration=100, # threshold=1e-2) # gmmset.fit(X_train, y_train) print "predicting ..." import time start = time.time() import cProfile y_pred = gmmset.predict(X_test) print time.time() - start nr_total = len(y_test) nr_correct = len(filter(lambda x: x[0] == x[1], zip(y_pred, y_test))) print "{} {}/{}" . format( float(nr_correct) / nr_total, nr_correct, nr_total) print "nr_person: {}" . format(nr_person)
def main(): nr_person = 50 fpaths = get_training_data_fpaths() X_train, y_train, X_test, y_test = datautil.read_data(fpaths, nr_person) ubm = GMM.load("model/ubm-32.model") for x, y in zip(X_train, y_train): gmm = GMM(concurrency=8, threshold=0.01, nr_iteration=100, verbosity=1) gmm.fit(x, ubm=ubm) gmm.dump("model/" + y + ".32.model")
def main(): nr_person = 50 fpaths = get_training_data_fpaths() X_train, y_train, X_test, y_test = datautil.read_data(fpaths, nr_person) ubm = GMM.load('model/ubm-32.model') for x, y in zip(X_train, y_train): gmm = GMM(concurrency=8, threshold=0.01, nr_iteration=100, verbosity=1) gmm.fit(x, ubm=ubm) gmm.dump("model/" + y + ".32.model")
def main(datapath, ubmpath, gmmPath): fpaths = get_training_data_fpaths(datapath) # print "The fpath is :",fpaths X_train, y_train = datautil.read_data(fpaths) ubm = GMM.load(ubmpath) for x, y in zip(X_train, y_train): gmm = GMM(concurrency=8, threshold=0.01, nr_iteration=100, verbosity=1) start = time.time() gmm.fit(x, ubm=ubm) # score = gmm.score(X_train[0]) # print(gmm.weights_) # score_ubm = ubm.score(X_train[0]) # print(sum(score)) # print(sum(score_ubm)) # score_all = gmm.score_all(X_train[6]) # score_all_ubm = ubm.score_all(X_train[6]) # print(str(score_all) + " score_all") # print(str(score_all_ubm) + " score_all") # print(str(score_all/score_all_ubm) + " score_all") end = time.time() print(str(end - start) + " seconds") gmm.dump(os.path.join(gmmPath, y + ".model")) print(os.path.join(gmmPath, y + ".model"))