From f5bc26404eba5462e8614f5dbbfd0e43b3bbb1f7 Mon Sep 17 00:00:00 2001 From: nayansinghal Date: Mon, 28 Nov 2016 01:36:48 -0600 Subject: [PATCH] Move topk and bottom_k images to output folder --- util/move_files.py | 59 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 util/move_files.py diff --git a/util/move_files.py b/util/move_files.py new file mode 100644 index 0000000..6902681 --- /dev/null +++ b/util/move_files.py @@ -0,0 +1,59 @@ +import numpy as np +import skimage.transform +import skimage.color as color +import scipy.ndimage.interpolation as sni +import os +import matplotlib +matplotlib.use('Agg') +import matplotlib.pyplot as plt +import heapq as heap +from tqdm import tqdm +from shutil import copyfile +import argparse + +import sys +import os + +parser = argparse.ArgumentParser() +parser.add_argument('--log') +parser.add_argument('--save', default='Testing/output') +parser.add_argument('--fpath', default = 'Testing/evalPerReference_3_v5') +opt = parser.parse_args() + +if not os.path.exists(opt.save): #check if directory exists + os.makedirs(opt.save) + +pDir = opt.save +cDir ='' +with open(opt.log, 'r') as f: + for line in f: + if('Euclidean' in line): + pDir = os.path.join(opt.save,'Euclidean') + if not os.path.exists(pDir): + os.makedirs(pDir) + continue + elif('Softmax' in line): + pDir = os.path.join(opt.save,'Softmax') + if not os.path.exists(pDir): + os.makedirs(pDir) + continue + + if('Largest' in line): + cDir = 'Largest' + if not os.path.exists(os.path.join(pDir, cDir)): + os.makedirs(os.path.join(pDir, cDir)) + continue + elif('Smallest' in line): + cDir = 'Smallest' + if not os.path.exists(os.path.join(pDir, cDir)): + os.makedirs(os.path.join(pDir, cDir)) + continue + + try: + line = line.rstrip('\n') + line = os.path.join(opt.fpath, line) + filepath = os.path.join(pDir,cDir, line.split('/')[-1]) + copyfile(line, filepath) + + except: + continue