summaryrefslogtreecommitdiff
path: root/crop_frames.py
diff options
context:
space:
mode:
Diffstat (limited to 'crop_frames.py')
-rw-r--r--crop_frames.py13
1 files changed, 11 insertions, 2 deletions
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: