Skip to content

Commit

Permalink
Fix config to use new arg names for augmentations
Browse files Browse the repository at this point in the history
  • Loading branch information
TimKoornstra committed Mar 5, 2024
1 parent 5060d19 commit 749fe75
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
21 changes: 12 additions & 9 deletions src/setup/arg_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,11 @@ def get_arg_parser():
augmentation_args.add_argument('--aug_multiply', '--multiply',
metavar='multiply', type=int,
dest='multiply',
default=1, help="Factor to increase the "
"size of the training dataset by "
"duplicating images. Default: 1 (no "
"duplication).")
default=1,
help="Factor to increase the "
"size of the training dataset by "
"duplicating images. Default: 1 (no "
"duplication).")
augmentation_args.add_argument('--aug_elastic_transform',
'--elastic_transform', action='store_true',
dest='elastic_transform',
Expand Down Expand Up @@ -210,12 +211,14 @@ def get_arg_parser():
help="Apply Otsu's binarization method to "
"images for augmentation.")
augmentation_args.add_argument('--aug_binarize_sauvola',
'--do_binarize_sauvola', action='store_true',
'--do_binarize_sauvola',
action='store_true',
dest='do_binarize_sauvola',
help="Use Sauvola's method for image binarization during "
"augmentation.")
help="Use Sauvola's method for image "
"binarization during augmentation.")
augmentation_args.add_argument('--visualize_augments',
'--visualize_augments', action='store_true',
'--visualize_augments',
action='store_true',
dest='visualize_augments',
help='Prompt to create visualization of '
'selected augments')
Expand Down Expand Up @@ -339,7 +342,7 @@ def arg_future_warning(args):
'do_binarize_otsu', 'do_binarize_sauvola']
for old_arg in old_arg_names:
if getattr(args, old_arg, None) is not None:
new_arg_name = old_arg.replace("do_","")
new_arg_name = old_arg.replace("do_", "")
logger.warning(f"Argument will lose support in May 2024: "
f"--{old_arg}. Use --aug_{new_arg_name} instead.")

Expand Down
20 changes: 10 additions & 10 deletions src/setup/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,16 +186,16 @@ def organize_args(self, args: argparse.Namespace) -> dict:
"freeze_dense_layers": args.freeze_dense_layers
},
"augmentation": {
"multiply": args.multiply,
"elastic_transform": args.elastic_transform,
"random_crop": args.random_crop,
"random_width": args.random_width,
"distort_jpeg": args.distort_jpeg,
"do_random_shear": args.do_random_shear,
"do_blur": args.do_blur,
"do_invert": args.do_invert,
"do_binarize_otsu": args.do_binarize_otsu,
"do_binarize_sauvola": args.do_binarize_sauvola,
"aug_multiply": args.aug_multiply,
"aug_elastic_transform": args.aug_elastic_transform,
"aug_random_crop": args.aug_random_crop,
"aug_random_width": args.aug_random_width,
"aug_distort_jpeg": args.aug_distort_jpeg,
"aug_random_shear": args.aug_random_shear,
"aug_blur": args.aug_blur,
"aug_invert": args.aug_invert,
"aug_binarize_otsu": args.aug_binarize_otsu,
"aug_binarize_sauvola": args.aug_binarize_sauvola,
"visualize_augments": args.visualize_augments
},
"decoding": {
Expand Down

0 comments on commit 749fe75

Please sign in to comment.