Keras-based medical 2D and 3D image analysis library.
Project description
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, andjax. - 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
🛠 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 guide 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.
Project details
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 medicai-0.0.4.tar.gz.
File metadata
- Download URL: medicai-0.0.4.tar.gz
- Upload date:
- Size: 237.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b273ea4ba68f301be8e8058021dd212d1387dfd4ecae5e8ecf5a2219b6dcca5b
|
|
| MD5 |
a0e6a5f1c60f68d9153e0f5d293cbc92
|
|
| BLAKE2b-256 |
8125affe17102b3a61a67d007f5036534c9be5a3bab552271723d4137157f9a3
|
File details
Details for the file medicai-0.0.4-py3-none-any.whl.
File metadata
- Download URL: medicai-0.0.4-py3-none-any.whl
- Upload date:
- Size: 316.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
abc4e2512541e810d1e44bc6b43ce0d3f927a505930b0412fe1cb634d8d3b074
|
|
| MD5 |
6bf0c14a1877a0e40b7b78a098b49086
|
|
| BLAKE2b-256 |
535cf6af066ae62751d7903cc33c425479f4d62162f8da325662786f3b19f96e
|