|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import os |
|
import json |
|
from yacs.config import CfgNode as CN |
|
|
|
|
|
cfg = CN(new_allowed=True) |
|
|
|
cfg.OUTPUT_DIR = 'results' |
|
cfg.DEVICE = 'cuda' |
|
cfg.DEBUG = False |
|
cfg.LOGDIR = '' |
|
cfg.VAL_VIS_BATCH_FREQ = 200 |
|
cfg.TRAIN_VIS_ITER_FERQ = 1000 |
|
cfg.SEED_VALUE = -1 |
|
|
|
cfg.TRAIN = CN(new_allowed=True) |
|
|
|
cfg.LOSS = CN(new_allowed=True) |
|
cfg.LOSS.KP_2D_W = 300.0 |
|
cfg.LOSS.KP_3D_W = 300.0 |
|
cfg.LOSS.SHAPE_W = 0.06 |
|
cfg.LOSS.POSE_W = 60.0 |
|
cfg.LOSS.VERT_W = 0.0 |
|
|
|
|
|
cfg.LOSS.INDEX_WEIGHTS = 2.0 |
|
|
|
cfg.LOSS.PART_WEIGHTS = 0.3 |
|
|
|
cfg.LOSS.POINT_REGRESSION_WEIGHTS = 0.5 |
|
|
|
cfg.MODEL = CN(new_allowed=True) |
|
|
|
cfg.MODEL.PyMAF = CN(new_allowed=True) |
|
|
|
|
|
cfg.TRAIN.VAL_LOOP = True |
|
|
|
cfg.TEST = CN(new_allowed=True) |
|
|
|
|
|
def get_cfg_defaults(): |
|
"""Get a yacs CfgNode object with default values for my_project.""" |
|
|
|
|
|
|
|
return cfg |
|
|
|
|
|
def update_cfg(cfg_file): |
|
|
|
cfg.merge_from_file(cfg_file) |
|
|
|
return cfg |
|
|
|
|
|
def parse_args(args): |
|
cfg_file = args.cfg_file |
|
if args.cfg_file is not None: |
|
cfg = update_cfg(args.cfg_file) |
|
else: |
|
cfg = get_cfg_defaults() |
|
|
|
|
|
|
|
|
|
return cfg |
|
|
|
|
|
def parse_args_extend(args): |
|
if args.resume: |
|
if not os.path.exists(args.log_dir): |
|
raise ValueError( |
|
'Experiment are set to resume mode, but log directory does not exist.' |
|
) |
|
|
|
|
|
cfg_file = os.path.join(args.log_dir, 'cfg.yaml') |
|
cfg = update_cfg(cfg_file) |
|
|
|
if args.misc is not None: |
|
cfg.merge_from_list(args.misc) |
|
else: |
|
parse_args(args) |
|
|