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.segmentation#
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 |
|
|
UNet++ on a ResNet-style encoder. |
|
2D |
Yes |
Note
The Model:UNetpp5 used in the Synthesis example is a local class in
examples/Synthesis/Model.py wrapping segmentation_models_pytorch, not the
built-in UNetpp above.
Classification — konfai.models.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.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.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.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