Models#
Built-in networks under konfai/models/, referenced in a config by classpath
(e.g. classpath: segmentation.UNet.UNet, or the bare dotted form). A model is
a subclass of konfai.network.Network — a routed add_module graph. See
Model graph and output naming for how the graph and its named outputs work,
and Declarative YAML model graphs for building a feed-forward model
entirely from YAML.
Note
“YAML-buildable” column. A model is buildable from a .yml (via the safe
Declarative YAML model graphs) only if it is a pure graph of registry
node types. Models with a custom forward() (diffusion, StyleGAN, ConvNeXt,
VoxelMorph, …) are written as Python classes. The registry is deliberately small
— see Declarative YAML model graphs.
Segmentation — konfai.models.python.segmentation#
PlainConvUNet is the parametric nnU-Net backbone (n_stages / features_per_stage /
strides / n_conv_per_stage as real arguments), weight-exact to
dynamic_network_architectures.PlainConvUNet for any topology — a real nnU-Net /
TotalSegmentator / MRSeg checkpoint loads into it through the pretrained bridge. Every
decoder resolution has a deep-supervision head as a named output.
SMP wraps any segmentation_models_pytorch architecture/encoder pair (Unet,
UnetPlusPlus, FPN, DeepLabV3Plus, … × resnet/efficientnet/timm encoders), with
optional ImageNet encoder weights (encoder_weights: imagenet) that survive
training start. 2D-only (SMP’s encoder zoo is 2D); use slice-wise patches or
2.5D channels on volumes. Requires pip install konfai[smp].
Model |
Classpath |
Purpose |
Key args (defaults) |
Dims |
YAML-buildable |
|---|---|---|---|---|---|
|
|
Classic encoder–decoder U-Net; optional attention gates and deep-supervision heads. |
|
2D / 3D |
Yes |
|
|
UNet++ with dense nested skips and per-level deep-supervision heads. |
as |
2D / 3D |
Yes |
|
|
Parametric UNet++ on a pretrained ResNet backbone — weight-exact vs |
|
2D |
Yes (params) |
|
|
Parametric nnU-Net residual-encoder U-Net for any topology — weight-exact vs |
|
2D / 3D |
Yes (params) |
Note
Two UNet++ flavours: NestedUNet (academic, plain-conv encoder trained from scratch) and
UNetPlusPlus (the smp-faithful UNet++ with a real pretrained ResNet backbone — the one
that loads smp.UnetPlusPlus checkpoints). Pick UNetPlusPlus when you need smp
weight-compatibility (e.g. the ImpactSynth app).
Note
The Model:UNetpp5 used in the Synthesis example is a local class in
examples/Synthesis/Model.py wrapping segmentation_models_pytorch; the built-in
UNetPlusPlus above is the maintained, smp-weight-exact equivalent.
Classification — konfai.models.python.classification#
Model |
Classpath |
Purpose |
Key args (defaults) |
Dims |
YAML-buildable |
|---|---|---|---|---|---|
|
|
ResNet-18/34/50/101/152 family with torchvision-compatible weight aliases. |
|
2D / 3D |
Yes |
|
|
ConvNeXt (tiny→xlarge presets) with a multi-head classifier ( |
|
2D |
No (custom |
Generation — konfai.models.python.generation#
Model |
Classpath |
Purpose |
Dims |
YAML-buildable |
|---|---|---|---|---|
|
|
Convolutional auto-encoder. Deterministic — despite the name there is no latent sampling. |
2D / 3D |
Yes |
|
|
Fully-connected variational AE ( |
1D (flat vectors) |
No ( |
|
|
PatchGAN discriminator + ResNet-autoencoder generator + composite adversarial graph. |
2D / 3D |
No |
|
|
Conditional denoising-diffusion U-Net. |
2D / 3D |
No |
|
|
Adversarial + diffusion + CycleGAN family. |
2D / 3D |
No |
|
|
Conditional StyleGAN-style generator with weight-modulated convs. |
2D / 3D |
No |
Registration — konfai.models.python.registration#
Model |
Classpath |
Purpose |
Dims |
YAML-buildable |
|---|---|---|---|---|
|
|
Learning-based deformable/rigid registration (U-Net flow field + spatial-transformer warp + scaling-and-squaring integration). Pass |
2D |
No |
Representation — konfai.models.python.representation#
Model |
Classpath |
Purpose |
Dims |
YAML-buildable |
|---|---|---|---|---|
|
|
Self-supervised / triplet-style representation learner: a frozen conv encoder + trainable linear projection head. |
3D |
No |
Building blocks (konfai.network.blocks)#
If you author your own model — as a Python Network or a YAML graph — these
reusable pieces are the vocabulary:
Conv graphs:
ConvBlock([Conv → Norm → Activation]×N),ResBlock(residual with projected skip),Attention(Attention-U-Net gate),LatentDistribution(VAE reparameterisation, exposesmu/log_std/z).BlockConfig— one conv stage:kernel_size=3, stride=1, padding=1, bias=True, activation="ReLU", norm_mode="NONE".activationaccepts a name, a";"-separated spec ("LeakyReLU;0.2;True"), a callable, orNone.Enums:
NormMode(NONE/BATCH/INSTANCE/GROUP/LAYER/SYNCBATCH/INSTANCE_AFFINE),UpsampleMode(CONV_TRANSPOSE/UPSAMPLE),DownsampleMode(MAXPOOL/AVGPOOL/CONV_STRIDE).Tensor ops (leaf modules):
Add,Multiply,Concat,Detach,ArgMax,Select,View,Permute,NormalNoise, and more.
Note
konfai.network.blocks also defines debug-only blocks — Print, Write,
Exit — that have side effects (print / write-to-disk / raise) on every forward.
They are for graph debugging; do not leave them in a trained model.
Next steps#
Model graph and output naming — named outputs,
outputs_criterions, patchingLosses & metrics — attach losses/metrics to a model’s named outputs
Using custom models, transforms, augmentations, and losses — subclass
Networkyourself