Configuration
One YAML per workflow: roots, dataset, groups, transforms, patches, models.
Four files, four roots
A KonfAI config is YAML that says which Python objects to build and how they connect. Each workflow has one file with one root key; the model workflows share a workspace named by train_name, so use the same train_name in the files of one experiment.
| Command | File | Root | Writes |
|---|---|---|---|
konfai TRAIN / RESUME | Config.yml | Trainer: | Checkpoints/<train_name>/, Statistics/<train_name>/ |
konfai PREDICTION | Prediction.yml | Predictor: | Predictions/<train_name>/ |
konfai EVALUATION | Evaluation.yml | Evaluator: | Evaluations/<train_name>/Metric_*.json |
konfai TRANSFORM | Transform.yml | Transformer: | wherever each Write: points; logs in Transforms/<name>/ |
How YAML becomes objects
Each key is a constructor argument: KonfAI reads the class's signature, takes each argument from the key of the same name (snake_case) and builds nested objects the same way. A missing key takes its default (konfai <COMMAND> --init writes every default into the file); null means None and turns a feature off; a required key must be written and the error names it; a value of the wrong shape is refused with its path; a key nothing reads is reported with the closest valid name. Running a config rewrites it with its resolved defaults.
The dataset
Every workflow reads its data through a Dataset: block. dataset_filenames is a list of path, path:format or path:flag:format entries, as the templates write them:
./Dataset:mha,./DicomDataset:dicom,./OmeDataset:omezarr;- the flag
aadds a dataset's cases to the others (union),ikeeps only the cases present in all (intersection):./Predictions/TRAIN_01/Dataset:i:mha; - a manifest of explicit entries,
./cases.yml:omezarr, when the cases do not sit in the standard layout.
groups_src names the groups read from disk; each gives one or more tensors in groups_dest, each with its own transforms; is_input: true marks the model's inputs, the others are targets. transforms is case preprocessing, replayed on regions when streaming; patch_transforms runs on each patch. No transforms means the group reaches the model as stored.
Trainer:
Dataset:
dataset_filenames: [./Dataset:mha]
groups_src:
CT:
groups_dest:
CT:
transforms:
Standardize: {mean: None, std: None}
is_input: true
SEG:
groups_dest:
SEG: {}
Patch:
patch_size: [128, 128, 128]
subset and validation take the same selectors: a share of the cases, a list of names, a case-list file, or a start:end slice.
Patches
Patch.patch_size is the patch the model sees (default [128, 128, 128]); a 0 lets KonfAI size that axis, starting from the whole axis and, on a GPU out-of-memory at the first step, restarting with the fewest equal patches that fit. overlap defaults to 20 %. extend_slice adds neighbouring slices as channels for 2.5-D models (with patch_size[0] == 1). memory_budget decides whether the dataset stays in RAM or streams.
Models by classpath
A KonfAI model is a graph of named modules, either a Python class or the same graph written as a .yml. Pick it with classpath: segmentation.UNet.UNet for a Python class of the catalogue, default|UNet.yml for the YAML catalogue, UNet.yml for a file next to the config; its arguments go in a section named after the class. A module's path joins the names of its parents with :, and the config attaches losses and metrics to those paths under outputs_criterions (the segmentation example puts cross entropy on UNetBlock_0:Head:Conv, the logits, and Dice on UNetBlock_0:Head:Softmax, the probabilities). A model with no loss is refused. KonfAI also instantiates regular PyTorch and MONAI components named by classpath (monai.networks.nets:UNet, with the monai extra).
The exhaustive field tables: training, prediction, evaluation, transform.
