Medical AI · Applied case studies: diabetes & metabolic health · Lesson 4 of 5
Diabetic foot-ulcer image classification
Reviewed by Dr. Ram Kumar G, MBBS, MD (Internal Medicine), MPH (USA), on · Last updated
- Intermediate
- Clinical focus
- About 30 minutes
- Includes exercise
Before this lesson: CNNs for chest X-ray and retinal images, Bias and fairness
In short
AI models can detect diabetic foot ulcers in photographs and measure their size, which could support remote monitoring and earlier referral. But image models trained mostly on lighter skin can perform worse on darker skin, as dermatology AI has shown, so performance must be reported by skin tone. A practical use of wound measurement is tracking healing: a reduction in ulcer area of about half within four weeks is widely used as a sign of progress, and slower healing should prompt review of treatment.
You will learn to
- Describe how AI is being applied to diabetic foot-ulcer photographs
- Show how unrepresentative training data creates a skin-tone performance gap
- Compare two mitigations: more diverse data and image normalisation
- Use wound-area measurements to flag ulcers that are not healing as expected
AI and diabetic foot ulcers
Diabetic foot ulcers are a leading cause of amputation, and early recognition and regular review improve outcomes. Research has used deep learning to detect and classify ulcers in photographs, including in the Diabetic Foot Ulcer Grand Challenges (Yap et al., 2021), and to segment wounds to measure their area. International guidance on diabetes-related foot disease is maintained by the IWGDF.
Photographs vary with lighting, camera, distance, angle and skin tone, all of which affect models. A study of dermatology AI on a diverse, curated image set found performance dropped on darker skin tones (Daneshjou et al., 2022).
A skin-tone performance gap
The simulation makes 28 × 28 'foot photos' whose overall brightness depends on skin tone, with a darker textured patch for an ulcer. The training set contains only 5% darker-skin photos; the test set is balanced.
import numpy as np
import torch
from torch import nn
def wound_photos(n, seed, dark_share):
"""Synthetic 28x28 'foot photos'. Skin tone sets the overall brightness; an ulcer is a darker,
textured patch. dark_share: fraction of photos with darker skin tones."""
rng = np.random.default_rng(seed)
yy, xx = np.mgrid[:28, :28]
dark = rng.random(n) < dark_share
tone = np.where(dark, rng.uniform(-1.6, -0.8, n), rng.uniform(0.8, 1.6, n))
images = tone[:, None, None] + rng.normal(0, 0.6, (n, 28, 28))
labels = rng.integers(0, 2, n)
for i in np.where(labels == 1)[0]:
cy, cx, r = rng.integers(7, 21), rng.integers(7, 21), rng.uniform(3, 5)
patch = (yy - cy) ** 2 + (xx - cx) ** 2 < r ** 2
images[i][patch] -= 1.2 + rng.normal(0, 0.4, patch.sum())
to_t = lambda a: torch.tensor(a, dtype=torch.float32)
return to_t(images).unsqueeze(1), torch.tensor(labels), dark
class SmallCNN(nn.Module):
def __init__(self):
super().__init__()
self.net = nn.Sequential(
nn.Conv2d(1, 8, 3, padding=1), nn.ReLU(), nn.MaxPool2d(2),
nn.Conv2d(8, 16, 3, padding=1), nn.ReLU(), nn.MaxPool2d(2),
nn.Flatten(), nn.Linear(16 * 7 * 7, 2))
def forward(self, x):
return self.net(x)
def train(X, y, epochs=8):
torch.manual_seed(0)
model = SmallCNN()
opt = torch.optim.Adam(model.parameters(), lr=1e-3)
for _ in range(epochs):
for idx in torch.randperm(len(X)).split(64):
opt.zero_grad()
nn.functional.cross_entropy(model(X[idx]), y[idx]).backward()
opt.step()
return model
def accuracy_by_tone(model, X, y, dark):
with torch.no_grad():
correct = (model(X).argmax(1) == y).numpy()
return correct[~dark].mean(), correct[dark].mean()
X_tr, y_tr, dark_tr = wound_photos(4000, seed=1, dark_share=0.05) # 95% lighter skin in training
X_te, y_te, dark_te = wound_photos(2000, seed=2, dark_share=0.5) # balanced test set
model = train(X_tr, y_tr)
light_acc, dark_acc = accuracy_by_tone(model, X_te, y_te, dark_te)
print(f"Trained on 5% darker skin: lighter skin {light_acc:.1%}, darker skin {dark_acc:.1%}")
# Trained on 5% darker skin: lighter skin 99.7%, darker skin 71.6%- Overall accuracy on a test set like the training data would look excellent. Split by skin tone, the model is far less accurate for darker skin: it learned cues tied to the lighter images it mostly saw.
Two mitigations
X_bal, y_bal, _ = wound_photos(4000, seed=3, dark_share=0.5) # diverse training set
light_acc, dark_acc = accuracy_by_tone(train(X_bal, y_bal), X_te, y_te, dark_te)
print(f"Trained on 50% darker skin: lighter skin {light_acc:.1%}, darker skin {dark_acc:.1%}")
def normalise(X): # per-image standardisation
return (X - X.mean(dim=(2, 3), keepdim=True)) / X.std(dim=(2, 3), keepdim=True)
light_acc, dark_acc = accuracy_by_tone(train(normalise(X_tr), y_tr), normalise(X_te), y_te, dark_te)
print(f"5% darker skin, normalised: lighter skin {light_acc:.1%}, darker skin {dark_acc:.1%}")
# Trained on 50% darker skin: lighter skin 99.2%, darker skin 97.6%
# 5% darker skin, normalised: lighter skin 99.9%, darker skin 100.0%- Training on diverse data closes most of the gap, which is why datasets should be documented and checked for representation, as the STANDING Together recommendations advise.
- Normalising each image removes the gap completely here, but only because this simulation differs by brightness alone. Real differences in skin tone also affect colour, contrast and how redness, swelling and wound edges appear, so normalisation is not a substitute for diverse data and subgroup testing.
Tracking healing with wound area
Segmentation models can measure ulcer area from photographs taken with a reference marker. A reduction in area of about half over four weeks is widely used as an early sign that an ulcer is on track to heal (Sheehan et al., 2003); slower progress should prompt review of offloading, infection, blood supply and other treatment.
# Wound area (cm2) measured weekly from segmented photos for three synthetic patients
areas = {"patient A": [4.0, 3.1, 2.4, 1.7, 1.1], "patient B": [3.5, 3.4, 3.3, 3.0, 2.9],
"patient C": [6.2, 5.6, 4.0, 3.5, 3.0]}
for name, a in areas.items():
reduction = 1 - a[4] / a[0] # percent area reduction after 4 weeks
flag = "on track" if reduction >= 0.5 else "REVIEW: under 50% reduction at 4 weeks"
print(f"{name}: {reduction:.0%} smaller after 4 weeks -> {flag}")
# patient A: 72% smaller after 4 weeks -> on track
# patient B: 17% smaller after 4 weeks -> REVIEW: under 50% reduction at 4 weeks
# patient C: 52% smaller after 4 weeks -> on track- Patient B's ulcer is shrinking too slowly and is flagged for clinical review. The flag prompts a clinician; it does not decide treatment.
- Measurements from photographs are only as good as the images: angle, distance and lighting must be controlled, and the measurement method validated against manual measurement.
Teaching models, not clinical tools
- Data in these case studies are simulated, and the models are fitted to them for learning. They must not be used to make decisions about real patients.
- Validated tools exist for several of these problems; any tool used in care must be validated for its population and meet regulatory requirements.
Exercise
Build and audit a foot-ulcer image classifier across skin tones, and design a healing-monitoring rule.
Data: Synthetic wound photos in the notebook; optional DFUC datasets under their data-use terms (Generated in the notebook; external datasets under their own licences)
- Reproduce the skin-tone experiment and plot accuracy against the share of darker-skin photos in training (5%, 15%, 30%, 50%).
- Make the ulcer contrast lower on darker skin, a more realistic difference, and check whether normalisation still closes the gap.
- Report sensitivity and specificity by skin tone with confidence intervals, and decide what minimum performance you would require in each group.
- Extend the healing rule to flag ulcers that grow between visits, and write the message a clinician would see.
Open the notebook in ColabView on GitHubWorked solution coming soon
Key takeaways
- Foot-ulcer AI can detect and measure wounds in photographs, under controlled imaging conditions.
- Unrepresentative training data creates performance gaps by skin tone; report results by group.
- Diverse data is the main fix; normalisation helps only with simple differences.
- Area reduction of about half in four weeks is a common progress marker; slower healing needs review.
Terms used: Convolutional neural network (CNN), Label bias, Image segmentation
Related: Diabetic foot ulcers, Diabetic foot ulcer wound care, Bias and fairness
FAQ
Can AI detect diabetic foot ulcers from photos?
Research systems can detect and measure ulcers in photographs, but performance depends on image quality and on the diversity of the training data. Clinical use needs validation in the target population.
Why does skin tone matter for wound AI?
Models learn from their training images. If darker skin tones are under-represented, models may perform worse for those patients, as shown in dermatology AI.
What is a good sign that a foot ulcer is healing?
A reduction in wound area of roughly half within four weeks is widely used as an early sign of progress. Slower healing should prompt a review of treatment by the care team.
Can patients photograph their own ulcers for AI review?
Remote photography is being studied, but lighting, distance and angle vary at home. Any such service needs validated imaging instructions, measurement checks and clear routes to urgent care.
Does AI replace foot examinations?
No. Examination of sensation, blood supply, infection and footwear remains essential; image tools may support monitoring between visits.
Sources
- Yap MH, et al. Deep learning in diabetic foot ulcers detection: a comprehensive evaluation. Computers in Biology and Medicine 2021;135:104596. doi:10.1016/j.compbiomed.2021.104596
- Daneshjou R, et al. Disparities in dermatology AI performance on a diverse, curated clinical image set. Science Advances 2022;8(31):eabq6147. doi:10.1126/sciadv.abq6147
- Sheehan P, et al. Percent change in wound area of diabetic foot ulcers over a 4-week period is a robust predictor of complete healing in a 12-week prospective trial. Diabetes Care 2003;26(6):1879–1882. doi:10.2337/diacare.26.6.1879
- Schaper NC, et al. Practical guidelines on the prevention and management of diabetes-related foot disease (IWGDF 2023 update). Diabetes Metab Res Rev 2024;40(3):e3657. doi:10.1002/dmrr.3657
- Alderman JE, et al. Tackling algorithmic bias and promoting transparency in health datasets: the STANDING Together consensus recommendations. Lancet Digital Health 2025;7(1):e64–e88. doi:10.1016/S2589-7500(24)00224-3
Educational content only. This material teaches methods; it is not clinical advice. Code, models and examples here are not validated medical devices and must not be used to make decisions about real patients without proper clinical validation, governance and any required regulatory approval. Examples use synthetic or openly licensed de-identified data only. Never paste identifiable patient information into public AI tools. Mentions of models, tools or vendors are for identification, not endorsement.