diff options
| author | jules <jules@asdf.us> | 2019-01-17 22:10:14 +0100 |
|---|---|---|
| committer | jules <jules@asdf.us> | 2019-01-17 22:10:14 +0100 |
| commit | 9325a3fa43b65ed6b5c69b95128db9c0a10d17b4 (patch) | |
| tree | 018122720744919aad28a76598233f4c458dfa2a | |
| parent | 2085a45ca753ac5fbcec677298442eb5a789c1c1 (diff) | |
fixes
| -rw-r--r-- | crop_frames.py | 9 | ||||
| -rw-r--r-- | merge_frames.py | 1 | ||||
| -rw-r--r-- | test.py | 8 |
3 files changed, 13 insertions, 5 deletions
diff --git a/crop_frames.py b/crop_frames.py index 0773e86..6ce54d8 100644 --- a/crop_frames.py +++ b/crop_frames.py @@ -31,8 +31,9 @@ def crop_dir(): else: height = round(width / args.ratio) top_offset = round((old_height - height) / 2) + print('top offset: {}'.format(top_offset)) - print("{}x{} {}".format(width, height, step)) + print("{}x{}, step {}".format(width, height, step)) for x in range(0, width, step): for y in range(0, height, step): xx = max(0, x - overlap) @@ -40,17 +41,18 @@ def crop_dir(): w = min(side, width - xx) h = min(side, height - yy) crop_dir = "{}/crop_{}_{}_{}_{}".format(args.out_dir, x, y, w, h) + print(crop_dir) if os.path.exists(crop_dir): rmtree(crop_dir) os.makedirs(crop_dir) dataset = [] - for raw_fn in files: + for i, raw_fn in enumerate(sorted(files)): fn, ext = os.path.splitext(os.path.basename(raw_fn)) partz = fn.split('_') try: num = int(partz[-1].replace('.png', '')) - if num >= opt.start and num <= opt.end: + if i >= args.start and i <= args.end: dataset.append((raw_fn, width, height, step, side, overlap, top_offset,)) except: pass @@ -71,6 +73,7 @@ def crop_image(raw_fn, width, height, step, side, overlap, top_offset): crop_dir = "{}/crop_{}_{}_{}_{}".format(args.out_dir, x, y, w, h) # print("{}x{} {}x{}".format(x, y, w, h)) crop = img.crop((xx, yy + top_offset, xx + w, yy + h + top_offset)) + print("{}/{}".format(crop_dir, fn)) crop.save("{}/{}".format(crop_dir, fn)) if __name__ == "__main__": diff --git a/merge_frames.py b/merge_frames.py index 5d42950..3626c6f 100644 --- a/merge_frames.py +++ b/merge_frames.py @@ -2,6 +2,7 @@ import os import argparse import glob import operator +import subprocess from multiprocessing import Pool, cpu_count from shutil import rmtree from PIL import Image @@ -18,7 +18,7 @@ parser.add_argument('--L', metavar='L', type=int, default=28, help='Network dept parser.add_argument('--T', metavar='T', default='L', help='Input type: L(Low-resolution) or G(Ground-truth)') parser.add_argument('--dataset', default=None, help='Name of dataset') parser.add_argument('--in_dir', metavar='in_dir', default=None, help='Directory to process') -parser.add_argument('--out_dir', metavar='out_dir', default='./results', help='Directory to output to') +parser.add_argument('--out_dir', metavar='out_dir', default='./results/test', help='Directory to output to') parser.add_argument('--network_dir', default='.', help='Path to networks') parser.add_argument('--mov_from_dirs', action='store_true') args = parser.parse_args() @@ -47,13 +47,17 @@ def process_dir(dir): dataset = args.dataset = dir_partz[-2] part = dir_partz[-1] tag = '_'.join([dataset, str(args.L) + 'L', part]) - out_path = os.path.join(args.out_dir, dataset, part) + out_path = os.path.join(args.out_dir, part) render_path = os.path.join(args.out_dir, 'renders') + print('process dir {}, out path: {}'.format(dir, out_path)) os.makedirs(out_path, exist_ok=True) if args.mov_from_dirs: os.makedirs(render_path, exist_ok=True) dir_frames = sorted(glob.glob(os.path.join(dir, '*.png'))) + if not len(dir_frames): + print("{}: no frames!".format(dir)) + return # print(dir_frames) frames = [] |
