Lightweight inference package for dafne models
Project description
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 —
DafneUnetModelandDafneDynUnetModel, wrapping MONAI'sUNetandDynUNetwith 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+)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dafne_monai_inference-1.0.0.tar.gz.
File metadata
- Download URL: dafne_monai_inference-1.0.0.tar.gz
- Upload date:
- Size: 10.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5fb2ed250c05d26fe54322610400648f3911983018481a99e6589ac1c406cf53
|
|
| MD5 |
4e5d4602347465e0e0cbf2341bcc8bc3
|
|
| BLAKE2b-256 |
3631788d8a2b749db8a8cbbd911bb21fdd4ab959cc026b22e2e6e2207a302bae
|
File details
Details for the file dafne_monai_inference-1.0.0-py3-none-any.whl.
File metadata
- Download URL: dafne_monai_inference-1.0.0-py3-none-any.whl
- Upload date:
- Size: 11.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c7b21e5eac2eb7fb7610b14e8a3a7e507631f61768a0f2c683901e9eac66d711
|
|
| MD5 |
e70ac6e2eb963bee7130ab45e712fd5f
|
|
| BLAKE2b-256 |
2bbac779d3db0772644e8a028a4dfddd43bc4e8b9d052ef25e125f83a924eb6f
|