Showing
1 changed file
with
38 additions
and
0 deletions
make_testset.py
0 → 100644
| 1 | +import os | ||
| 2 | +import numpy as np | ||
| 3 | +from imageio import imread | ||
| 4 | +from skimage.transform import resize | ||
| 5 | +import hickle as hkl | ||
| 6 | +from setting import * | ||
| 7 | + | ||
| 8 | +desired_im_sz = (128, 160) #높이,너비 | ||
| 9 | + | ||
| 10 | +base_dir = os.path.join(DATA_DIR, 'testset/') | ||
| 11 | +im_list = [] | ||
| 12 | +source_list = [] # corresponds to recording that image came from | ||
| 13 | +X_t = [] | ||
| 14 | + | ||
| 15 | +for top, dir, f in os.walk(base_dir): | ||
| 16 | + if(len(f) > 0): | ||
| 17 | + f.sort() | ||
| 18 | + im_list += [top + '/' + f[idx] for idx in range(len(f))] | ||
| 19 | + start = top.rfind('/') | ||
| 20 | + source_list += [top[start+1:]] * 11 | ||
| 21 | + | ||
| 22 | +print(len(im_list)) | ||
| 23 | + | ||
| 24 | + | ||
| 25 | +# X_t = np.zeros((len(im_list),) + desired_im_sz + (3,)) | ||
| 26 | +for i, im_file in enumerate(im_list): | ||
| 27 | + im = imread(im_file) | ||
| 28 | + im = resize(im, (desired_im_sz[0], desired_im_sz[1])) | ||
| 29 | + X_t.append(im) | ||
| 30 | + | ||
| 31 | +X_t = np.array(X_t) | ||
| 32 | + | ||
| 33 | +hkl.dump(X_t, os.path.join(DATA_DIR, 'X_test.hkl')) | ||
| 34 | +hkl.dump(source_list, os.path.join(DATA_DIR, 'sources_test.hkl')) | ||
| 35 | + | ||
| 36 | + | ||
| 37 | +# np.save(DATA_DIR + 'X_test', X_t) | ||
| 38 | +# np.save(DATA_DIR + 'sources_test', source_list) | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or login to post a comment