From 1a88fee6a7bab0a25f2e4e7a0857adc70376ea51 Mon Sep 17 00:00:00 2001 From: "jules@lens" Date: Sun, 18 Nov 2018 21:21:11 +0100 Subject: move thing up --- test.py | 49 ++++++++++++++++++++++++------------------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/test.py b/test.py index 3347063..d1b74d2 100644 --- a/test.py +++ b/test.py @@ -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)) - - -- cgit v1.2.3-70-g09d2