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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: cc-by-nc-4.0
|
| 3 |
+
library_name: pytorch
|
| 4 |
+
pipeline_tag: image-segmentation
|
| 5 |
+
tags:
|
| 6 |
+
- pytorch
|
| 7 |
+
- medical-imaging
|
| 8 |
+
- image-segmentation
|
| 9 |
+
- semantic-segmentation
|
| 10 |
+
- wound-segmentation
|
| 11 |
+
- diabetic-foot-ulcer
|
| 12 |
+
- dfu
|
| 13 |
+
- unet
|
| 14 |
+
- unet-plus-plus
|
| 15 |
+
- efficientnet
|
| 16 |
+
- deep-learning
|
| 17 |
+
- computer-vision
|
| 18 |
+
- healthcare
|
| 19 |
+
- medical-ai
|
| 20 |
+
- fuseg
|
| 21 |
+
- miccai
|
| 22 |
+
datasets:
|
| 23 |
+
- custom
|
| 24 |
+
metrics:
|
| 25 |
+
- iou
|
| 26 |
+
- dice
|
| 27 |
+
---
|
| 28 |
+
|
| 29 |
+
# DiaFoot.AI 🦶
|
| 30 |
+
|
| 31 |
+
**State-of-the-Art Diabetic Foot Ulcer Segmentation**
|
| 32 |
+
|
| 33 |
+
[](https://github.com/Ruthvik-Bandari/DiaFoot.AI)
|
| 34 |
+
[](LICENSE)
|
| 35 |
+
|
| 36 |
+
## Model Description
|
| 37 |
+
|
| 38 |
+
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.
|
| 39 |
+
|
| 40 |
+
### Performance
|
| 41 |
+
|
| 42 |
+
| Metric | DiaFoot.AI | FUSeg 2021 Winner | Improvement |
|
| 43 |
+
|--------|-----------|-------------------|-------------|
|
| 44 |
+
| **IoU** | **85.58%** | 80.30% | **+5.28%** |
|
| 45 |
+
| **Dice** | **92.23%** | 89.23% | **+3.00%** |
|
| 46 |
+
|
| 47 |
+
### Cross-Validation Results
|
| 48 |
+
|
| 49 |
+
| Fold | IoU | Dice |
|
| 50 |
+
|------|-----|------|
|
| 51 |
+
| Fold 1 | 83.22% | 90.84% |
|
| 52 |
+
| Fold 2 | 85.81% | 92.36% |
|
| 53 |
+
| Fold 3 | 82.16% | 90.20% |
|
| 54 |
+
| Fold 4 | 85.00% | 91.89% |
|
| 55 |
+
| Fold 5 | 84.44% | 91.56% |
|
| 56 |
+
| **Mean** | **84.13% ± 1.30%** | **91.37% ± 0.77%** |
|
| 57 |
+
|
| 58 |
+
## Usage
|
| 59 |
+
|
| 60 |
+
### Installation
|
| 61 |
+
```bash
|
| 62 |
+
pip install torch segmentation-models-pytorch albumentations huggingface_hub
|
| 63 |
+
```
|
| 64 |
+
|
| 65 |
+
### Download and Load Model
|
| 66 |
+
```python
|
| 67 |
+
from huggingface_hub import hf_hub_download
|
| 68 |
+
import torch
|
| 69 |
+
import segmentation_models_pytorch as smp
|
| 70 |
+
|
| 71 |
+
# Download model
|
| 72 |
+
model_path = hf_hub_download("RuthvikBandari/DiaFootAI", "best_model.pt")
|
| 73 |
+
|
| 74 |
+
# Create model architecture
|
| 75 |
+
model = smp.UnetPlusPlus(
|
| 76 |
+
encoder_name="efficientnet-b4",
|
| 77 |
+
encoder_weights=None,
|
| 78 |
+
in_channels=3,
|
| 79 |
+
classes=1
|
| 80 |
+
)
|
| 81 |
+
|
| 82 |
+
# Load weights
|
| 83 |
+
checkpoint = torch.load(model_path, map_location="cpu", weights_only=False)
|
| 84 |
+
state_dict = checkpoint["model_state_dict"]
|
| 85 |
+
# Remove 'model.' prefix if present
|
| 86 |
+
state_dict = {k.replace("model.", "", 1): v for k, v in state_dict.items()}
|
| 87 |
+
model.load_state_dict(state_dict)
|
| 88 |
+
model.eval()
|
| 89 |
+
```
|
| 90 |
+
|
| 91 |
+
### Inference
|
| 92 |
+
```python
|
| 93 |
+
import cv2
|
| 94 |
+
import numpy as np
|
| 95 |
+
import albumentations as A
|
| 96 |
+
from albumentations.pytorch import ToTensorV2
|
| 97 |
+
|
| 98 |
+
# Preprocessing
|
| 99 |
+
transform = A.Compose([
|
| 100 |
+
A.LongestMaxSize(max_size=512),
|
| 101 |
+
A.PadIfNeeded(min_height=512, min_width=512, border_mode=cv2.BORDER_CONSTANT),
|
| 102 |
+
A.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
|
| 103 |
+
ToTensorV2()
|
| 104 |
+
])
|
| 105 |
+
|
| 106 |
+
# Load and preprocess image
|
| 107 |
+
image = cv2.imread("wound_image.jpg")
|
| 108 |
+
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
|
| 109 |
+
transformed = transform(image=image)
|
| 110 |
+
input_tensor = transformed["image"].unsqueeze(0)
|
| 111 |
+
|
| 112 |
+
# Predict
|
| 113 |
+
with torch.no_grad():
|
| 114 |
+
output = model(input_tensor)
|
| 115 |
+
mask = torch.sigmoid(output).squeeze().numpy()
|
| 116 |
+
binary_mask = (mask > 0.5).astype(np.uint8)
|
| 117 |
+
```
|
| 118 |
+
|
| 119 |
+
## Model Architecture
|
| 120 |
+
|
| 121 |
+
- **Architecture:** U-Net++
|
| 122 |
+
- **Encoder:** EfficientNet-B4 (ImageNet pretrained)
|
| 123 |
+
- **Input Size:** 512 × 512 × 3
|
| 124 |
+
- **Output:** Single channel probability map
|
| 125 |
+
- **Parameters:** 20.8M
|
| 126 |
+
|
| 127 |
+
## Training Details
|
| 128 |
+
|
| 129 |
+
- **Loss:** Focal Tversky + BCE with warmup
|
| 130 |
+
- **Optimizer:** AdamW
|
| 131 |
+
- **Learning Rate:** 3e-4 (decoder), 1e-5 (encoder)
|
| 132 |
+
- **Batch Size:** 8
|
| 133 |
+
- **Epochs:** 100
|
| 134 |
+
- **Augmentation:** Heavy (flips, rotations, color jitter, elastic transform)
|
| 135 |
+
- **Test Time Augmentation:** 8 transforms
|
| 136 |
+
|
| 137 |
+
## Dataset
|
| 138 |
+
|
| 139 |
+
Trained on [FUSeg 2021 Challenge Dataset](https://github.com/uwm-bigdata/wound-segmentation):
|
| 140 |
+
- 810 training images
|
| 141 |
+
- 200 validation images
|
| 142 |
+
- Pixel-wise annotations by wound care experts
|
| 143 |
+
|
| 144 |
+
## Citation
|
| 145 |
+
```bibtex
|
| 146 |
+
@software{bandari2025diafootai,
|
| 147 |
+
author = {Bandari, Ruthvik},
|
| 148 |
+
title = {DiaFoot.AI: Deep Learning for Diabetic Foot Ulcer Segmentation},
|
| 149 |
+
year = {2025},
|
| 150 |
+
publisher = {GitHub},
|
| 151 |
+
url = {https://github.com/Ruthvik-Bandari/DiaFoot.AI},
|
| 152 |
+
note = {Achieves 85.58% IoU, surpassing MICCAI FUSeg 2021 winner by +5.28%}
|
| 153 |
+
}
|
| 154 |
+
```
|
| 155 |
+
|
| 156 |
+
## License
|
| 157 |
+
|
| 158 |
+
**CC BY-NC 4.0** - You must give appropriate credit and may not use for commercial purposes without permission.
|
| 159 |
+
|
| 160 |
+
## Author
|
| 161 |
+
|
| 162 |
+
**Ruthvik Bandari**
|
| 163 |
+
Master's in Applied Artificial Intelligence
|
| 164 |
+
Northeastern University
|
| 165 |
+
|
| 166 |
+
- GitHub: [@Ruthvik-Bandari](https://github.com/Ruthvik-Bandari)
|
| 167 |
+
- LinkedIn: [Ruthvik Bandari](https://linkedin.com/in/ruthvik-bandari)
|
| 168 |
+
|
| 169 |
+
## Disclaimer
|
| 170 |
+
|
| 171 |
+
This model is intended for research purposes only. Not for clinical diagnosis without professional medical oversight.
|