Allow methods configs to be discovered from external packages. (#1357)

* Allow method_config to be registered from external packages

* Add license

* Add MethodSpecification class + fix linter errors

---------
This commit is contained in:
Jonáš Kulhánek authored and GitHub committed 2023-02-06 13:25:33 -08:00
1 parent bf64769128
commit 59f71eda0e
7 files changed
+183

No files matched your search

+30
View File
@@ -118,3 +118,33 @@ Often times, you just want to play with the parameters of an existing model with
# NOTE: the dataparser and associated configurations go at the end of the command
ns-train {METHOD_NAME} --vis viewer {DATA_PARSER} --scale-factor 0.5
```
### Extending Nerfstudio with custom methods
In order to extend the Nerfstudio and register your own methods, you can package your code as a python package
and register it with Nerfstudio as a `nerfstudio.method_configs` entrypoint in the `pyproject.toml` file.
The Nerfstudio will automatically look for all registered methods and will register them to be used
by method such as `ns-train`.
Here is an example:
```python
"""my_package/my_config.py"""
from nerfstudio.engine.trainer import TrainerConfig
from nerfstudio.plugins.types import MethodSpecification
MyMethod = MethodSpecification(
config=TrainerConfig(
method_name="my-method",
...
),
description="Custom description"
)
"""pyproject.toml"""
[project]
name = "my_package"
...
[project.entry-points.'nerfstudio.method_configs']
my-method = 'my_package.my_config:MyMethod'
```