| 18 | |
| 19 | |
| 20 | def parse_args(): |
| 21 | parser = argparse.ArgumentParser(description='Train an editor') |
| 22 | parser.add_argument('config', help='train config file path') |
| 23 | parser.add_argument('--work-dir', help='the dir to save logs and models') |
| 24 | parser.add_argument( |
| 25 | '--resume-from', help='the checkpoint file to resume from') |
| 26 | parser.add_argument( |
| 27 | '--no-validate', |
| 28 | action='store_true', |
| 29 | help='whether not to evaluate the checkpoint during training') |
| 30 | parser.add_argument( |
| 31 | '--gpus', |
| 32 | type=int, |
| 33 | default=1, |
| 34 | help='number of gpus to use ' |
| 35 | '(only applicable to non-distributed training)') |
| 36 | parser.add_argument('--seed', type=int, default=None, help='random seed') |
| 37 | parser.add_argument( |
| 38 | '--deterministic', |
| 39 | action='store_true', |
| 40 | help='whether to set deterministic options for CUDNN backend.') |
| 41 | parser.add_argument( |
| 42 | '--launcher', |
| 43 | choices=['none', 'pytorch', 'slurm', 'mpi'], |
| 44 | default='none', |
| 45 | help='job launcher') |
| 46 | parser.add_argument('--local_rank', type=int, default=0) |
| 47 | parser.add_argument( |
| 48 | '--autoscale-lr', |
| 49 | action='store_true', |
| 50 | help='automatically scale lr with the number of gpus') |
| 51 | args = parser.parse_args() |
| 52 | if 'LOCAL_RANK' not in os.environ: |
| 53 | os.environ['LOCAL_RANK'] = str(args.local_rank) |
| 54 | |
| 55 | return args |
| 56 | |
| 57 | |
| 58 | def main(): |