Config loader

Code using omegaconf to handle IO.

IO


source

class_to_str

 class_to_str (cls)

source

load_config

 load_config (file_path)

source

config_to_dict

 config_to_dict (config)

source

save_dataclass_yaml

 save_dataclass_yaml (data_obj, file_path)

source

save_dict_yaml

 save_dict_yaml (dict_obj, file_path)

Test

@dataclass
class MyConfig:    
    target:str = class_to_str(OmegaConf)
    clr_dim: int = 80
    features: list[int]=None
    
c = MyConfig()
c.features = [1,2,3]

OmegaConf.structured(c)
{'target': 'omegaconf.omegaconf.OmegaConf', 'clr_dim': 80, 'features': [1, 2, 3]}

Object config load

Mostly taken from: https://github.com/Stability-AI/stablediffusion


source

get_obj_from_str

 get_obj_from_str (string, reload=False)

source

instantiate_from_config

 instantiate_from_config (config)

source

load_model_from_config

 load_model_from_config (config, ckpt, device)
Back to top