Skip to content
ModelListedExternal
Download

Kvasir Unet Segmentation

This repository contains a U-Net model trained for gastrointestinal polyp segmentation on the Angelou0516/kvasir-seg dataset.

KindOtherVersionRevision 4494a7a

Model source

Kind
Other
File size
118 MB
Version
vRevision 4494a7a
Updated
Sep 27, 2026
Downloads
0
Tasks
Image segmentation
Source
Hugging Face

Source description

Kvasir-SEG U-Net

This repository contains a U-Net model trained for gastrointestinal polyp segmentation on the Angelou0516/kvasir-seg dataset.

Architecture

  • U-Net implemented in PyTorch
  • Encoder with convolution + max-pooling
  • Bottleneck
  • Decoder with transposed convolutions
  • Skip connections
  • Final 1x1 convolution producing a single-channel mask

Input shape:

  • 3 x 256 x 256

Output shape:

  • 1 x 256 x 256

Loss function rationale

Medical image segmentation suffers from severe class imbalance because the foreground object occupies a small region of the image while the background dominates most pixels.

To address this, the model was trained with a combined loss:

  • BCEWithLogitsLoss
  • Dice Loss

Final loss:

  • 0.5 * BCEWithLogitsLoss + 0.5 * DiceLoss

Preprocessing

  • Resize to 256 x 256
  • RGB normalization to [-1, 1]
  • Masks resized with nearest-neighbor interpolation
  • Masks binarized to {0, 1}

Training

  • Hugging Face Trainer
  • Epochs: 20
  • Learning rate: 1e-3
  • Batch size: 2

Results

  • Test Dice: 0.7096
  • Test IoU: 0.6066

Sources

1 source
Hugging FacePrimaryVersion 4494a7a0acc11771ff5f6b207d9fe2b36eba2c71
huggingface.co/x4n4/kvasir-unet-segmentation/tree/4494a7a0acc11771ff5f6b207d9fe2b36eba2c71

Verified Sep 27

Model artifacts

1 artifact

model.safetensors

safetensors · 118 MB · SHA-256 3be5727d4e94…1e72 · Hugging Face

Download

Source excerpts

2 excerpts

--- language: en library_name: pytorch tags: - image-segmentation - medical-imaging - unet - kvasir datasets: - Angelou0516/kvasir-seg metrics: - dice - iou --- # Kvasir-SEG U-Net This repository contains a U-Net model trained for gastrointestinal polyp segmentation on the `Angelou0516/kvasir-seg` dataset. ## Architecture - U-Net implemented in PyTorch - Encoder with convolution + max-pooling - Bottleneck - Decoder with transposed convolutions - Skip connections - Final 1x1 convolution producing a single-channel mask Input shape: - `3 x 256 x 256` Output shape: - `1 x 256 x 256` ## Loss function rationale Medical image segmentation suffers from severe class imbalance because the foreground object occupies a small region of the image while the background dominates most pixels. To address this, the model was trained with a combined loss: - BCEWithLogitsLoss - Dice Loss Final loss: - `0.5 * BCEWithLogitsLoss + 0.5 * DiceLoss` ## Preprocessing - Resize to `256 x 256` - RGB normalization to `[-1, 1]` - Masks resized with nearest-neighbor interpolation - Masks binarized to `{0, 1}` ## Training - Hugging Face Trainer - Epochs: 20 - Learning rate: 1e-3 - Batch size: 2 ## Results - Test Dice: 0.7096 - Test IoU: 0.6066

Source context: 0 downloads · 0 likes · Pipeline image-segmentation · Library pytorch · Repo x4n4/kvasir-unet-segmentation