From 9325a3fa43b65ed6b5c69b95128db9c0a10d17b4 Mon Sep 17 00:00:00 2001 From: jules Date: Thu, 17 Jan 2019 22:10:14 +0100 Subject: fixes --- crop_frames.py | 9 ++++++--- merge_frames.py | 1 + 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 diff --git a/test.py b/test.py index 3847b3f..ec88299 100644 --- a/test.py +++ b/test.py @@ -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 = [] -- cgit v1.2.3-70-g09d2