File size: 1,715 Bytes
21598fa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
---
license: apache-2.0
tags:
  - image-segmentation
  - medical-imaging
  - polyp-segmentation
  - pytorch
  - malunet
datasets:
  - cvc-clinicdb
library_name: pytorch
pipeline_tag: image-segmentation
---

# MALUNet · CVC-ClinicDB (Polyp Segmentation)

Lightweight U-shape segmentation network adapted from
[jcruan519/MALUNet](https://github.com/jcruan519/MALUNet) and trained on
[CVC-ClinicDB](https://www.kaggle.com/datasets/balraj98/cvcclinicdb) for
binary polyp segmentation in colonoscopy frames.

## Model

- Architecture: MALUNet (DGA + IEA + CAB + SAB)
- Channels: `[8, 16, 24, 32, 48, 64]`, `split_att="fc"`, `bridge=True`
- Input: RGB, 256×256
- Output: single-channel sigmoid mask (1 = polyp)
- Parameters: ~0.18 M

## Training

- Dataset: CVC-ClinicDB (612 paired image/mask frames)
- Split: 80% train / 20% val (seeded by filename, `seed=42`)
- Loss: BCE + Dice
- Optimizer: AdamW, `lr=1e-3`, `weight_decay=1e-2`
- Schedule: CosineAnnealingLR, `T_max=50`, `eta_min=1e-5`
- Augmentations: random h/v flip, random rotation
- Epochs: 150

## Usage

```python
import torch
from huggingface_hub import hf_hub_download
from infer import load_model, predict_mask  # infer.py from this repo
from PIL import Image

model = load_model("YOUR_USERNAME/malunet-cvc")
mask = predict_mask(model, Image.open("polyp.png"))
Image.fromarray(mask).save("mask.png")
```

`infer.py` and `models/malunet.py` are bundled in this repo so you can
also clone it and run inference without the original training code.

## Limitations

- Trained on CVC-ClinicDB only (612 frames, single source). Generalization
  to other colonoscopy systems / patient populations is unverified.
- Not a medical device. Research / demo use only.