Arulkumar03/Wheat_HEAD_Detection_Counting_ComputerVision_Model
0
1# Yacs Configs2 3Detectron2 provides a key-value based config system that can be4used to obtain standard, common behaviors.5 6This system uses YAML and [yacs](https://github.com/rbgirshick/yacs).7Yaml is a very limited language,8so we do not expect all features in detectron2 to be available through configs.9If you need something that's not available in the config space,10please write code using detectron2's API.11 12With the introduction of a more powerful [LazyConfig system](lazyconfigs.md),13we no longer add functionality / new keys to the Yacs/Yaml-based config system.14 15### Basic Usage16 17Some basic usage of the `CfgNode` object is shown here. See more in [documentation](../modules/config.html#detectron2.config.CfgNode).18```python19from detectron2.config import get_cfg20cfg = get_cfg() # obtain detectron2's default config21cfg.xxx = yyy # add new configs for your own custom components22cfg.merge_from_file("my_cfg.yaml") # load values from a file23 24cfg.merge_from_list(["MODEL.WEIGHTS", "weights.pth"]) # can also load values from a list of str25print(cfg.dump()) # print formatted configs26with open("output.yaml", "w") as f:27 f.write(cfg.dump()) # save config to file28```29 30In addition to the basic Yaml syntax, the config file can31define a `_BASE_: base.yaml` field, which will load a base config file first.32Values in the base config will be overwritten in sub-configs, if there are any conflicts.33We provided several base configs for standard model architectures.34 35Many builtin tools in detectron2 accept command line config overwrite:36Key-value pairs provided in the command line will overwrite the existing values in the config file.37For example, [demo.py](../../demo/demo.py) can be used with38```sh39./demo.py --config-file config.yaml [--other-options] \40 --opts MODEL.WEIGHTS /path/to/weights INPUT.MIN_SIZE_TEST 100041```42 43To see a list of available configs in detectron2 and what they mean,44check [Config References](../modules/config.html#config-references)45 46### Configs in Projects47 48A project that lives outside the detectron2 library may define its own configs, which will need to be added49for the project to be functional, e.g.:50```python51from detectron2.projects.point_rend import add_pointrend_config52cfg = get_cfg() # obtain detectron2's default config53add_pointrend_config(cfg) # add pointrend's default config54# ... ...55```56 57### Best Practice with Configs58 591. Treat the configs you write as "code": avoid copying them or duplicating them; use `_BASE_`60 to share common parts between configs.61 622. Keep the configs you write simple: don't include keys that do not affect the experimental setting.63 