Beispiel #1
0
def img_dataset(in_path):
    img_dict={}
    for path_i in files.top_files(in_path):
        name_i=files.clean_str(path_i.split("/")[-1])
        img_i=cv2.imread(path_i, cv2.IMREAD_GRAYSCALE)
        img_i=np.expand_dims(img_i,-1)
        img_dict[name_i]=img_i
    print(img_dict.keys())
    return img_dict
Beispiel #2
0
def read_frames(seq_path_i, as_dict=False):
    if (as_dict):
        return {
            files.clean_str(path_j): cv2.imread(path_j, cv2.IMREAD_GRAYSCALE)
            for path_j in files.top_files(seq_path_i)
        }
    return [
        cv2.imread(path_j, cv2.IMREAD_GRAYSCALE)
        for path_j in files.top_files(seq_path_i)
    ]
Beispiel #3
0
def read_frame_feats(in_path):
    seq_dict = {}
    for path_i in files.top_files(in_path):
        postfix = in_path.split(".")[-1]
        if (postfix == "npy"):
            seq_i = np.loadtxt(path_i, delimiter=',')
        else:
            seq_i = np.load(path_i)
        name_i = files.clean_str(path_i.split('/')[-1])
        seq_dict[name_i] = seq_i
    return seq_dict
Beispiel #4
0
def read_single(in_path, as_dict=True):
    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.clean_str(info_i)
            feat_dict[info_i] = np.fromstring(data_i, sep=',')
    if (as_dict):
        return feat_dict
    return from_dict(feat_dict)
Beispiel #5
0
def ts_plot(in_path, out_path):
    seqs = {
        files.clean_str(path_i): np.load(path_i)
        for path_i in files.top_files(in_path)
    }
    files.make_dir(out_path)
    for name_i, seq_i in seqs.items():
        out_i = "%s/%s" % (out_path, name_i)
        files.make_dir(out_i)
        for j, ts_j in enumerate(seq_i.T):
            out_ij = "%s/%d" % (out_i, j)
            print(out_ij)
            fig = plt.figure()
            #            plt.clf()
            ax = plt.axes()
            x = range(ts_j.shape[0])
            ax.plot(x, ts_j)
            plt.savefig(out_ij)
            plt.close()
Beispiel #6
0
def get_len_dict(seq_dict):
    return {
        files.clean_str(name_i): len(seq_i)
        for name_i, seq_i in seq_dict.items()
    }