HyperKvasirDataset / README.md
AhmadMM2024's picture
Update README.md
5c65438 verified
|
Raw History Blame Contribute Delete
9.29 kB
metadata
dataset_info:
  features:
    - name: image_id
      dtype: string
    - name: image
      dtype: image
    - name: organ
      dtype: string
    - name: category
      dtype: string
    - name: finding
      dtype: string
    - name: label
      dtype: int32
  splits:
    - name: train
      num_bytes: 2438255685
      num_examples: 10662
  download_size: 3935481324
  dataset_size: 2438255685
configs:
  - config_name: default
    data_files:
      - split: train
        path: data/train-*
license: cc-by-4.0
task_categories:
  - image-classification
language:
  - en
tags:
  - endoscopy
  - gastrointestinal
  - colonoscopy
  - gastroscopy
  - polyps
  - medical
  - classification
pretty_name: HyperKvasir
size_categories:
  - 10K<n<100K

HyperKvasir — Labeled Gastrointestinal Endoscopy Images

This dataset is derived from HyperKvasir (Borgli et al., 2020), a multi-class image and video dataset of the gastrointestinal (GI) tract, originally hosted by Simula and mirrored on OSF. The images were collected during routine gastroscopies and colonoscopies in Norway and labelled by experienced gastrointestinal endoscopists into 23 classes covering anatomical landmarks, pathological findings, mucosal-view quality and therapeutic interventions. Here, we provide only the 10,662 labeled images. We kept the original JPG images unchanged and added the organ, category, finding and an integer label, all taken from the original folder structure. The dataset is designed for GI endoscopy image classification.

📦 Dataset Structure

The dataset has a single train split, with each row corresponding to a single endoscopy image:

Field Description
image_id Original image filename without extension (a UUID)
image RGB endoscopy image (variable resolution, JPG)
organ lower-gi-tract (colonoscopy) or upper-gi-tract (gastroscopy)
category anatomical-landmarks, pathological-findings, quality-of-mucosal-views or therapeutic-interventions
finding One of 23 classes (e.g., polyps, cecum, esophagitis-a)
label Integer class 0–22: the index of finding in the alphabetically sorted list of classes

⚙️ Preprocessing

  • hyper-kvasir-labeled-images.zip was downloaded from https://datasets.simula.no/hyper-kvasir/ (the full 58.6 GB release, including videos and unlabeled images, was not used)
  • Images were kept as the original JPG files (no re-encoding, resizing, cropping or color normalization)
  • organ, category and finding were taken from each image's folder path: labeled-images/<organ>/<category>/<finding>/<image>.jpg
  • label is the index of finding in the alphabetically sorted list of the 23 classes
  • All labeled images were preserved

🚀 Usage

from datasets import load_dataset
import matplotlib.pyplot as plt

ds = load_dataset("chehablab/HyperKvasir", split="train")

# One example image per class
findings = ds["finding"]
classes = sorted(set(findings))
fig, axes = plt.subplots(4, 6, figsize=(16, 11))
for ax in axes.flat:
    ax.axis("off")
for ax, c in zip(axes.flat, classes):
    sample = ds[findings.index(c)]
    ax.imshow(sample["image"])
    ax.set_title(f"{c}\n{sample['organ']}", fontsize=8)
plt.tight_layout()
plt.show()

# Filter by organ or category
polyps = ds.filter(lambda x: x["finding"] == "polyps")
upper_gi = ds.filter(lambda x: x["organ"] == "upper-gi-tract")
print(f"Polyps: {len(polyps)}, upper GI: {len(upper_gi)}")

# No split in this release: make a stratified train/test split
split = ds.class_encode_column("label").train_test_split(test_size=0.2, stratify_by_column="label", seed=0)

🏷️ Feature Descriptions

Classes

23 classes, grouped by organ and category:

Lower GI tract (colonoscopy)

  • Anatomical landmarks
    • Cecum — Most proximal part of the colon; reaching it confirms a complete colonoscopy
    • Ileum — Terminal ileum, reached through the ileocecal valve
    • Retroflex rectum — Retroflexed view of the distal rectum
  • Pathological findings
    • Hemorrhoids — Dilated vascular structures in the anal canal
    • Polyps — Mucosal growths, potential precursors of colorectal cancer
    • Ulcerative colitis, grade 0–1 / 1 / 1–2 / 2 / 2–3 / 3 — Inflammation graded by severity on the Mayo endoscopic score
  • Quality of mucosal views
    • BBPS 0–1 — Poor bowel preparation (Boston Bowel Preparation Scale 0–1)
    • BBPS 2–3 — Good bowel preparation (BBPS 2–3)
    • Impacted stool — Stool that blocks the view of the mucosa
  • Therapeutic interventions
    • Dyed lifted polyps — Polyps lifted by injection of dyed saline before removal
    • Dyed resection margins — Resection site after polyp removal

