lazy_config/README.md
2025-05-29 18:32:58 +08:00

29 lines
959 B
Markdown

# lazy_config
剥离 detectron2 的 LazyConfig 功能,用于通用任务的项目模板。
## How to create your own package based on this package.
```bash
python init.py
```
and follow the prompts.
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` (or `L`): 这是让你能够以惰性方式定义对象构建的语法糖。
- `instantiate()` function: 这是将惰性配置(带有 _target_ 的 omegaconf 对象)转换为实际 Python 对象的关键函数。它会处理递归实例化和参数传递。
- `parse_args_and_configs()` function: 它允许你读取命令行参数和配置文件,并将它们合并成一个 omegaconf 对象。