espnet3.utils.config_utils.convert_to_dict
Less than 1 minute
espnet3.utils.config_utils.convert_to_dict
espnet3.utils.config_utils.convert_to_dict(value: Any) → Any
Return value with any OmegaConf container turned into plain Python.
Hydra hands nested blocks over as DictConfig/ListConfig unless the config opts into _convert_. Those unpack through ** well enough, but they leak into components’ stored attributes and into checkpointed hparams, so callers that keep the value around convert it once with this helper.
- Parameters:value (Any) – Any config value.
DictConfigandListConfigare converted recursively with interpolations resolved; anything else is returned unchanged, so plain Python and direct Python calls pass straight through. - Returns:
dictfor aDictConfig,listfor aListConfig, otherwisevalueitself. - Return type: Any
Example
>>> from omegaconf import OmegaConf
>>> convert_to_dict(OmegaConf.create({"depth": 18}))
{'depth': 18}
>>> convert_to_dict({"depth": 18})
{'depth': 18}NOTE
Conversion happens before the value reaches a component, so a config list such as mask_fraction_range: [0.7, 1.0] arrives as a real list and is coerced by the component’s own signature rather than being stored as a ListConfig.
