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 architectures — DafneUnetModel 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+)

Metadata

Release files for dafne-monai-inference 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dafne-monai-inference 1.0.2
File Size Uploaded
dafne_monai_inference-1.0.2.tar.gz 11.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dafne-monai-inference 1.0.2
File Interpreter ABI Platform
dafne_monai_inference-1.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 22.9 kB

Release files / dafne_monai_inference-1.0.2.tar.gz

Download URL dafne_monai_inference-1.0.2.tar.gz
Size 11.0 kB
Tags Source
SHA-256 checksum
How to use checksums
a15b721464449a729337cacfe497e481a19759e36ce871222de3bb2f37d9fb10
BLAKE2b-256 checksum
How to use checksums
5a5bca0909ec7e1db35bb30f8e6b1567cf3b7493bdd66d3c77d208fa2e6c192c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / dafne_monai_inference-1.0.2-py3-none-any.whl

Download URL dafne_monai_inference-1.0.2-py3-none-any.whl
Size 11.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e1144970db2f5a14cc630a8860448c753210d63a17e10a2ca45ba2a6e8db1529
BLAKE2b-256 checksum
How to use checksums
2d20a88de256a94f6253a9f453456bd43c3a21bd647b7df9d49d4ada2463f6f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page