| 25 | from mmcv.utils import TORCH_VERSION, digit_version |
| 26 | |
| 27 | def parse_args(): |
| 28 | parser = argparse.ArgumentParser(description='Train a detector') |
| 29 | parser.add_argument('config', help='train config file path') |
| 30 | parser.add_argument('--work-dir', help='the dir to save logs and models') |
| 31 | parser.add_argument( |
| 32 | '--resume-from', help='the checkpoint file to resume from') |
| 33 | parser.add_argument( |
| 34 | '--no-validate', |
| 35 | action='store_true', |
| 36 | help='whether not to evaluate the checkpoint during training') |
| 37 | group_gpus = parser.add_mutually_exclusive_group() |
| 38 | group_gpus.add_argument( |
| 39 | '--gpus', |
| 40 | type=int, |
| 41 | help='number of gpus to use ' |
| 42 | '(only applicable to non-distributed training)') |
| 43 | group_gpus.add_argument( |
| 44 | '--gpu-ids', |
| 45 | type=int, |
| 46 | nargs='+', |
| 47 | help='ids of gpus to use ' |
| 48 | '(only applicable to non-distributed training)') |
| 49 | parser.add_argument('--seed', type=int, default=0, help='random seed') |
| 50 | parser.add_argument( |
| 51 | '--deterministic', |
| 52 | action='store_true', |
| 53 | help='whether to set deterministic options for CUDNN backend.') |
| 54 | parser.add_argument( |
| 55 | '--options', |
| 56 | nargs='+', |
| 57 | action=DictAction, |
| 58 | help='override some settings in the used config, the key-value pair ' |
| 59 | 'in xxx=yyy format will be merged into config file (deprecate), ' |
| 60 | 'change to --cfg-options instead.') |
| 61 | parser.add_argument( |
| 62 | '--cfg-options', |
| 63 | nargs='+', |
| 64 | action=DictAction, |
| 65 | help='override some settings in the used config, the key-value pair ' |
| 66 | 'in xxx=yyy format will be merged into config file. If the value to ' |
| 67 | 'be overwritten is a list, it should be like key="[a,b]" or key=a,b ' |
| 68 | 'It also allows nested list/tuple values, e.g. key="[(a,b),(c,d)]" ' |
| 69 | 'Note that the quotation marks are necessary and that no white space ' |
| 70 | 'is allowed.') |
| 71 | parser.add_argument( |
| 72 | '--launcher', |
| 73 | choices=['none', 'pytorch', 'slurm', 'mpi'], |
| 74 | default='none', |
| 75 | help='job launcher') |
| 76 | parser.add_argument('--local_rank', type=int, default=0) |
| 77 | parser.add_argument( |
| 78 | '--autoscale-lr', |
| 79 | action='store_true', |
| 80 | help='automatically scale lr with the number of gpus') |
| 81 | args = parser.parse_args() |
| 82 | if 'LOCAL_RANK' not in os.environ: |
| 83 | os.environ['LOCAL_RANK'] = str(args.local_rank) |
| 84 | |