diff options
Diffstat (limited to 'crop-thirds.py')
| -rw-r--r-- | crop-thirds.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/crop-thirds.py b/crop-thirds.py index 670dbb2..1a9ea34 100644 --- a/crop-thirds.py +++ b/crop-thirds.py @@ -25,7 +25,7 @@ parser.add_argument('--max', type=int, default=0) parser.add_argument('--aspect', type=float, default=3.0) # parser.add_argument('--folder_id', type=int, required=True) parser.add_argument('--overlap', type=float, default=0.5) -parser.add_argument('--clobber', action='store_false') +parser.add_argument('--no_clobber', action='store_false') opt = parser.parse_args() src_width = 1024 @@ -38,14 +38,16 @@ y0 = opt.vertical_offset - dst_height / 2 crops = [] paths = [] +out_path = os.path.join(opt.out_dir, opt.label) + +if not opt.no_clobber: + if os.path.exists(out_path): + rmtree(out_path) for i in range(opt.count): x = int(i / opt.count * dst_width) crops.append((x, y0, x + dst_width, y0 + dst_height,)) - path = os.path.join(opt.out_dir, opt.label, chr(97 + i)) - if opt.clobber: - if os.path.exists(path): - rmtree(path) + path = os.path.join(out_path, chr(97 + i)) os.makedirs(path) paths.append(path) @@ -55,7 +57,7 @@ for i, fn in enumerate(sorted(glob.glob(os.path.join(opt.folder, '*.png')))): if i > max_i: break out_fn = "frame_{:05d}.png".format(i + 1) - if not opt.clobber and os.path.exists(os.path.join(paths[0], out_fn)): + if opt.no_clobber and os.path.exists(os.path.join(paths[0], out_fn)): continue dataset.append((i, fn,)) |
