Skip to content

Repository files navigation

medicai

Palestine

Static Badge Static Badge Static Badge Static Badge

Medic-AI is a Keras based library designed for medical 2D and 3D image analysis using machine learning techniques. Its core strengths include:

  • Backend Agnostic: Compatible with tensorflow, torch, and jax.
  • User-Friendly API: High-level interface for transformations and model creation of both 2D and 3D.
  • Scalable Execution: Supports training and inference on single/multi-GPU and TPU-VM setups.
  • Essential Components: Includes standard medical specific metrics and losses, such as Dice. Support GradCAM for segmentation and classification on both 2D and 3D input.
  • Optimized 3D Inference: Offers an efficient sliding-window method and callback for volumetric data.

📋 Table of Contents

  1. Installation
  2. Features
  3. Documentation
  4. Acknowledgements
  5. Citation

🛠 Installation

PyPI version:

pip install medicai

This installs medicai and keras, but leaves backend runtime selection to you. Install tensorflow, torch, or jax separately based on your workflow.

Installing from source GitHub: (recommended)

pip install git+https://github.com/innat/medic-ai.git

Using uv for local development:

uv venv --python 3.10
source .venv/bin/activate
uv pip install -e .[dev]

Optional extras:

pip install "medicai[docs]"
pip install "medicai[test]"
pip install "medicai[dev]"

Quick Overview

For details end-to-end training workflow, please check the code-example section.

from medicai.models import SwinUNETR, UNet
from medicai.models import SwinTiny, SwinTinyV2
from medicai.models import SwinBackbone, SwinBackboneV2

# Build 3D model.
model = SwinUNETR(
    encoder_name='swin_tiny_v2', input_shape=(96,96,96,1)
)
model = UNet(
    encoder_name='densenet121', input_shape=(96,96,96,1)
)

# Build 2D model.
model = SwinUNETR(
    encoder_name='swin_tiny_v2', input_shape=(96,96,1)
)
model = UNet(
    encoder_name='densenet121', input_shape=(96,96,1)
)
# Build with pre-built encoder.
encoder = SwinTiny(
    input_shape=(96,96,96,1),
    patch_size=2, 
    downsampling_strategy='swin_unetr_like'
)
model = SwinUNETR(encoder=encoder)

# Build with custom encoder.
custom_encoder = SwinBackboneV2(
    input_shape=(64, 128, 128, 1),
    embed_dim=48,
    window_size=8,
    patch_size=2,
    downsampling_strategy='swin_unetr_like'
)
model = SwinUNETR(encoder=custom_encoder)

📊 Features

Available Models : The following table lists the currently supported models along with their supported input modalities, primary tasks, and underlying architecture type. The model inputs can be either 3D (depth × height × width × channel) or 2D (height × width × channel).

Model Supported Modalities Primary Task Architecture Type
DenseNet 2D, 3D Classification CNN
ResNet-V1,V2 2D, 3D Classification CNN
ResNeXt 2D, 3D Classification CNN
SE-ResNet 2D, 3D Classification CNN
SE-ResNeXt 2D, 3D Classification CNN
Xception 2D, 3D Classification CNN
EfficientNet-V1,V2 2D, 3D Classification CNN
ConvNeXt-V1,V2 2D, 3D Classification CNN
ViT 2D, 3D Classification Transformer
MiT 2D, 3D Classification Transformer
Swin Transformer-V1,V2 2D, 3D Classification Transformer
UNet 2D, 3D Segmentation CNN
UNet++ 2D, 3D Segmentation CNN
AttentionUNet 2D, 3D Segmentation CNN
DeepLabV3Plus 2D, 3D Segmentation CNN
UPerNet 2D, 3D Segmentation CNN
UNETR 2D, 3D Segmentation Transformer
UNETR++ 2D, 3D Segmentation Transformer
SwinUNETR 2D, 3D Segmentation Transformer
SwinUNETR-V2 2D, 3D Segmentation Transformer
TransUNet 2D, 3D Segmentation Transformer
SegFormer 2D, 3D Segmentation Transformer

Available Transformation: The following preprocessing and transformation methods are supported for volumetric data. The following layers are implemented with TensorFlow operations. It can be used in the tf.data API or a Python data generator and is fully compatible with multiple backends, tf, torch, jax in training and inference, supporting both GPUs and TPUs.

CropForeground
NormalizeIntensity
Orientation
RandomCropByPosNegLabel
RandomFlip
RandomRotate90
RandomRotate
RandomCutOut
RandomShiftIntensity
RandomSpatialCrop
Resize
ScaleIntensityRange
Spacing

📚 Documentation

To learn more about models, transformations, and training, please visit the Read the Docs documentation: medicai.readthedocs.io

🤝 Contributing

Please check the contribution guide here.

🙏 Acknowledgements

This project is greatly inspired by MONAI.

📝 Citation

If you use medicai in your research or educational purposes, please cite it using the metadata from our CITATION.cff file.

About

AI Toolkit for Healthcare Imaging in Keras 3

Topics

Resources

Stars

25 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages