From a8e994a32e481f667424fc55bffa16f8cd1e2b04 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Wed, 16 Jan 2019 01:59:41 +0100 Subject: start/end --- crop_frames.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'crop_frames.py') diff --git a/crop_frames.py b/crop_frames.py index 0f700b8..dd8c1e6 100644 --- a/crop_frames.py +++ b/crop_frames.py @@ -9,9 +9,11 @@ from PIL import Image parser = argparse.ArgumentParser() parser.add_argument('--step', default=192, type=int, help='Width of frames') parser.add_argument('--overlap', default=2, type=int, help='Expand all frames by this margin') -parser.add_argument('--ratio', default=2, type=int, help='Pre-crop frames to this ratio') +parser.add_argument('--ratio', default=2.0, type=float, help='Pre-crop frames to this ratio') parser.add_argument('--in_dir', help='Directory to process') parser.add_argument('--out_dir', default='inputs', help='Directory to output crops to') +parser.add_argument('--start', default=0, type=int, help='Minimum frame number') +parser.add_argument('--end', default=99999, type=int, help='Maximum frame number') args = parser.parse_args() def crop_dir(): @@ -43,7 +45,14 @@ def crop_dir(): dataset = [] for raw_fn in files: - dataset.append((raw_fn, width, height, step, side, overlap, top_offset,)) + fn, ext = os.path.splitext(os.path.basename(raw_fn)) + partz = fn.split('_') + try: + num = int(partz[-1].replace('.png', '')) + if num >= start and num <= end: + dataset.append((raw_fn, width, height, step, side, overlap, top_offset,)) + except: + pass chunksize = 3 with Pool(processes=cpu_count()) as pool: -- cgit v1.2.3-70-g09d2