Skip to content
ModelListedExternal
Download

Unet Residual Resnet34

A U-Net architecture for polyp segmentation from colonoscopy images, combining:

KindUNetVersionmodel

Model source

Kind
UNet
File size
253 MB
Version
vmodel
Updated
Sep 27, 2026
Downloads
18
Tasks
Image segmentation
Source
Hugging Face

Source description

UNet Residual ResNet34

A U-Net architecture for polyp segmentation from colonoscopy images, combining:

  • ResNet34 pretrained encoder (ImageNet weights, early layers frozen during training)
  • Residual blocks with Squeeze-and-Excitation (SE) attention in the decoder
  • ASPP (Atrous Spatial Pyramid Pooling) bottleneck for multi-scale context

Inspired by the ResUNet++ architecture.

Model description

The encoder is a ResNet34 backbone that extracts multi-scale features at 5 resolutions (H, H/2, H/4, H/8, H/16) with channel counts [64, 64, 128, 256, 512]. Channel adapters project backbone features to the decoder's expected dimensions before skip connections.

The bottleneck applies a ResidualSEBlock followed by ASPP (rates [1, 6, 12, 18]) and a projection convolution, giving the model a wide receptive field without losing spatial detail.

The decoder uses four ResidualSEBlock stages with transposed convolutions for upsampling and concatenated skip connections from the encoder. A final 1×1 convolution produces the binary segmentation logit map.

ComponentDetail
Input size256×256×3
Output size256×256×1 (logits)
EncoderResNet34 (pretrained, ImageNet)
BottleneckResidualSEBlock + ASPP
Decoder blocksResidualSEBlock + ConvTranspose2d
Parameters~28M

Training

Trained on the Kvasir-SEG dataset with 5× random augmentation (geometric flips/rotations + brightness/contrast/saturation jitter), giving ~5 400 training samples.

HyperparameterValue
Epochs8
Batch size128
OptimizerAdamW
Learning rate1e-3 (linear decay)
Weight decay0.01
Loss0.5 × BCE + 0.5 × Dice

Training metrics

EpochTrain lossVal lossVal DiceVal IoU
10.42810.29640.81180.6832
20.22000.47460.62930.4591
30.12490.16280.85860.7523
40.08190.15970.85560.7477
50.07350.13300.88150.7881
60.05770.12960.88730.7975
70.05020.12170.89190.8049
80.03990.11270.89910.8167

Usage

import torch
from huggingface_hub import hf_hub_download
from safetensors.torch import load_file

# These files are also available in the repository
from models.backbones import ResNet34Backbone
from models.residual_unet import ResidualUNet

# Load model
backbone = ResNet34Backbone(pretrained=False)
model = ResidualUNet(in_channels=3, num_classes=1, backbone=backbone)

weights_path = hf_hub_download(
    repo_id="RGarrido03/unet-residual-resnet34",
    filename="model.safetensors",
)
model.load_state_dict(load_file(weights_path), strict=False)
model.eval()

# Inference
from torchvision.transforms import Compose, Resize, ToTensor
from PIL import Image

transform = Compose([Resize((256, 256)), ToTensor()])
image = transform(Image.open("your_image.jpg").convert("RGB")).unsqueeze(0)

with torch.no_grad():
    logits = model(image)          # (1, 1, 256, 256)
    mask = (logits.sigmoid() > 0.5).squeeze()  # binary mask

Citation

If you use this model, please also cite the Kvasir-SEG dataset:

@inproceedings{Jha2020,
  title     = {Kvasir-{SEG}: A Segmented Polyp Dataset},
  author    = {Jha, Debesh and Smedsrud, Pia H. and Riegler, Michael A. and
               Halvorsen, P{\aa}l and de Lange, Thomas and Johansen, Dag and
               Johansen, H{\aa}vard D.},
  booktitle = {MultiMedia Modeling},
  year      = {2020},
}

Sources

1 source
Hugging FacePrimaryVersion 39e3d3877a66fef80ae13052acb9b2c8541a6a4d
huggingface.co/RGarrido03/unet-residual-resnet34/tree/39e3d3877a66fef80ae13052acb9b2c8541a6a4d

Verified Sep 27

Model artifacts

1 artifact

model.safetensors

safetensors · 253 MB · SHA-256 ed7ff4d71894…0f54 · Hugging Face

Download

Source excerpts

2 excerpts

--- license: mit tags: - pytorch - image-segmentation - unet - medical-imaging - resnet - polyp-segmentation datasets: - RGarrido03/kvasir-seg-augmented metrics: - dice - iou model-index: - name: UNet Residual ResNet34 results: - task: type: image-segmentation name: Image Segmentation dataset: name: Kvasir-SEG (augmented) type: RGarrido03/kvasir-seg-augmented metrics: - type: dice value: 0.8991 name: Dice Score - type: iou value: 0.8167 name: IoU Score --- # UNet Residual ResNet34 A U-Net architecture for polyp segmentation from colonoscopy images, combining: - **ResNet34** pretrained encoder (ImageNet weights, early layers frozen during training) - **Residual blocks** with Squeeze-and-Excitation (SE) attention in the decoder - **ASPP** (Atrous Spatial Pyramid Pooling) bottleneck for multi-scale context Inspired by the [ResUNet++](https://arxiv.org/abs/1911.07067) architecture. ## Model description The encoder is a ResNet34 backbone that extracts multi-scale features at 5 resolutions (H, H/2, H/4, H/8, H/16) with channel counts [64, 64, 128, 256, 512]. Channel adapters project backbone features to the decoder's expected dimensions before skip connections. The bottleneck applies a `ResidualSEBlock` followed by ASPP (rates [1, 6, 12, 18]) and a projection convolution, giving the model a wide receptive field without losing spatial detail. The decoder uses four `ResidualSEBlock` stages with transposed convolutions for upsampling and concatenated skip connections from the encoder. A final 1×1 convolution produces the binary segmentation logit map. | Component | Detail | |------------------|--------| | Input size | 256×256×3 | | Output size | 256×256×1 (logits) | | Encoder | ResNet34 (pretrained, ImageNet) | | Bottleneck | ResidualSEBlock + ASPP | | Decoder blocks | ResidualSEBlock + ConvTranspose2d | | Parameters | ~28M | ## Training Trained on the [Kvasir-SEG](https://datasets.simula.no/kvasir-seg/) dataset with 5× random augmentation (geometric flips/rotations + brightness/contrast/saturation jitter), giving ~5 400 training samples. | Hyperparameter | Value | |-------------------------|-------| | Epochs | 8 | | Batch size | 128 | | Optimizer | AdamW | | Learning rate | 1e-3 (linear decay) | | Weight decay | 0.01 | | Loss | 0.5 × BCE + 0.5 × Dice | ### Training metrics | Epoch | Train loss | Val loss | Val Dice | Val IoU | |-------...

Source context: 18 downloads · 0 likes · Pipeline image-segmentation · Repo RGarrido03/unet-residual-resnet34