Aller au contenu
ModelPrésentéExterne
Browse files

Kvasir Polyp Segmentation

Two TensorFlow/Keras models for gastrointestinal polyp segmentation on endoscopy images, trained on the Kvasir-SEG dataset augmented with normal (no-polyp) images from Kvasir v2.

TypeUNetVersionDeeplabv3plus bestCClasse

Source du modèle

Type
UNet
Taille du fichier
38,7–356 MB
Version
vDeeplabv3plus best
Mis à jour
1 nov. 2026
Source
Hugging Face

Description de la source

Kvasir Polyp Segmentation (U-Net & DeepLabV3+)

Two TensorFlow/Keras models for gastrointestinal polyp segmentation on endoscopy images, trained on the Kvasir-SEG dataset augmented with normal (no-polyp) images from Kvasir v2.

Models

FileArchitectureBackboneSize
unet_best.h5U-Netfrom scratch~373 MB
deeplabv3plus_best.h5DeepLabV3+EfficientNet-B0 (ImageNet)~40 MB

Both are saved as full Keras models (architecture + weights) in legacy HDF5 format.

Intended use

  • Input: RGB image resized to 256x256, pixel values normalized to [0, 1].
  • Output: single-channel sigmoid mask of shape (256, 256, 1). Threshold at 0.5 to obtain a binary polyp mask.

Training data

  • Positives: Kvasir-SEG — 1,000 polyp images with manually annotated segmentation masks.
  • Negatives: ~500 normal images from Kvasir v2 (normal-cecum, normal-pylorus, normal-z-line), paired with all-zero masks so the model learns that "no polyp" is a valid output and avoids false positives on healthy tissue.

Training setup

  • Loss: Dice + Binary Cross-Entropy (BCE). The BCE term keeps gradients well-behaved on empty (normal) masks, where pure Dice is unstable.
  • Optimizer: Adam, learning rate 1e-4.
  • Batch size: 8. Epochs: 15 (with ReduceLROnPlateau and EarlyStopping).
  • Metrics: Dice coefficient, IoU (on polyp images); sensitivity / specificity / false-positive rate (across polyp vs. normal images).

How to load

These models use custom loss/metric functions. For inference only, skip them with compile=False:

from tensorflow.keras.models import load_model
from huggingface_hub import hf_hub_download

path = hf_hub_download("bekmon/kvasir-polyp-segmentation", "unet_best.h5")
model = load_model(path, compile=False)

# preprocess: RGB -> 256x256 -> /255.0, shape (1, 256, 256, 3)
pred = model.predict(image_batch)        # (1, 256, 256, 1), values in [0, 1]
mask = (pred > 0.5).astype("float32")    # binary polyp mask

To resume training (or use the custom metrics), pass custom_objects with dice_bce_loss, dice_loss, bce_loss, dice_coef, and iou_coef.

Limitations

  • Trained on single-center data (Kvasir / Bærum Hospital); may not generalize to other scopes or populations.
  • Positives and negatives come from related but distinct Kvasir collections, so some dataset-bias ("shortcut learning") risk remains.
  • Not a medical device. For research and educational use only.

Sources

1 source
Hugging FacePrincipalVersion 91d67f961358750523173f63605c4efaa863137f
huggingface.co/bekmon/kvasir-polyp-segmentation/tree/91d67f961358750523173f63605c4efaa863137f

Vérifié 1 nov.

Download files

Artefacts du modèle

2 artefacts

deeplabv3plus_best.h5

h5 · 38,7 MB · SHA-256 5c6b53d9bbdf…5fed · Hugging Face

Download file

unet_best.h5

h5 · 356 MB · SHA-256 e571d29f27ec…9301 · Hugging Face

Download file

Extraits de sources

2 extraits

--- license: mit tags: - image-segmentation - medical-imaging - polyp-segmentation - gastrointestinal - tensorflow - keras - unet - deeplabv3plus library_name: keras pipeline_tag: image-segmentation --- # Kvasir Polyp Segmentation (U-Net & DeepLabV3+) Two TensorFlow/Keras models for **gastrointestinal polyp segmentation** on endoscopy images, trained on the [Kvasir-SEG](https://huggingface.co/datasets/kowndinya23/Kvasir-SEG) dataset augmented with normal (no-polyp) images from Kvasir v2. ## Models | File | Architecture | Backbone | Size | |------|--------------|----------|------| | `unet_best.h5` | U-Net | from scratch | ~373 MB | | `deeplabv3plus_best.h5` | DeepLabV3+ | EfficientNet-B0 (ImageNet) | ~40 MB | Both are saved as **full Keras models** (architecture + weights) in legacy HDF5 format. ## Intended use - **Input:** RGB image resized to **256x256**, pixel values normalized to **[0, 1]**. - **Output:** single-channel **sigmoid** mask of shape `(256, 256, 1)`. Threshold at **0.5** to obtain a binary polyp mask. ## Training data - **Positives:** Kvasir-SEG — 1,000 polyp images with manually annotated segmentation masks. - **Negatives:** ~500 normal images from Kvasir v2 (`normal-cecum`, `normal-pylorus`, `normal-z-line`), paired with all-zero masks so the model learns that "no polyp" is a valid output and avoids false positives on healthy tissue. ## Training setup - **Loss:** Dice + Binary Cross-Entropy (BCE). The BCE term keeps gradients well-behaved on empty (normal) masks, where pure Dice is unstable. - **Optimizer:** Adam, learning rate `1e-4`. - **Batch size:** 8. **Epochs:** 15 (with `ReduceLROnPlateau` and `EarlyStopping`). - **Metrics:** Dice coefficient, IoU (on polyp images); sensitivity / specificity / false-positive rate (across polyp vs. normal images). ## How to load These models use custom loss/metric functions. For **inference only**, skip them with `compile=False`: ```python from tensorflow.keras.models import load_model from huggingface_hub import hf_hub_download path = hf_hub_download("bekmon/kvasir-polyp-segmentation", "unet_best.h5") model = load_model(path, compile=False) # preprocess: RGB -> 256x256 -> /255.0, shape (1, 256, 256, 3) pred = model.predict(image_batch) # (1, 256, 256, 1), values in [0, 1] mask = (pred > 0.5).astype("float32") # binary polyp mask ``` To resume training (or use the custom met...

Source context: 0 downloads · 0 likes · Pipeline image-segmentation · Library keras · Repo bekmon/kvasir-polyp-segmentation