File size: 4,529 Bytes
5f7682e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
939ac12
5f7682e
 
 
 
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
---
license: cc-by-nc-4.0
library_name: pytorch
pipeline_tag: image-segmentation
tags:
  - pytorch
  - medical-imaging
  - image-segmentation
  - semantic-segmentation
  - wound-segmentation
  - diabetic-foot-ulcer
  - dfu
  - unet
  - unet-plus-plus
  - efficientnet
  - deep-learning
  - computer-vision
  - healthcare
  - medical-ai
  - fuseg
  - miccai
datasets:
  - custom
metrics:
  - iou
  - dice
---

# DiaFoot.AI 🦶

**State-of-the-Art Diabetic Foot Ulcer Segmentation**

[![GitHub](https://img.shields.io/badge/GitHub-Repository-blue)](https://github.com/Ruthvik-Bandari/DiaFoot.AI)
[![License](https://img.shields.io/badge/License-CC%20BY--NC%204.0-lightgrey.svg)](LICENSE)

## Model Description

DiaFoot.AI is a deep learning model for automatic segmentation of diabetic foot ulcers from clinical images. It uses a U-Net++ architecture with an EfficientNet-B4 encoder pretrained on ImageNet.

### Performance

| Metric | DiaFoot.AI | FUSeg 2021 Winner | Improvement |
|--------|-----------|-------------------|-------------|
| **IoU** | **85.58%** | 80.30% | **+5.28%** |
| **Dice** | **92.23%** | 89.23% | **+3.00%** |

### Cross-Validation Results

| Fold | IoU | Dice |
|------|-----|------|
| Fold 1 | 83.22% | 90.84% |
| Fold 2 | 85.81% | 92.36% |
| Fold 3 | 82.16% | 90.20% |
| Fold 4 | 85.00% | 91.89% |
| Fold 5 | 84.44% | 91.56% |
| **Mean** | **84.13% ± 1.30%** | **91.37% ± 0.77%** |

## Usage

### Installation
```bash
pip install torch segmentation-models-pytorch albumentations huggingface_hub
```

### Download and Load Model
```python
from huggingface_hub import hf_hub_download
import torch
import segmentation_models_pytorch as smp

# Download model
model_path = hf_hub_download("RuthvikBandari/DiaFootAI", "best_model.pt")

# Create model architecture
model = smp.UnetPlusPlus(
    encoder_name="efficientnet-b4",
    encoder_weights=None,
    in_channels=3,
    classes=1
)

# Load weights
checkpoint = torch.load(model_path, map_location="cpu", weights_only=False)
state_dict = checkpoint["model_state_dict"]
# Remove 'model.' prefix if present
state_dict = {k.replace("model.", "", 1): v for k, v in state_dict.items()}
model.load_state_dict(state_dict)
model.eval()
```

### Inference
```python
import cv2
import numpy as np
import albumentations as A
from albumentations.pytorch import ToTensorV2

# Preprocessing
transform = A.Compose([
    A.LongestMaxSize(max_size=512),
    A.PadIfNeeded(min_height=512, min_width=512, border_mode=cv2.BORDER_CONSTANT),
    A.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
    ToTensorV2()
])

# Load and preprocess image
image = cv2.imread("wound_image.jpg")
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
transformed = transform(image=image)
input_tensor = transformed["image"].unsqueeze(0)

# Predict
with torch.no_grad():
    output = model(input_tensor)
    mask = torch.sigmoid(output).squeeze().numpy()
    binary_mask = (mask > 0.5).astype(np.uint8)
```

## Model Architecture

- **Architecture:** U-Net++
- **Encoder:** EfficientNet-B4 (ImageNet pretrained)
- **Input Size:** 512 × 512 × 3
- **Output:** Single channel probability map
- **Parameters:** 20.8M

## Training Details

- **Loss:** Focal Tversky + BCE with warmup
- **Optimizer:** AdamW
- **Learning Rate:** 3e-4 (decoder), 1e-5 (encoder)
- **Batch Size:** 8
- **Epochs:** 100
- **Augmentation:** Heavy (flips, rotations, color jitter, elastic transform)
- **Test Time Augmentation:** 8 transforms

## Dataset

Trained on [FUSeg 2021 Challenge Dataset](https://github.com/uwm-bigdata/wound-segmentation):
- 810 training images
- 200 validation images
- Pixel-wise annotations by wound care experts

## Citation
```bibtex
@software{bandari2025diafootai,
  author = {Bandari, Ruthvik},
  title = {DiaFoot.AI: Deep Learning for Diabetic Foot Ulcer Segmentation},
  year = {2025},
  publisher = {GitHub},
  url = {https://github.com/Ruthvik-Bandari/DiaFoot.AI},
  note = {Achieves 85.58% IoU, surpassing MICCAI FUSeg 2021 winner by +5.28%}
}
```

## License

**CC BY-NC 4.0** - You must give appropriate credit and may not use for commercial purposes without permission.

## Author

**Ruthvik Bandari**  
Master's in Applied Artificial Intelligence  
Northeastern University

- GitHub: [@Ruthvik-Bandari](https://github.com/Ruthvik-Bandari)
- LinkedIn: [Ruthvik Bandari](https://www.linkedin.com/in/ruthvik-nath-bandari-908b00247/)

## Disclaimer

This model is intended for research purposes only. Not for clinical diagnosis without professional medical oversight.