MCPcopy Create free account
hub / github.com/OpenGVLab/InternVL / update_config

Function update_config

classification/config.py:228–277  ·  view source on GitHub ↗
(config, args)

Source from the content-addressed store, hash-verified

226
227
228def update_config(config, args):
229 _update_config_from_file(config, args.cfg)
230
231 config.defrost()
232 if hasattr(args, 'opts') and args.opts:
233 config.merge_from_list(args.opts)
234
235 # merge from specific arguments
236 if hasattr(args, 'batch_size') and args.batch_size:
237 config.DATA.BATCH_SIZE = args.batch_size
238 if hasattr(args, 'dataset') and args.dataset:
239 config.DATA.DATASET = args.dataset
240 if hasattr(args, 'data_path') and args.data_path:
241 config.DATA.DATA_PATH = args.data_path
242 if hasattr(args, 'zip') and args.zip:
243 config.DATA.ZIP_MODE = True
244 if hasattr(args, 'cache_mode') and args.cache_mode:
245 config.DATA.CACHE_MODE = args.cache_mode
246 if hasattr(args, 'pretrained') and args.pretrained:
247 config.MODEL.PRETRAINED = args.pretrained
248 if hasattr(args, 'resume') and args.resume:
249 config.MODEL.RESUME = args.resume
250 if hasattr(args, 'accumulation_steps') and args.accumulation_steps:
251 config.TRAIN.ACCUMULATION_STEPS = args.accumulation_steps
252 if hasattr(args, 'use_checkpoint') and args.use_checkpoint:
253 config.TRAIN.USE_CHECKPOINT = True
254 if hasattr(args, 'amp_opt_level') and args.amp_opt_level:
255 config.AMP_OPT_LEVEL = args.amp_opt_level
256 if hasattr(args, 'output') and args.output:
257 config.OUTPUT = args.output
258 if hasattr(args, 'tag') and args.tag:
259 config.TAG = args.tag
260 if hasattr(args, 'eval') and args.eval:
261 config.EVAL_MODE = True
262 if hasattr(args, 'throughput') and args.throughput:
263 config.THROUGHPUT_MODE = True
264 if hasattr(args, 'save_ckpt_num') and args.save_ckpt_num:
265 config.SAVE_CKPT_NUM = args.save_ckpt_num
266 if hasattr(args, 'use_zero') and args.use_zero:
267 config.TRAIN.OPTIMIZER.USE_ZERO = True
268 # set local rank for distributed training
269 if hasattr(args, 'local_rank') and args.local_rank:
270 config.LOCAL_RANK = args.local_rank
271
272 # output folder
273 config.MODEL.NAME = args.cfg.split('/')[-1].replace('.yaml', '')
274 config.OUTPUT = os.path.join(config.OUTPUT, config.MODEL.NAME)
275 # config.OUTPUT = os.path.join(config.OUTPUT, config.MODEL.NAME, config.TAG)
276
277 config.freeze()
278
279
280def get_config(args):

Callers 1

get_configFunction · 0.85

Calls 1

_update_config_from_fileFunction · 0.85

Tested by

no test coverage detected