Initialize a model using OmegaConf configuration. Args: model_str (str): Name of the model class to create. model_config (DictConfig): OmegaConf model configuration. torch_hub_force_reload (bool): Whether to force reload relevant parts of the model from torch hub.
(
model_str: str, model_config: DictConfig, torch_hub_force_reload: bool = False
)
| 42 | |
| 43 | |
| 44 | def init_model( |
| 45 | model_str: str, model_config: DictConfig, torch_hub_force_reload: bool = False |
| 46 | ): |
| 47 | """ |
| 48 | Initialize a model using OmegaConf configuration. |
| 49 | |
| 50 | Args: |
| 51 | model_str (str): Name of the model class to create. |
| 52 | model_config (DictConfig): OmegaConf model configuration. |
| 53 | torch_hub_force_reload (bool): Whether to force reload relevant parts of the model from torch hub. |
| 54 | """ |
| 55 | if not OmegaConf.has_resolver("special_float"): |
| 56 | OmegaConf.register_new_resolver("special_float", resolve_special_float) |
| 57 | model_dict = OmegaConf.to_container(model_config, resolve=True) |
| 58 | model = model_factory( |
| 59 | model_str, torch_hub_force_reload=torch_hub_force_reload, **model_dict |
| 60 | ) |
| 61 | |
| 62 | return model |
| 63 | |
| 64 | |
| 65 | def _init_hydra_config(config_path: str, overrides: Optional[List[str]] = None): |
no test coverage detected