Beothuk's picture
Add comprehensive dataset card with FL usage instructions
b36fb5c verified

license: cc-by-nc-4.0
task_categories:
- image-classification
tags:
- medmnist
- medical-imaging
- skin-cancer
- federated-learning
- healthcare
size_categories:
- 10K<n<100K
---

# DermaMNIST Dataset for Federated Learning

## Dataset Description

**DermaMNIST** is a multi-class dataset of dermatoscopic images for skin lesion classification. It is part of the [MedMNIST v2](https://medmnist.com/) collection, a set of standardized biomedical image datasets for machine learning. This version of the dataset has been prepared for easy use in federated learning simulations, particularly with the [Flower](https://flower.dev/) framework.

The dataset is based on the [HAM10000](https://doi.org/10.1038/sdata.2018.161) dataset, a large collection of multi-source dermatoscopic images of common pigmented skin lesions. The images are 28x28 pixels and resized from their original 600x450 resolution.

### Classes
The dataset contains 7 classes of skin lesions:
- **0**: `actinic keratoses and intraepithelial carcinoma`
  • 1: basal cell carcinoma

  • 2: benign keratosis-like lesions

  • 3: dermatofibroma

  • 4: melanoma

  • 5: melanocytic nevi

  • 6: vascular lesions

    Dataset Statistics

    • Number of classes: 7
    • Training samples: 7,007
    • Test samples: 2,005
    • Total samples: 9,012

    Dataset Structure

    Data Fields

    • image: A PIL Image object of size 28x28.
    • label: The integer class ID.
    • label_name: The string name of the class label.

    Data Splits

    • Train: 7,007 samples
    • Test: 2,005 samples

    Usage with Flower Datasets 🌸

    This dataset is ideal for federated learning simulations where data is distributed across multiple clients (e.g., hospitals). Here's how to use it with Flower Datasets:

    from flwr_datasets import FederatedDataset
    
    # Define the number of clients (e.g., simulating 10 hospitals)
    NUM_CLIENTS = 10
    
    # Load the dataset and partition it into 10 clients
    fds = FederatedDataset(dataset="your-username/dermamnist-fl", partitioners={"train": NUM_CLIENTS})
    
    # Get the data for a specific client
    client_data = fds.load_partition(0, "train")
    
    # You can now use this client_data with your standard PyTorch or TensorFlow data loaders.
    # For example, to set the format for PyTorch:
    # client_data.set_format(type="torch", columns=["image", "label"])
    

    Citation

    If you use this dataset in your research, please cite the following paper:

    @article{medmnistv2,
        title={MedMNIST v2: A Large-Scale Lightweight Benchmark for 2D and 3D Biomedical Image Classification},
        author={Jiancheng Yang and Rui Shi and Donglai Wei and Zequan Liu and Lin Zhao and Bilian Ke and Hanspeter Pfister and Bingbing Ni},
        journal={Scientific Data},
        year={2023},
        volume={10},
        number={1},
        pages={41},
        doi={10.1038/s41597-022-01721-8}
    }
    

    Citation

        @article{medmnistv2,
            title={MedMNIST v2: A Large-Scale Lightweight Benchmark for 2D and 3D Biomedical Image Classification},
            author={Jiancheng Yang and Rui Shi and Donglai Wei and Zequan Liu and Lin Zhao and Bilian Ke and Hanspeter Pfister and Bingbing Ni},
            journal={Scientific Data},
            year={2023},
            volume={10},
            number={1},
            pages={41},
            doi={10.1038/s41597-022-01721-8}
        }
    

    Example Usage with datasets

    from datasets import load_dataset
    from PIL import Image
    
    # Load the dataset
    dataset = load_dataset("your-username/dermamnist-fl")
    
    # Access the training split
    train_data = dataset["train"]
    print(f"Number of training samples: {len(train_data)}")
    
    # Access a sample
    sample = train_data[100]
    image: Image = sample['image']
    print(f"Image size: {image.size}")
    print(f"Label: {sample['label']}")
    print(f"Label name: {sample['label_name']}")
    
    # To display the image
    # image.show()