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