Skip to main content

dafne-monai-inference

Lightweight inference and incremental learning package for Dafne models, built on MONAI and PyTorch.

Overview

This package provides:

  • Inference — sliding-window (3D) and slice-by-slice (2D) segmentation inference using trained Dafne models
  • Incremental learning — online fine-tuning of a deployed model on new annotated data, with optional EWC (Elastic Weight Consolidation) regularization to prevent catastrophic forgetting
  • Network architecturesDafneUnetModel and DafneDynUnetModel, wrapping MONAI's UNet and DynUNet with Dafne-compatible interfaces
  • Transforms — preprocessing pipeline with anisotropy handling, spacing normalization, and bounding-box cropping

Installation

pip install dafne-monai-inference

Requirements

  • Python >= 3.8
  • torch >= 2.0
  • monai >= 1.3
  • numpy >= 1.24
  • scikit-image >= 0.19

Usage

Inference

from dafne_inference.inference import run_inference

# model_obj: a DynamicTorchModel loaded from a .model file
# data_dict must contain 'image' (numpy array) and either 'affine' or 'resolution'
result = run_inference(model_obj, data_dict)
# result: dict { label_name: binary_mask (np.int8) }

Incremental learning

from dafne_inference.incremental import run_incremental_learning

# trainingData: dict with key 'image_list' (list of numpy arrays) and 'resolution'
# trainingOutputs: dict of masks corresponding to each image
run_incremental_learning(model_obj, trainingData, trainingOutputs, bs=1, minTrainImages=2)

Network architectures

from dafne_inference.networks import DafneUnetModel, DafneDynUnetModel

# Standard UNet
model = DafneUnetModel(
    spatial_dims=3,
    in_channels=1,
    out_channels=5,
    start_channel=32,
    n_levels=5
)

# Dynamic UNet (nnU-Net style)
model = DafneDynUnetModel(
    spatial_dims=3,
    in_channels=1,
    out_channels=5,
    kernels=[[3,3,3], [3,3,3], [3,3,3]],
    strides=[[1,1,1], [2,2,2], [2,2,2]]
)

License

GNU General Public License v3 or later (GPLv3+)

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dafne_monai_inference-1.0.2.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dafne_monai_inference-1.0.2-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file dafne_monai_inference-1.0.2.tar.gz.

File metadata

  • Download URL: dafne_monai_inference-1.0.2.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for dafne_monai_inference-1.0.2.tar.gz
Algorithm Hash digest
SHA256 a15b721464449a729337cacfe497e481a19759e36ce871222de3bb2f37d9fb10
MD5 820c7b4828e18be18c4b88c044c74888
BLAKE2b-256 5a5bca0909ec7e1db35bb30f8e6b1567cf3b7493bdd66d3c77d208fa2e6c192c

See more details on using hashes here.

File details

Details for the file dafne_monai_inference-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for dafne_monai_inference-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e1144970db2f5a14cc630a8860448c753210d63a17e10a2ca45ba2a6e8db1529
MD5 2e105264a22ccaccd0e6882107ea7597
BLAKE2b-256 2d20a88de256a94f6253a9f453456bd43c3a21bd647b7df9d49d4ada2463f6f8

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 files

1.0.1

2 files

1.0.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page