diff options
| -rw-r--r-- | test.py | 49 |
1 files changed, 24 insertions, 25 deletions
@@ -36,6 +36,30 @@ if not(args.T == 'L' or args.T =='G'): print('Invalid input type: {} (Must be L(Low-resolution) or G(Ground-truth))'.format(args.T)) exit(1) +def process_dir(v): + scene_name = v.split('/')[-1] + os.mkdir('./results/{}L/L/{}/'.format(args.L, scene_name)) + + dir_frames = glob.glob(v + '/*.png') + dir_frames.sort() + + frames = [] + for f in dir_frames: + frames.append(LoadImage(f)) + frames = np.asarray(frames) + frames_padded = np.lib.pad(frames, pad_width=((T_in//2,T_in//2),(0,0),(0,0),(0,0)), mode='constant') + + for i in range(frames.shape[0]): + print('Scene {}: Frame {}/{} processing'.format(scene_name, i+1, frames.shape[0])) + in_L = frames_padded[i:i+T_in] # select T_in frames + in_L = in_L[np.newaxis,:,:,:,:] + + out_H = sess.run(GH, feed_dict={L: in_L, is_train: False}) + out_H = np.clip(out_H, 0, 1) + + Image.fromarray(np.around(out_H[0,0]*255).astype(np.uint8)).save('./results/{}L/L/{}/Frame{:03d}.png'.format(args.L, scene_name, i+1)) + + def G(x, is_train): # shape of x: [B,T_in,H,W,C] @@ -137,28 +161,3 @@ with tf.Session(config=config) as sess: dir_inputs = glob.glob('./inputs/L/*') for v in dir_inputs: process_dir(v) - -def process_dir(v): - scene_name = v.split('/')[-1] - os.mkdir('./results/{}L/L/{}/'.format(args.L, scene_name)) - - dir_frames = glob.glob(v + '/*.png') - dir_frames.sort() - - frames = [] - for f in dir_frames: - frames.append(LoadImage(f)) - frames = np.asarray(frames) - frames_padded = np.lib.pad(frames, pad_width=((T_in//2,T_in//2),(0,0),(0,0),(0,0)), mode='constant') - - for i in range(frames.shape[0]): - print('Scene {}: Frame {}/{} processing'.format(scene_name, i+1, frames.shape[0])) - in_L = frames_padded[i:i+T_in] # select T_in frames - in_L = in_L[np.newaxis,:,:,:,:] - - out_H = sess.run(GH, feed_dict={L: in_L, is_train: False}) - out_H = np.clip(out_H, 0, 1) - - Image.fromarray(np.around(out_H[0,0]*255).astype(np.uint8)).save('./results/{}L/L/{}/Frame{:03d}.png'.format(args.L, scene_name, i+1)) - - |
