KonfAI GitHub

Workflows

TRAIN, RESUME, PREDICTION, EVALUATION, TRANSFORM and the options that matter.

Options that matter for every command

OptionEffect
-y, --overwriteOverwrite existing outputs without asking. Under TRANSFORM and PREDICTION, recompute cases already written; without it, PREDICTION skips them and refuses a Prediction.yml or checkpoints other than the ones they were written with.
--gpuGPU ids (--gpu 0 1). Without it, the run is on the CPU.
--cpuNumber of CPU processes when no --gpu is given. Under TRANSFORM, the number of processes sharing the cases.
-q, --quietLess console output.
--configThe config file (default: the workflow's own name).

TRAIN and RESUME

konfai TRAIN -y --gpu 0 --config Config.yml
konfai RESUME -y --config Config.yml --model Checkpoints/SEG_BASELINE/resume_latest.pt

TRAIN fits the model of Config.yml and writes Checkpoints/ and Statistics/ under train_name. save_checkpoint_mode: BEST keeps one dated model; resume_latest.pt is the continuation RESUME reads (optimizer, scheduler and counters restored), crash_*.pt an exceptional save: neither is a model to predict with. RESUME reads the split seed back from Statistics/<train_name>/Seed.txt.

PREDICTION

konfai PREDICTION -y --gpu 0 --config Prediction.yml --models Checkpoints/SEG_BASELINE/SELECTED_MODEL.pt
konfai PREDICTION -y --gpu 0 --config Prediction.yml --models ckpt_a.pt ckpt_b.pt ckpt_c.pt   # an ensemble

--models is required; several checkpoints make an ensemble, merged by combine (Mean by default), the members run one after the other in one model with their weights kept in a host cache. Test-time augmentation is the augmentations block of Predictor.Dataset (a Flip gives, in turn, the distinct mirrors its f_prob allows) and the copies are merged by reduction (Mean, Vote for labels). Prediction owns patching, overlap reconstruction, geometry and output writing: outputs_dataset says which head is written, under which group name and format. Preprocessing must match training.

EVALUATION

konfai EVALUATION -y --cpu 1 --config Evaluation.yml

Evaluation compares predictions with references: metrics names, for each output group, the reference group and the criteria (Dice with its labels, …). It writes Evaluations/<train_name>/Metric_TRAIN.json and the per-case values beside it, so an interrupted evaluation resumes.

TRANSFORM

konfai TRANSFORM --config Transform.yml --plan   # what it would do
konfai TRANSFORM --config Transform.yml          # do it

TRANSFORM prepares a dataset: it reads cases, runs a chain of stages on each one (Resample, …, then Write: to a dataset and format) and writes the result, slab by slab when the chain streams, so a cohort larger than RAM is a normal cohort. Plan before you run. A case whose output already exists is skipped, so an interrupted run resumes. If you never train anything, this is the only workflow you need.

The complete option tables, exit codes and environment variables: CLI reference.