MONAI
MONAI – Medical Open Network for AI
An open-source framework built on PyTorch for deep learning in medical imaging: loading medical images, their transforms, networks and metrics.
Basic information
| Name | MONAI |
|---|---|
| Full name | MONAI – Medical Open Network for AI |
| Category | Computer Vision & Image Processing |
| Developer | The MONAI project (initiated by NVIDIA and King's College London with academic contributors) |
| Release year | 2020 |
| Official website | project-monai.github.io |
| GitHub repository | Project-MONAI/MONAI |
| Official documentation | monai.readthedocs.io |
| Package on PyPI | monai |
| License | Apache-2.0 (PyPI license_expression) |
| Project status | Active Had a release in the last 12 months |
| Latest version | 18 November 2026 (version 1.6.2) |
| Programming language | Python |
| Operating systems | Not specified |
| Required Python version | >=3.10 |
| Difficulty level | Medium |
Data last checked: 21 November 2026 — source: PyPI JSON API (2026-11-21)
Overview
MONAI reads DICOM and NIfTI, offers 3D medical transforms (reorientation, spacing, intensity normalisation and cropping around lesions), ready networks such as UNet, UNETR and SwinUNETR, loss functions such as Dice, medical metrics, and sliding-window inference for large volumes.
It is complemented by MONAI Label for interactive labelling and MONAI Deploy for clinical deployment. It is the reference choice for tumour segmentation and MRI and CT image classification with deep learning.
When to choose it? Choose it for any deep learning project on medical images, especially 3D volumes and segmentation.
Uses
Main uses
- Segmenting organs and tumours in MRI and CT
- Segmenting organs and tumours in MRI and CT
- Medical image classification
- Medical image classification
- 3D transforms and data augmentation
- 3D transforms and data augmentation
- Dice and Hausdorff metrics
- Dice and Hausdorff metrics
Scientific fields
- Radiology
- Radiology
- Oncology
- Oncology
- Digital pathology
- Digital pathology
Suitable project types
- Brain tumour segmentation from MRI
- Brain tumour segmentation from MRI
- Chest X-ray classification
- Chest X-ray classification
Research applications
- 3D segmentation experiments with UNet/UNETR/SwinUNETR architectures
- 3D segmentation experiments with UNet/UNETR/SwinUNETR architectures
- Comparing medical loss functions
- Comparing medical loss functions
Technical features
A feature is shown as "Supported" only if it is documented in the library's official documentation; anything we have not verified is shown as "Not specified".
| CPU support | Supported |
|---|---|
| GPU support | Supported |
| CUDA compatibility | Supported |
| Distributed training or computing | Supported |
| Automatic differentiation (Autodiff) | SupportedThrough PyTorch. |
| Model deployment | SupportedThrough MONAI Deploy and PyTorch export. |
| Pre-trained models | SupportedThrough the MONAI Model Zoo (Bundles). |
| Supported data types | 3D and 4D volumes, DICOM and NIfTI formats |
| Integration with other libraries | PyTorch, TorchIO, SimpleITK, ITK, Captum |
| Flexibility (editorial estimate) | High |
| Performance (editorial estimate) | High |
| Community (editorial estimate) | Active in the medical field |
| Documentation quality (editorial estimate) | Plenty of documentation and tutorials |
Installation and running
pip install monaiFor some optional modules: pip install "monai[all]"
Compatibility: Python >=3.10 — according to the package data on PyPI, checked on 21 November 2026
Compatibility: Python >=3.10 — according to the package data on PyPI, checked on 21 November 2026
Installing inside a virtual environment (venv or conda) is recommended. If you need compatibility with a specific CUDA version or operating system, refer to the official documentation, because this information changes with every release.
Code examples
Examples marked "Run and tested" were actually run, with their output, test date and library versions recorded; the others need a GPU or model downloads, so they were not run in the test environment.
BeginnerA MONAI transform pipeline for a 3D volumeRun and tested
Goal: Normalising the intensity of an MRI volume, cropping it and adding random augmentation.
import numpy as np, torch
from monai.transforms import Compose, NormalizeIntensity, CropForeground, RandFlip, ToTensor
from monai.utils import set_determinism
set_determinism(seed=0)
vol = np.zeros((1, 64, 64, 48), dtype=np.float32)
vol[:, 16:48, 20:44, 10:38] = np.random.default_rng(0).normal(100, 20, (32, 24, 28))
tf = Compose([NormalizeIntensity(nonzero=True), CropForeground(), RandFlip(prob=1.0, spatial_axis=0), ToTensor()])
out = tf(vol)
print("Shape before:", vol.shape, "after cropping:", tuple(out.shape))
nz = out[out != 0]
print(f"Mean intensity after normalisation: {nz.mean().item():.3f}, std: {nz.std().item():.3f}")
Code explanation
MONAI transforms work on arrays in (channel, depth, height, width) format. We apply intensity normalisation, then foreground cropping, then a random flip. Here the volume is randomly generated; with real NIfTI files add LoadImaged at the start.
Output recorded during testing
Shape before: (1, 64, 64, 48) after cropping: (1, 32, 24, 28) Mean intensity after normalisation: -0.000, std: 1.000
This example was actually run and tested on 21 November 2026 on a CPU — monai 1.6.2, torch 2.15.0, python 3.13.18
MediumA 3D UNet with Dice loss in MONAIRun and tested
Goal: Training a small segmentation network for a few steps on synthetic data and monitoring the Dice metric.
import torch
from monai.losses import DiceLoss
from monai.metrics import DiceMetric
from monai.networks.nets import UNet
torch.manual_seed(0)
def sample(n=2, s=32):
g = torch.stack(torch.meshgrid(*[torch.arange(s)] * 3, indexing="ij")).float()
m = (((g - s / 2) ** 2).sum(0) < (s / 4) ** 2).float()
x = m + 0.5 * torch.randn(n, 1, s, s, s)
return x, m.expand(n, 1, s, s, s)
net = UNet(spatial_dims=3, in_channels=1, out_channels=1, channels=(8, 16, 32), strides=(2, 2), num_res_units=1)
loss_fn = DiceLoss(sigmoid=True)
metric = DiceMetric(include_background=True, reduction="mean")
opt = torch.optim.Adam(net.parameters(), 1e-2)
for step in range(1, 31):
x, y = sample()
loss = loss_fn(net(x), y)
opt.zero_grad(); loss.backward(); opt.step()
if step % 10 == 0:
with torch.no_grad():
pred = (torch.sigmoid(net(x)) > 0.5).float()
metric(pred, y); d = metric.aggregate().item(); metric.reset()
print(f"step {step}: dice_loss={loss.item():.4f} dice={d:.3f}")
Code explanation
We build a 3D UNet from MONAI, use DiceLoss, which suits the pixel imbalance between tumour and background, and DiceMetric for evaluation. The data is a synthetic sphere inside noise; the goal is to illustrate the API, not a clinical result.
Output recorded during testing
step 10: dice_loss=0.7871 dice=0.434 step 20: dice_loss=0.7600 dice=0.592 step 30: dice_loss=0.7150 dice=0.657
This example was actually run and tested on 21 November 2026 on a CPU — monai 1.6.2, torch 2.15.0, python 3.13.18
AdvancedSliding-window inference on a large volumeRun and tested
Goal: Running a network on a volume larger than the training size without running out of memory.
import torch
from monai.inferers import sliding_window_inference
from monai.networks.nets import UNet
net = UNet(3, 1, 2, channels=(8, 16, 32), strides=(2, 2)).eval()
volume = torch.randn(1, 1, 160, 160, 96)
with torch.no_grad():
out = sliding_window_inference(volume, roi_size=(64, 64, 64), sw_batch_size=4,
predictor=net, overlap=0.25, mode="gaussian")
print("Input size:", tuple(volume.shape))
print("Output size:", tuple(out.shape))
Code explanation
sliding_window_inference splits the volume into patches of roi_size with a given overlap, runs the network on each batch of patches, then merges the results with weights. This is how a network trained on 64³ patches is applied to a full scan.
Output recorded during testing
Input size: (1, 1, 160, 160, 96) Output size: (1, 2, 160, 160, 96)
This example was actually run and tested on 21 November 2026 on a CPU — monai 1.6.2, torch 2.15.0, python 3.13.18
Pros
- Designed specifically for medical images
- Ready medical transforms, networks and metrics
- An active academic and medical community
Limitations
- Requires good knowledge of PyTorch
- The many modules can confuse beginners
References and verification
- Package page on PyPI (source of the version, licence and release date) Checked directly
https://pypi.org/project/monai/
Checked on: 21 November 2026 — version checked: 1.6.2 — reviewed by: the DLArabic team
- Official website A link the package officially declares on PyPI
https://project-monai.github.io/
Checked on: 21 November 2026 — reviewed by: the DLArabic team
- Official documentation A link the package officially declares on PyPI
https://monai.readthedocs.io/
Checked on: 21 November 2026 — reviewed by: the DLArabic team
- Official repository A link the package officially declares on PyPI
https://github.com/Project-MONAI/MONAI
Checked on: 21 November 2026 — reviewed by: the DLArabic team
- Package page on PyPI (source of the version, licence and release date) Checked directly
https://pypi.org/project/monai/
Checked on: 21 November 2026 — version checked: 1.6.2 — reviewed by: the DLArabic team
- Official website A link the package officially declares on PyPI
https://project-monai.github.io/
Checked on: 21 November 2026 — reviewed by: the DLArabic team
- Official documentation A link the package officially declares on PyPI
https://monai.readthedocs.io/
Checked on: 21 November 2026 — reviewed by: the DLArabic team
- Official repository A link the package officially declares on PyPI
https://github.com/Project-MONAI/MONAI
Checked on: 21 November 2026 — reviewed by: the DLArabic team
History of verified versions
| Version | Release date | Checked on |
|---|---|---|
| 1.6.2 | 18 November 2026 | 21 November 2026 |
Page information last reviewed: 21 November 2026. The description was written originally for the encyclopedia and is not copied from the official websites.
