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.1.tar.gz (10.7 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.1-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dafne_monai_inference-1.0.1.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.7

File hashes

Hashes for dafne_monai_inference-1.0.1.tar.gz
Algorithm Hash digest
SHA256 d2082242dcfcc292e52ba00e4e99b7c01ef8226e72ba7f3a0d01e8ae7b2910c9
MD5 6cdabd2285057ea11400f6ce05808128
BLAKE2b-256 c31be27e7a0c776281365ea5a1f1b07edb343da53eec7e472435250549d73db7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dafne_monai_inference-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 405f2479cf56d60ebb9a8482789306bbdc1e96e763df60df791523348fdece6c
MD5 8c1e6ec11d1cd80693c70c24b3350c67
BLAKE2b-256 b978b3f0ccc28380ca0e22b9ba528b9ff80507db1a17c45c5064d400e0f64e95

See more details on using hashes here.

Release history Release notifications | RSS feed

1.0.2

2 files

This release

1.0.1 This release

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