| 22 | # os.environ['CUDA_VISIBLE_DEVICES'] = "0" |
| 23 | |
| 24 | def parse_args(): |
| 25 | parser = argparse.ArgumentParser(description='Train a segmentor') |
| 26 | parser.add_argument('config', help='train config file path') |
| 27 | parser.add_argument('--work-dir', help='the dir to save logs and models') |
| 28 | parser.add_argument( |
| 29 | '--load-from', help='the checkpoint file to load weights from') |
| 30 | parser.add_argument( |
| 31 | '--resume-from', help='the checkpoint file to resume from') |
| 32 | parser.add_argument( |
| 33 | '--no-validate', |
| 34 | action='store_true', |
| 35 | help='whether not to evaluate the checkpoint during training') |
| 36 | group_gpus = parser.add_mutually_exclusive_group() |
| 37 | group_gpus.add_argument( |
| 38 | '--gpus', |
| 39 | type=int, |
| 40 | help='number of gpus to use ' |
| 41 | '(only applicable to non-distributed training)') |
| 42 | group_gpus.add_argument( |
| 43 | '--gpu-ids', |
| 44 | type=int, |
| 45 | nargs='+', |
| 46 | help='ids of gpus to use ' |
| 47 | '(only applicable to non-distributed training)') |
| 48 | parser.add_argument('--seed', type=int, default=2023, help='random seed') |
| 49 | parser.add_argument( |
| 50 | '--deterministic', |
| 51 | action='store_true', |
| 52 | help='whether to set deterministic options for CUDNN backend.') |
| 53 | parser.add_argument( |
| 54 | '--options', nargs='+', action=DictAction, help='custom options') |
| 55 | parser.add_argument( |
| 56 | '--launcher', |
| 57 | choices=['none', 'pytorch', 'slurm', 'mpi'], |
| 58 | default='none', |
| 59 | help='job launcher') |
| 60 | parser.add_argument('--local-rank', type=int, default=0) |
| 61 | parser.add_argument('--finetune', default=False, action='store_true') |
| 62 | args = parser.parse_args() |
| 63 | if 'LOCAL_RANK' not in os.environ: |
| 64 | os.environ['LOCAL_RANK'] = str(args.local_rank) |
| 65 | return args |
| 66 | |
| 67 | |
| 68 | def main(): |