MCPcopy Index your code
hub / github.com/OpenGVLab/InternVL / parse_option

Function parse_option

classification/main_accelerate.py:35–79  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

33
34
35def parse_option():
36 parser = argparse.ArgumentParser(
37 'InternVL training and evaluation script', add_help=False)
38 parser.add_argument('--cfg', type=str, required=True, metavar='FILE', help='path to config file')
39 parser.add_argument('--opts', help="Modify config options by adding 'KEY VALUE' pairs. ", default=None, nargs='+')
40
41 # easy config modification
42 parser.add_argument('--batch-size', type=int, help='batch size for single GPU')
43 parser.add_argument('--dataset', type=str, help='dataset name', default=None)
44 parser.add_argument('--data-path', type=str, help='path to dataset')
45 parser.add_argument('--zip', action='store_true', help='use zipped dataset instead of folder dataset')
46 parser.add_argument('--cache-mode', type=str, default='part', choices=['no', 'full', 'part'],
47 help='no: no cache, '
48 'full: cache all data, '
49 'part: sharding the dataset into nonoverlapping pieces and only cache one piece'
50 )
51 parser.add_argument('--pretrained', help='pretrained weight from checkpoint, could be imagenet22k pretrained weight')
52 parser.add_argument('--resume', help='resume from checkpoint')
53 parser.add_argument('--output', default='work_dirs', type=str, metavar='PATH',
54 help='root of output folder, the full path is <output>/<model_name>/<tag> (default: output)'
55 )
56 parser.add_argument('--eval', action='store_true', help='Perform evaluation only')
57 parser.add_argument('--throughput', action='store_true', help='Test throughput only')
58 parser.add_argument('--save-ckpt-num', default=1, type=int)
59 parser.add_argument('--accumulation-steps', type=int, default=1, help='gradient accumulation steps')
60 parser.add_argument('--disable-grad-scalar', action='store_true', help='disable Grad Scalar')
61 parser.add_argument(
62 '--logger',
63 type=str,
64 default='tensorboard',
65 choices=['tensorboard', 'wandb'],
66 help=(
67 'Whether to use [tensorboard](https://www.tensorflow.org/tensorboard) or [wandb](https://www.wandb.ai)'
68 ' for experiment tracking and logging of model metrics and model checkpoints'
69 ),
70 )
71
72 args, unparsed = parser.parse_known_args()
73 config = get_config(args)
74 config.defrost()
75 config.TRAIN.OPTIMIZER.USE_ZERO = False
76 config.OUTPUT += '_deepspeed'
77 config.DATA.IMG_ON_MEMORY = False
78 config.freeze()
79 return args, config
80
81
82def seed_everything(seed, rank):

Callers 1

mainFunction · 0.70

Calls 1

get_configFunction · 0.90

Tested by

no test coverage detected