MCPcopy
hub / github.com/cvg/Hierarchical-Localization / dynamic_load

Function dynamic_load

hloc/utils/base_model.py:37–47  ·  view source on GitHub ↗
(root, model)

Source from the content-addressed store, hash-verified

35
36
37def dynamic_load(root, model):
38 module_path = f'{root.__name__}.{model}'
39 module = __import__(module_path, fromlist=[''])
40 classes = inspect.getmembers(module, inspect.isclass)
41 # Filter classes defined in the module
42 classes = [c for c in classes if c[1].__module__ == module_path]
43 # Filter classes inherited from BaseModel
44 classes = [c for c in classes if issubclass(c[1], BaseModel)]
45 assert len(classes) == 1, classes
46 return classes[0][1]
47 # return getattr(module, 'Model')

Callers 3

match_from_pathsFunction · 0.85
match_denseFunction · 0.85
mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected