示例#1
0
def read_frame_seqs(in_path, n_split=1):
    frame_seqs = FrameSeqs()
    for i, path_i in enumerate(files.top_files(in_path)):
        name_i = files.Name(path_i.split('/')[-1]).clean()
        if (len(name_i) == 0):
            name_i = files.Name(str(i))
        frames = [
            read_frame(path_j, n_split) for path_j in files.top_files(path_i)
        ]
        frame_seqs[name_i] = frames
    return frame_seqs
示例#2
0
def split_each_label(in_path,out_path,train_size=0.8):
    frames=data.imgs.read_frame_seqs(in_path)
    new_frames=data.imgs.FrameSeqs()
    for name_i,seq_i in frames.items():
        split_size= int(len(seq_i) *(1.0-train_size))
        n_split=int(len(seq_i) /split_size) 
        for j in range(n_split-1):
            seq_j=seq_i[j*split_size:(j+1)*split_size]
            name_j=files.Name("%d_1_%d" % (int(name_i),j))
            new_frames[name_j]=seq_j
            print(name_j)
        seq_j=seq_i[(n_split-1)*split_size: ]
        name_j=files.Name("%d_2_%d" % (int(name_i),0))
        new_frames[name_j]=seq_j
    new_frames.scale()
    new_frames.save(out_path)
示例#3
0
def read_actions(in_path):
    actions = ActionImgs()
    for path_i in files.top_files(in_path):
        name_i = files.Name(path_i.split('/')[-1])
        name_i = name_i.clean()
        actions[name_i] = cv2.imread(path_i, cv2.IMREAD_GRAYSCALE)
    return actions
示例#4
0
def read_seqs(in_path):
	seqs=Seqs()
	for path_i in files.top_files(in_path):
		data_i=np.loadtxt(path_i, delimiter=',')
		name_i=path_i.split('/')[-1]
		name_i=files.Name(name_i).clean()#clean(name_i)
		seqs[name_i]=data_i
	return seqs
示例#5
0
def read_seqs(in_path):
    paths = files.top_files(in_path)
    seq_dict = Seqs()
    for path_i in paths:
        data_i = np.load(path_i)
        name_i = path_i.split('/')[-1]
        name_i = files.Name(name_i).clean()
        seq_dict[name_i] = data_i
    return seq_dict
示例#6
0
文件: feats.py 项目: tjacek/dtw_feats
def read_single(in_path):
    lines = open(in_path, 'r').readlines()
    feat_dict = {}
    for line_i in lines:
        raw = line_i.split('#')
        if (len(raw) > 1):
            data_i, info_i = raw[0], raw[-1]
            info_i = files.Name(info_i).clean()  #files.clean_str(info_i)
            x_i = np.fromstring(data_i, sep=',')
            x_i = np.nan_to_num(x_i, nan=0.0, posinf=0.0, neginf=0.0)
            feat_dict[info_i] = x_i
    return Feats(feat_dict)
示例#7
0
def read_feats(in_path):
    if (type(in_path) == list):
        all_feats = [read_feats(path_i) for path_i in in_path]
        return concat_feats(all_feats)
    lines = open(in_path, 'r').readlines()
    feat_dict = Feats()
    for line_i in lines:
        raw = line_i.split('#')
        if (len(raw) > 1):
            data_i, info_i = raw[0], files.Name(raw[-1])
            info_i = info_i.clean()
            feat_dict[info_i] = np.fromstring(data_i, sep=',')
    return feat_dict
示例#8
0
def read_pairs(in_path):
    if (type(in_path) == list):
        return [read_pairs(path_i) for path_i in in_path]
    raw_i = pairs.read(in_path)
    dict_i = {files.Name(name_i): data_i for name_i, data_i in raw_i.items()}
    return pairs.DTWpairs(dict_i)
示例#9
0
def read_rename(id):
    rename = json.load(open("%s.json" % id))
    return {
        files.Name(name_i): files.Name(rename_i)
        for name_i, rename_i in rename.items()
    }
示例#10
0
文件: feats.py 项目: tjacek/dtw_feats
 def rename(self, name_dict):
     new_feats = Feats()
     for name_i, name_j in name_dict.items():
         new_feats[files.Name(name_j)] = self[name_i]
     return new_feats