🏥 MedMNIST-C
We introduce MedMNIST-C [preprint], a benchmark dataset based on the MedMNIST+ collection covering 12 2D datasets and 9 imaging modalities. We simulate task and modality-specific image corruptions of varying severity to comprehensively evaluate the robustness of established algorithms against real-world artifacts and distribution shifts. We further show that our simple-to-use artificial corruptions allow for highly performant, lightweight data augmentation to enhance model robustness.
Installation and Requirements
pip install medmnistc
We do require Wand for image manipulation, a Python binding for ImageMagick. Thus, if you are using Ubuntu:
sudo apt-get install libmagickwand-dev
otherwise, please check the tutorial.
Main components
medmnistc/corruptions/registry.py: List of all the corruptions and respective intensity hyperparameters.medmnistc/dataset_manager.py: Dataset class responsible for the creation of the corrupted datasets.medmnistc/visualizer.py: Class used to visualize and store the defined corruptions.medmnistc/augmentation.py: Augumentation class based on the defined corruptions.medmnistc/dataset.py: Dataset class used for the corrupted datasets.medmnistc/eval.py: PyTorch class used for model evaluation under corrupted datasets.medmnistc/assets/baseline/*: Normalization baselines used for model evaluation under corrupted datasets.
Basic usage
Create the corrupted datasets
from medmnistc.dataset_manager import DatasetManager
medmnist_path = ... # PATH TO THE CLEAN IMAGES
medmnistc_path = ... # PATH TO THE CORRUPTED IMAGES
ds_manager = DatasetManager(medmnist_path = medmnist_path, output_path=output_path)
ds_manager.create_dataset(dataset_name = "breastmnist") # create a single corrupted test set
ds_manager.create_dataset(dataset_name = "all") # create all
Augmentations
from medmnistc.augmentation import AugMedMNISTC
from medmnistc.corruptions.registry import CORRUPTIONS_DS
import torchvision.transforms as transforms
dataset = "breastmnist" # select dataset
train_corruptions = CORRUPTIONS_DS[dataset] # load the designed corruptions for this dataset
images = ... # load images
# Augment with AugMedMNISTC
augment = AugMedMNISTC(train_corruptions)
augmented_img = augment(images[0])
# Integrate into transforms.Compose
aug_compose = transforms.Compose([
AugMedMNISTC(train_corruptions),
transforms.ToTensor(),
transforms.Normalize(mean=..., std=...)
])
augmented_img = aug_compose(images[0])
Notebooks
- Create the dataset
- Visualize the corruptions
- Evaluate the corruptions
- Use the designed augmentations
License
The code is under Apache-2.0 License.
The MedMNIST-C dataset is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0), except DermaMNIST-C under Creative Commons Attribution-NonCommercial 4.0 International (CC BY-NC 4.0).
Citation
If you find this work useful, please consider citing us:
@article{,
title={},
author={},
journal={},
year={}
}
DISCLAIMER: This repository is inspired by MedMNIST APIs and the ImageNet-C repository. Thus, please also consider citing MedMNIST, the respective source datasets (described here) and ImageNet-C.
Release versions
v0.1.0: MedMNIST-C beta release.
Metadata
Release files for medmnistc 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| medmnistc-0.1.0.tar.gz | 4.9 MB | Without provenance | Details for medmnistc-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| medmnistc-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for medmnistc-0.1.0-py3-none-any.whl |
Total release size: 4.9 MB
Release files / medmnistc-0.1.0.tar.gz
| Download URL | medmnistc-0.1.0.tar.gz |
|---|---|
| Size | 4.9 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e3898a8ff5cec9be9e969314d1207f677d8d933dfcafe4576f4a102776654d36
|
|
BLAKE2b-256 checksum How to use checksums |
4c7d1ab377e05bbae1853b95103713670a2f7c1af05b3ddeadf2165608d9e7d1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.11.4
|
Release files / medmnistc-0.1.0-py3-none-any.whl
| Download URL | medmnistc-0.1.0-py3-none-any.whl |
|---|---|
| Size | 32.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4529626f0ce7e498fe876acd12e50c3776103f9bfeb99afd3e7dba34a1779e34
|
|
BLAKE2b-256 checksum How to use checksums |
231f01546d9b6077570c3cdcc181dd586ece77914c1905b45a25fb9e7ab29a0d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.11.4
|
Security for medmnistc 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.