예제 #1
0
def show_frames(frame_path, dir_path):
    paths = files.get_paths(dir_path, ["actions", "bounds"])
    action_imgs.mean_action(frame_path, paths["actions"], dims=None)
    tools.cut_actions(paths["actions"],
                      paths["bounds"],
                      scale=None,
                      binary=True)
예제 #2
0
def reg_pretrain(in_path, reg_epochs=3000, clf_epochs=1000):
    post = ['seqs', 'spline', 'stats', 'feats', 'reg_nn', 'clf_nn']
    paths = files.get_paths(in_path, post)
    spline.ens_upsample(paths['seqs'], paths["spline"])
    stats.ens_stats(paths['seqs'], paths['stats'])

    train_reg(paths['spline'], paths['stats'], paths['reg_nn'], 3000)
    pretrain_clf(paths['reg_nn'], paths['spline'], paths['clf_nn'], clf_epochs)
    basic.ts.ens_extract(paths["spline"], paths["clf_nn"], paths["feats"])
예제 #3
0
def agum_exp(input_path, out_path, n_epochs=1000):
    files.make_dir(out_path)
    paths = files.get_paths(out_path, ["spline", "agum", "nn", "feats"])
    spline.upsample(input_path, paths["spline"], size=64)
    agum = Agum([ts_scale, magnitude_warp])
    agum(paths["spline"], paths["agum"])
    train, extract = ts_cnn.get_train()
    train(paths["agum"], paths["nn"], n_epochs)
    extract(paths["agum"], paths["nn"], paths["feats"])
예제 #4
0
파일: voting.py 프로젝트: tjacek/dtw_feats
def voting(in_path):
    paths = files.get_paths(in_path, name="pairs")
    dtw_pairs = read_pairs(paths)
    pref_dicts = [get_preferences(pairs_i) for pairs_i in dtw_pairs]
    names = pref_dicts[0].keys()

    y_pred, y_true = [], []
    for name_i in names:
        y_true.append(name_i.get_cat())
        votes = [pref_j[name_i] for pref_j in pref_dicts]
        y_pred.append(border_count(votes))
    print(accuracy_score(y_true, y_pred))
예제 #5
0
 def __call__(self, input_paths, out_path, arg_dict):
     dirs = files.get_paths(out_path, self.dir_names)
     for dir_i in dirs.values():
         files.make_dir(dir_i)
     for path_i in input_paths:
         name_i = path_i.split('/')[-1]
         args_i = {
             key_i: "%s/%s" % (path_i, name_i)
             for key_i, path_i in dirs.items()
         }
         args_i = {**args_i, **arg_dict}
         args_i[self.input_dir] = path_i
         for fun, arg_names in self.funcs:
             fun_args = [args_i[name_k] for name_k in arg_names]
             fun(*fun_args)
예제 #6
0
def basic_paths(dataset, dir_path, common, binary, name="dtw"):
    paths = {}
    paths["dir_path"] = "%s/%s" % (dir_path, dataset)
    common = "%s/%s" % (paths["dir_path"], common)
    paths["common"] = files.get_paths(common, name=name)
    if (binary):
        paths["binary"] = "%s/%s" % (paths["dir_path"], binary)
    else:
        paths["binary"] = None
    return paths


#def common_paths(common,binary):
#	common=files.top_files(common)
#	datasets=[ common_i.split('/')[-1].split("_")[0]
#				for common_i in common]
#	binary=[ binary % data_i  for data_i in datasets]
#	return list(zip(common,binary))
예제 #7
0
def ae_exp(in_path, out_path, n_epochs=5):
    files.make_dir(out_path)
    paths = files.get_paths(out_path, ["ae", "seqs"])
    train_ae(in_path, paths['ae'], n_epochs)
    extract(in_path, paths['ae'], paths['seqs'])
예제 #8
0
    default=config.NUM_SCREENSHOTS,
    help='number of screenshots to save and upload',
)
parser.add_argument(
    '-d',
    '--delete-unwanted-files',
    dest='delete_unwanted_files',
    action='store_true',
    default=config.DELETE_UNWANTED_FILES,
    help='delete files that are not whitelisted by the tracker (such as .rar files)',
)
args = parser.parse_args()


# Every argument to this script is treated as a path to a release to be uploaded
release_list = files.get_paths(args.file_list)

if len(release_list) == 0:
    logging.critical('You must give this script at least one file or directory to process!')
    sys.exit(1)

