Skip to content

Commit

Permalink
release as v2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
duducheng committed Aug 19, 2021
1 parent 1fb9a63 commit ece2a9d
Show file tree
Hide file tree
Showing 6 changed files with 463 additions and 518 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# MedMNIST
## Project Page ([Website](https://medmnist.github.io/)) | V2 Paper ([arXiv](#TODO)) | V1 Paper ([ISBI'21](https://arxiv.org/abs/2010.14925)) | Dataset ([Zenodo](https://doi.org/10.5281/zenodo.5208230))
## Project Page ([Website](https://medmnist.github.io/)) | Dataset ([Zenodo](https://doi.org/10.5281/zenodo.5208230)) | V2 Paper ([arXiv](#TODO)) | V1 Paper ([ISBI'21](https://arxiv.org/abs/2010.14925))
[Jiancheng Yang](https://jiancheng-yang.com/), Rui Shi, [Donglai Wei](https://donglaiw.github.io/), Zequan Liu, Lin Zhao, [Bilian Ke](https://scholar.google.com/citations?user=2cX5y8kAAAAJ&hl=en), [Hanspeter Pfister](https://scholar.google.com/citations?user=VWX-GMAAAAAJ&hl=en), [Bingbing Ni](https://scholar.google.com/citations?user=eUbmKwYAAAAJ)

We introduce *MedMNIST v2*, a large-scale MNIST-like collection of standardized biomedical images, including 12 datasets for 2D and 6 datasets for 3D. All images are pre-processed into $28\times 28$ (2D) or $28\times 28\times 28$ (3D) with the corresponding classification labels, so that no background knowledge is required for users. Covering primary data modalities in biomedical images, MedMNIST v2 is designed to perform classification on lightweight 2D and 3D images with various data scales (from 100 to 100,000) and diverse tasks (binary/multi-class, ordinal regression and multi-label). The resulting dataset, consisting of 708,069 2D images and 10,214 3D images in total, could support numerous research / educational purposes in biomedical image analysis, computer vision and machine learning. We benchmark several baseline methods on MedMNIST v2, including 2D / 3D neural networks and open-source / commercial AutoML tools.
Expand Down Expand Up @@ -27,7 +27,7 @@ Please note that this dataset is **NOT** intended for clinical use.
* [`getting_started.ipynb`](examples/getting_started.ipynb): Explore the MedMNIST dataset with jupyter notebook. It is **ONLY** intended for a quick exploration, i.e., it does not provide full training and evaluation functionalities.
* [`getting_started_without_PyTorch.ipynb`](examples/getting_started_without_PyTorch.ipynb): This notebook provides snippets about how to use MedMNIST data (the `.npz` files) without PyTorch.
* [`setup.py`](setup.py): The script to install medmnist as a module
* [EXTERNAL] [`MedMNIST/experiments`](https://github.com/MedMNIST/experiments): training and evaluation scripts to reproduce experiments in our paper, including PyTorch, auto-sklearn, AutoKeras and Google AutoML Vision together with their weights ;)
* [EXTERNAL] [`MedMNIST/experiments`](https://github.com/MedMNIST/experiments): training and evaluation scripts to reproduce both 2D and 3D experiments in our paper, including PyTorch, auto-sklearn, AutoKeras and Google AutoML Vision together with their weights ;)

# Installation and Requirements
Setup the required environments and install `medmnist` as a standard Python package:
Expand Down
36 changes: 36 additions & 0 deletions examples/dataset_without_pytorch.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import random
import numpy as np
from collections import Sequence
from PIL import Image
Expand Down Expand Up @@ -90,6 +91,15 @@ def download(self):
'Go to the homepage to download manually. ' +
HOMEPAGE)

@staticmethod
def _collate_fn(data):
xs = []
ys = []
for x, y in data:
xs.append(np.array(x))
ys.append(y)
return np.array(xs), np.array(ys)


class MedMNIST2D(MedMNIST):

Expand Down Expand Up @@ -273,3 +283,29 @@ class SynapseMNIST3D(MedMNIST3D):
OrganMNISTAxial = OrganAMNIST
OrganMNISTCoronal = OrganCMNIST
OrganMNISTSagittal = OrganSMNIST


def get_loader(dataset, batch_size):
total_size = len(dataset)
print('Size', total_size)
index_generator = shuffle_iterator(range(total_size))
while True:
data = []
for _ in range(batch_size):
idx = next(index_generator)
data.append(dataset[idx])
yield dataset._collate_fn(data)


def shuffle_iterator(iterator):
# iterator should have limited size
index = list(iterator)
total_size = len(index)
i = 0
random.shuffle(index)
while True:
yield index[i]
i += 1
if i >= total_size:
i = 0
random.shuffle(index)
421 changes: 238 additions & 183 deletions examples/getting_started.ipynb

Large diffs are not rendered by default.

516 changes: 185 additions & 331 deletions examples/getting_started_without_PyTorch.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion medmnist/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from medmnist.info import __version__, HOMEPAGE
from medmnist.info import __version__, HOMEPAGE, INFO
from medmnist.dataset import (PathMNIST, ChestMNIST, DermaMNIST, OCTMNIST, PneumoniaMNIST, RetinaMNIST,
BreastMNIST, BloodMNIST, TissueMNIST, OrganAMNIST, OrganCMNIST, OrganSMNIST,
OrganMNIST3D, NoduleMNIST3D, AdrenalMNIST3D, FractureMNIST3D, VesselMNIST3D, SynapseMNIST3D)
Expand Down
2 changes: 1 addition & 1 deletion medmnist/info.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "1.3"
__version__ = "2.0.0"


import os
Expand Down

0 comments on commit ece2a9d

Please sign in to comment.