lazy_config
剥离 detectron2 的 LazyConfig 功能,用于通用任务的项目模板。
How to create your own package based on this package.
Use the following command to create a new package based on this package:
python init.py your-package-name
It will replace the current package name (lazy_config) with your own package name in the code base.
However, you need to modify the author name and email in pyproject.toml.
Then you should use pip install -e .[dev] to install the package in editable mode.
After the project is created, you can delete the init.py file and start working on your project.
Usage
See the example in projects/lazy_config_demo/main.py and run it with the following command:
PYTHONPATH=. python projects/lazy_config_demo/main.py projects/lazy_config_demo/config.py MODEL.in_features=10
Principles
-
LazyCall(orL): 这是让你能够以惰性方式定义对象构建的语法糖。 -
instantiate()function: 这是将惰性配置(带有 target 的 omegaconf 对象)转换为实际 Python 对象的关键函数。它会处理递归实例化和参数传递。 -
parse_args_and_configs()function: 它允许你读取命令行参数和配置文件,并将它们合并成一个 omegaconf 对象。