for path in release_list:

    # Log exceptions but don't raise them; just continue

    try:

        if isinstance(path, bytes):
            path = path.decode('utf-8')
        files.set_log_file_name(os.path.basename(path) + '.log')
        upload = uploads.Upload(
예제 #9
0
def action_img_exp(in_path, n_epochs=100):
    paths = files.get_paths(in_path, ['frames', 'mean', "ens"])
    mean_action(paths["frames"], paths["mean"])
    action_one_shot(paths["mean"], paths["action"], n_epochs)
예제 #10
0
파일: ts.py 프로젝트: tjacek/dtw_feats
def make_reduced_dataset(common, out_path, n_feats=350):
    common = files.get_paths(common)
    dataset = ens.read_dataset(common, None)[0]
    dataset.norm()
    redu_data = reduction.reduce(dataset, n_feats)
    redu_data.save(out_path)
예제 #11
0
def lstm_exp(in_path, out_path, n_epochs=200, seq_len=20, static=True):
    files.make_dir(out_path)
    paths = files.get_paths(out_path, ["nn", "feats"])
    train_lstm(in_path, paths['nn'], n_epochs, seq_len, static=static)
    extract(in_path, paths['nn'], paths['feats'], seq_len)
예제 #12
0
def floor_exp(action_path, frame_path, dataset_path, out_path, n_epochs=750):
    files.make_dir(out_path)
    paths = files.get_paths(out_path, ["nn", "frames", "actions"])
    train(action_path, dataset_path, paths["nn"], n_epochs)
    apply_model(frame_path, paths["nn"], paths["frames"])
    action_imgs.mean_action(paths["frames"], paths["actions"], None)
예제 #13
0
def agum_exp(in_path, n_epochs=100):
    paths = files.get_paths(in_path, ['box', 'filtr_nn', 'frames'])
    train_model(paths["box"], paths["filtr_nn"], n_epochs)
    filtr_seqs(paths["box"], paths["filtr_nn"], paths["frames"])
예제 #14
0
    default=config.NUM_SCREENSHOTS,
    help='number of screenshots to save and upload',
)
parser.add_argument(
    '-d',
    '--delete-unwanted-files',
    dest='delete_unwanted_files',
    action='store_true',
    default=config.DELETE_UNWANTED_FILES,
    help=
    'delete files that are not whitelisted by the tracker (such as .rar files)',
)
args = parser.parse_args()

# Every argument to this script is treated as a path to a release to be uploaded
release_list = files.get_paths(args.file_list)

if len(release_list) == 0:
    logging.critical(
        'You must give this script at least one file or directory to process!')
    sys.exit(1)

for path in release_list:

    # Log exceptions but don't raise them; just continue

    try:

        if isinstance(path, bytes):
            path = path.decode('utf-8')
        files.set_log_file_name(os.path.basename(path) + '.log')
예제 #15
0
	clf = linear_model.Lasso(alpha=0.001,max_iter=1000)
	clf.fit(X_train,y_train)
	model = SelectFromModel(clf, prefit=True)
	new_X= model.transform(X)
	return new_X

def recursive(train_i,full_i,n=84):
	X_train,y_train,names_train=train_i.as_dataset()
	svc = SVC(kernel='linear',C=1)
	rfe = RFE(estimator=svc,n_features_to_select=n,step=10)
	rfe.fit(X_train,y_train)
	X,y,names=full_i.as_dataset()
	new_X= rfe.transform(X)
	return new_X

def selected_common(common_path,out_path,n=100):
	dataset=ens.read_dataset(common_path,None)[0]
	dataset.norm()
	new_data=reduce(dataset,n)
	new_data.save(out_path)

if __name__ == "__main__":
	dataset="MHAD"
	dir_path="../ICSS_exp/%s" % dataset
	common="%s/dtw" % dir_path
	common=files.get_paths(common,name="dtw")
	common.append("%s/common/1D_CNN/feats" % dir_path)
	binary="%s/ens/lstm/feats" % dir_path 
	acc=acc_curve(common,binary,clf="SVC",n=20,step=50)
	n=150
#	selected_common(common,"s_feats/%s_%d" % (dataset,n),n)
예제 #16
0
def sampled_exp(in_path, out_path, n_samples=3, n_epochs=5):
    files.make_dir(out_path)
    paths = files.get_paths(out_path, ["nn", "seqs"])
    train(in_path, paths["nn"], n_samples, n_epochs)
    extract(in_path, paths['nn'], paths['seqs'])
예제 #17
0
파일: voting.py 프로젝트: tjacek/dtw_feats
def basic_exp(in_path):
    paths = files.get_paths(in_path, name="dtw")
    result = ens.ensemble(paths[0], None, clf="LR", binary=False)[0]
    result.report()
예제 #18
0
def dtw_exp(seq_path,out_path):
	files.make_dir(out_path)
	paths=files.get_paths(out_path,["pairs","dtw"])
	dtw.pairs.compute_pairs(seq_path,paths["pairs"])
	compute_feats(paths["pairs"],paths["dtw"])