Upper GI tract (gastroscopy)

  • Anatomical landmarks
    • Pylorus — Opening from the stomach into the duodenum
    • Retroflex stomach — Retroflexed view of the upper stomach and cardia
    • Z-line — Junction between the esophagus and the stomach
  • Pathological findings
    • Barrett's — Barrett's esophagus (metaplasia of the distal esophagus)
    • Barrett's, short segment — Short-segment Barrett's esophagus
    • Esophagitis A — Mild esophagitis (Los Angeles grade A)
    • Esophagitis B–D — More severe esophagitis (Los Angeles grades B–D)

Image Specifications

  • Modality: White-light GI endoscopy (gastroscopy and colonoscopy)
  • Image size: Variable resolution, RGB, JPG
  • Content: Single endoscopy frames

Acquisition Protocol

  • Procedures: Routine clinical gastroscopies and colonoscopies, Norway
  • Annotation: Labelled by experienced gastrointestinal endoscopists

🧪 Use Cases

  • Multi-class classification of GI endoscopy images
  • Polyp detection and classification
  • Grading of ulcerative colitis and esophagitis
  • Bowel-preparation quality assessment (BBPS)
  • Anatomical landmark recognition for automatic procedure reporting
  • Representation learning, feature extraction and self-supervised pretraining for endoscopy

⚠️ Important Notes

  • No split in this release: The dataset has a single train split. Make your own stratified train/validation/test split (see Usage).
  • No patient IDs: Images are named by UUID and the release does not say which images come from the same patient or procedure, so a random split can place frames from one examination in both training and evaluation.
  • Class imbalance: Class sizes vary widely. Use weighted sampling, class balancing or class merging as needed.
  • Fine-grained grades: Neighbouring ulcerative-colitis grades (e.g., grade-1 vs grade-1-2) and Barrett's subtypes are hard to tell apart and are often merged in practice.

📚 Citation

This dataset is derived from data originally published by Simula under a CC BY 4.0 license. If you use this dataset, please acknowledge Chehab Lab and cite the original HyperKvasir dataset:

@misc{Borgli2020HyperKvasirData,
  author    = {Borgli, Hanna and Thambawita, Vajira and Smedsrud, Pia H. and Hicks, Steven and Jha, Debesh and Eskeland, Sigrun L. and Randel, Kristin Ranheim and Pogorelov, Konstantin and Lux, Mathias and Nguyen, Duc Tien Dang and Johansen, Dag and Griwodz, Carsten and Stensland, H{\aa}kon K. and Garcia-Ceja, Enrique and Schmidt, Peter T. and Hammer, Hugo L. and Riegler, Michael A. and Halvorsen, P{\aa}l and de Lange, Thomas},
  title     = {HyperKvasir [dataset]},
  year      = {2020},
  publisher = {OSF},
  doi       = {10.17605/OSF.IO/MH9SJ}
}

Additionally, cite the research paper that introduced this dataset:

@article{Borgli2020HyperKvasir,
  author  = {Borgli, Hanna and Thambawita, Vajira and Smedsrud, Pia H. and Hicks, Steven and Jha, Debesh and Eskeland, Sigrun L. and Randel, Kristin Ranheim and Pogorelov, Konstantin and Lux, Mathias and Nguyen, Duc Tien Dang and Johansen, Dag and Griwodz, Carsten and Stensland, H{\aa}kon K. and Garcia-Ceja, Enrique and Schmidt, Peter T. and Hammer, Hugo L. and Riegler, Michael A. and Halvorsen, P{\aa}l and de Lange, Thomas},
  title   = {HyperKvasir, a comprehensive multi-class image and video dataset for gastrointestinal endoscopy},
  journal = {Scientific Data},
  volume  = {7},
  pages   = {283},
  year    = {2020},
  doi     = {10.1038/s41597-020-00622-y}
}

✉️ Original Authors

Hanna Borgli, Vajira Thambawita, Pia H. Smedsrud, Steven Hicks, Debesh Jha, Sigrun L. Eskeland, Kristin Ranheim Randel, Konstantin Pogorelov, Mathias Lux, Duc Tien Dang Nguyen, Dag Johansen, Carsten Griwodz, Håkon K. Stensland, Enrique Garcia-Ceja, Peter T. Schmidt, Hugo L. Hammer, Michael A. Riegler, Pål Halvorsen, Thomas de Lange
Simula Research Laboratory, Norway, with collaborating hospitals and universities

Simula: https://datasets.simula.no/hyper-kvasir/ (original files)
OSF mirror: https://osf.io/mh9sj/

📜 License

This dataset is released under the Creative Commons Attribution 4.0 International (CC BY 4.0) license, consistent with the original HyperKvasir dataset.

You may copy, modify, distribute, and use the data for any purpose (commercial or non-commercial), provided that appropriate credit is given to Borgli et al., Simula, and the original paper.

CC BY 4.0

Chehab Lab @ 2026