Skip to main content

MedIM is a all-in-one collection for Medical Image Models in PyTorch Style.

Project description

Med-IM: One-Line Code to Get SoTA Pre-trained Medical Image Models

x x

A collection of pre-trained medical image models in PyTorch. This repository aims to provide a unified and easy-to-use interface for comparing and deploying these models.

Supported Models

  • STU-Net (STU-Net-S, STU-Net-B, STU-Net-L, STU-Net-H) pre-trained on TotalSegmentator, CT-ORG, FeTA21, BraTS21 (more datasets are WIP).
  • SAM-Med3D (SAM-Med3D) pre-trained on SA-Med3D-140K.
  • Other pre-trained medical image models are WIP. (You can request support for your model in Issues.)

Quick Start

Setup Environment

You can use this cmd to install this toolkit via pip:

pip install medim

For developers, you can install in the editable mode via:

git clone https://github.com/uni-medical/MedIM.git
cd MedIM
pip install -e .

Example Usage

First, let us import medim.

import medim

You have four ways to create a PyTorch-compatible model with create_model:

1. use models without pretraining

model = medim.create_model("STU-Net-S") 

2. use local checkpoint

model = medim.create_model(
            "STU-Net-S",
            pretrained=True,
            checkpoint_path="../tests/data/small_ep4k.model") 

3. use checkpoint pre-trained on validated datasets (will automatically download it from HuggingFace)

model = medim.create_model("STU-Net-B", dataset="BraTS21")

4. use HuggingFace url (will automatically download it from HuggingFace)

model = medim.create_model(
            "STU-Net-S",
            pretrained=True,
            checkpoint_path="https://huggingface.co/ziyanhuang/STU-Net/blob/main/small_ep4k.model") 

Tips: you can use MEDIM_CKPT_DIR environment variable to set custom path for medim model downloading from huggingface.

Then, you can use it as you like.

input_tensor = torch.randn(1, 1, 128, 128, 128)
output_tensor = model(input_tensor)
print("Output tensor shape:", output_tensor.shape)

More examples are in examples.

Roadmap & TO-DO

  • support more pre-training of STU-Net on different datasets.
  • support more pre-trained medical image models.
  • An easy-to-use interface compatible with MONAI/nnU-Net is still under development. Once developed, you will be able to deploy medical image models more elegantly within the Python/PyTorch ecosystem.

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

medim-0.1.2.tar.gz (28.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

medim-0.1.2-py3-none-any.whl (27.3 kB view details)

Uploaded Python 3

File details

Details for the file medim-0.1.2.tar.gz.

File metadata

  • Download URL: medim-0.1.2.tar.gz
  • Upload date:
  • Size: 28.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for medim-0.1.2.tar.gz
Algorithm Hash digest
SHA256 4dabea6faf8f89b80b064eca67580b483164c0be8b50b70880e2dd5e2e0929b6
MD5 59a8ea6c850e1f574c1435c697cae7de
BLAKE2b-256 f64eedfc845fe72247668c1f43b306cae7f719d834279496d823d67cf6506b88

See more details on using hashes here.

File details

Details for the file medim-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: medim-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 27.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for medim-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c08a84718aa7ccb1494ccdee781785f955daecb915ba15b2db77455137e503fc
MD5 bfd5f8ad2f8582caac319752de4d10dd
BLAKE2b-256 ed5bce521372626f80a9fa9c36379eb2ad591c075cb937c03cb0efeb9380e966

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page