--- 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.