beacon_aug/generator/__init__.py
def load_config(op_name, standard_fnames="./standard/*.yaml"):
    '''
    Extact and load the config for the current operator
    @input:
        standard_fnames: .json or .yaml file
    '''
    config = None
    config_custom = None
    # load config from custom python file
    for custom_op_name in custom.__all__:
        # get local fname withoutextension
        # custom_submodule = os.path.splitext(os.path.basename(py_fname))[0]
        if op_name == custom_op_name:
            module = importlib.import_module("custom." + op_name)  # dynamic import module
            custom_op_function = getattr(module, op_name)
            # add "custom" library to config paras
            transform_type = "ImageOnlyBATransform" if custom_op_function().image_only else "DualBATransform"
            config_custom = {"transform": transform_type,
                             custom_op_function().library: {"function": custom_op_function}}
            config = config_custom

    config_gan_based = None
    # load config from gan_based python file
    for custom_op_name in gan_based.__all__:
        # get local fname withoutextension
        # custom_submodule = os.path.splitext(os.path.basename(py_fname))[0]
        if op_name == custom_op_name:
            module = importlib.import_module("gan_based." + op_name)  # dynamic import module
            custom_op_function = getattr(module, op_name)
            # add "custom" library to config paras
            transform_type = "ImageOnlyBATransform" if custom_op_function().image_only else "DualBATransform"
            config_gan_based = {"transform": transform_type,
                                custom_op_function().library: {"function": custom_op_function}}
            config = config_gan_based

    # load config from standard json file
    js_fnames = glob.glob(os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                       standard_fnames))
    for js_fname in js_fnames:
        js_f = open(js_fname)
        OP_para = yaml.safe_load(js_f)
        if OP_para is not None:
            if op_name in OP_para:
                config = OP_para[op_name]
                # if same class exist in standard, add custom library to standard
                if config_custom:
                    config["custom"] = config_custom["custom"]
                if config_gan_based:
                    config["gan_based"] = config_custom["gan_based"]

    return config

    Extact and load the config for the current operator
    @input:
        standard_fnames: .json or .yaml file
    
Extact and load the config for the current operator
Extact and load the config for the current operator
def load_config(op_name, standard_fnames="./standard/*.yaml"):
    config = None
    config_custom = None
    for custom_op_name in custom.__all__:
        if op_name == custom_op_name:
            module = importlib.import_module("custom." + op_name)  
            custom_op_function = getattr(module, op_name)
            transform_type = "ImageOnlyBATransform" if custom_op_function().image_only else "DualBATransform"
            config_custom = {"transform": transform_type,
                             custom_op_function().library: {"function": custom_op_function}}
            config = config_custom
    config_gan_based = None
    for custom_op_name in gan_based.__all__:
        if op_name == custom_op_name:
            module = importlib.import_module("gan_based." + op_name)  
            custom_op_function = getattr(module, op_name)
            transform_type = "ImageOnlyBATransform" if custom_op_function().image_only else "DualBATransform"
            config_gan_based = {"transform": transform_type,
                                custom_op_function().library: {"function": custom_op_function}}
            config = config_gan_based
    js_fnames = glob.glob(os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                       standard_fnames))
    for js_fname in js_fnames:
        js_f = open(js_fname)
        OP_para = yaml.safe_load(js_f)
        if OP_para is not None:
            if op_name in OP_para:
                config = OP_para[op_name]
                if config_custom:
                    config["custom"] = config_custom["custom"]
                if config_gan_based:
                    config["gan_based"] = config_custom["gan_based"]
    return config
def load_config ( op_name , standard_fnames = "./standard/*.yaml" ) : config = None config_custom = None for custom_op_name in custom . __all__ : if op_name == custom_op_name : module = importlib . import_module ( "custom." + op_name ) custom_op_function = getattr ( module , op_name ) transform_type = "ImageOnlyBATransform" if custom_op_function ( ) . image_only else "DualBATransform" config_custom = { "transform" : transform_type , custom_op_function ( ) . library : { "function" : custom_op_function } } config = config_custom config_gan_based = None for custom_op_name in gan_based . __all__ : if op_name == custom_op_name : module = importlib . import_module ( "gan_based." + op_name ) custom_op_function = getattr ( module , op_name ) transform_type = "ImageOnlyBATransform" if custom_op_function ( ) . image_only else "DualBATransform" config_gan_based = { "transform" : transform_type , custom_op_function ( ) . library : { "function" : custom_op_function } } config = config_gan_based js_fnames = glob . glob ( os . path . join ( os . path . dirname ( os . path . abspath ( __file__ ) ) , standard_fnames ) ) for js_fname in js_fnames : js_f = open ( js_fname ) OP_para = yaml . safe_load ( js_f ) if OP_para is not None : if op_name in OP_para : config = OP_para [ op_name ] if config_custom : config [ "custom" ] = config_custom [ "custom" ] if config_gan_based : config [ "gan_based" ] = config_custom [ "gan_based" ] return config
Extact and load the config for the current operator
Extact and load the config for the current operator
'''
    Extact and load the config for the current operator
    @input:
        standard_fnames: .json or .yaml file
    ''' # load config from custom python file # get local fname withoutextension # custom_submodule = os.path.splitext(os.path.basename(py_fname))[0] # dynamic import module # add "custom" library to config paras # load config from gan_based python file # get local fname withoutextension # custom_submodule = os.path.splitext(os.path.basename(py_fname))[0] # dynamic import module # add "custom" library to config paras # load config from standard json file # if same class exist in standard, add custom library to standard
op_name
standard_fnames
input
.json or .yaml file
. json or . yaml file