MCPcopy Create free account
hub / github.com/Ropedia/SpatialBench / init_model

Function init_model

benchmark/models/mapanything/models/__init__.py:44–62  ·  view source on GitHub ↗

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
)

Source from the content-addressed store, hash-verified

42
43
44def 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
65def _init_hydra_config(config_path: str, overrides: Optional[List[str]] = None):

Callers 1

init_model_from_configFunction · 0.85

Calls 1

model_factoryFunction · 0.85

Tested by

no test coverage detected