mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-19 06:14:03 +08:00
NERFSTUDIO_METHOD_CONFIGS callable MethodSpecification (#2385)
* NERFSTUDIO_METHOD_CONFIGS allow method specification as callabale (function or class) * docs - NERFSTUDIO_METHOD_CONFIGS accepts function or derived class
This commit is contained in:
1 parent
a121d76fd0
commit
4d0033343c
3 files changed
+64
-10
No files matched your search
@@ -60,7 +60,16 @@ def discover_methods() -> t.Tuple[t.Dict[str, TrainerConfig], t.Dict[str, str]]:
|
||||
CONSOLE.print(f"[bold green]Info: Loading method {name} from environment variable")
|
||||
module, config_name = path.split(":")
|
||||
method_config = getattr(importlib.import_module(module), config_name)
|
||||
assert isinstance(method_config, MethodSpecification)
|
||||
|
||||
# method_config specified as function or class -> instance
|
||||
if callable(method_config):
|
||||
method_config = method_config()
|
||||
|
||||
# check for valid instance type
|
||||
if not isinstance(method_config, MethodSpecification):
|
||||
raise TypeError("Method is not an instance of MethodSpecification")
|
||||
|
||||
# save to methods
|
||||
methods[name] = method_config.config
|
||||
descriptions[name] = method_config.description
|
||||
except Exception:
|
||||
|
||||
Reference in new issue
Block a user