@@ -8,6 +8,15 @@ The main benefits are threefold:
88- it describes workflow at a relatively high level and allows for different low-level implementations.
99- learning paradigms at a higher level such as federated learning and AutoML can be decoupled from the component details.
1010
11+ Content:
12+
13+ - [ A basic example] ( #a-basic-example )
14+ - [ Syntax examples explained] ( #syntax-examples-explained )
15+ - ` @ ` to interpolate with Python objects
16+ - ` $ ` to evaluate as Python expressions
17+ - ` _target_ ` to instantiate a Python object
18+ - ` % ` to interpolate with plain texts
19+
1120## A basic example
1221
1322Components as part of a workflow can be specified using ` JSON ` or ` YAML ` syntax, for example, a network architecture
@@ -62,10 +71,14 @@ or additionally, tune the input parameters then instantiate the component:
6271BasicUNet features: (32 , 32 , 32 , 64 , 64 , 64 ).
6372```
6473
74+ For more details on the ` ConfigParser ` API, please see https://docs.monai.io/en/latest/bundle.html#config-parser .
75+
6576## Syntax examples explained
6677
6778A few characters and keywords are interpreted beyond the plain texts, here are examples of the syntax:
6879
80+ ### ` @ ` to interpolate with Python objects
81+
6982``` json
7083" @preprocessing#transforms#keys"
7184```
@@ -79,6 +92,8 @@ where `#` indicates a sub-structure of this configuration file.
7992
8093_ Description:_ ` 1 ` is interpreted as an integer, which is used to index the ` preprocessing ` sub-structure.
8194
95+ ### ` $ ` to evaluate as Python expressions
96+
8297``` json
8398" $print(42)"
8499```
@@ -91,6 +106,8 @@ _Description:_ `$` is a special character to indicate evaluating `print(42)` at
91106
92107_ Description:_ Create a list at runtime using the values in ` datalist ` as input.
93108
109+ ### ` _target_ ` to instantiate a Python object
110+
94111``` json
95112{
96113 "demo_name" :{
@@ -106,13 +123,6 @@ This dictionary will be instantiated as a Pytorch object at runtime.
106123` _target_ ` is a required key by monai bundle syntax for the Python object name.
107124` args1 ` and ` args2 ` should be compatible with the Python object to instantiate.
108125
109- ``` json
110- " %demo_config.json#demo_net#in_channels"
111- ```
112-
113- _ Description:_ A macro to replace the current value with the texts at ` demo_net#in_channels ` in the
114- ` demo_config.json ` file.
115-
116126``` json
117127{
118128 "component_name" : {
@@ -128,3 +138,12 @@ Python expression that will be evaluated/instantiated before `_target_` object i
128138It is useful when the component doesn’t explicitly depends on the other ConfigItems via
129139its arguments, but requires the dependencies to be instantiated/evaluated beforehand.
130140` _disabled_ ` specifies a flag to indicate whether to skip the instantiation.
141+
142+ ### ` % ` to interpolate with plain texts
143+
144+ ``` json
145+ " %demo_config.json#demo_net#in_channels"
146+ ```
147+
148+ _ Description:_ A macro to replace the current value with the texts at ` demo_net#in_channels ` in the
149+ ` demo_config.json ` file.
0 commit comments