Downloads · 30 days
9
18% of all-time downloads
cesaraha/ham10000-multimodal-skin-lesion
ham10000-multimodal-skin-lesion is a machine learning model from cesaraha. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as apache-2.0.
Cross-attention fusion model for 7-class dermoscopic skin lesion classification, combining image features with patient metadata (age, sex, lesion localization). Trained from scratch on HAM10000 using PyTorch.
Downloads · 30 days
9
18% of all-time downloads
All-time downloads
51
Public
Repo size
6.4 MB
Likes
0
Public
Click a slice to open those files.
.pt6.4 MB · 100%
From the Hugging Face model README
Cross-attention fusion model for 7-class dermoscopic skin lesion classification, combining image features with patient metadata (age, sex, lesion localization). Trained from scratch on HAM10000 using PyTorch.
The model uses a CNN-B backbone (residual connections + batch normalisation) as the image encoder, paired with a cross-attention fusion module that allows patient metadata to selectively attend to spatial regions of the image feature map. This produces a metadata-conditioned image representation rather than a spatially-averaged one.
| Metric | Value |
|---|---|
| Test macro AUROC | 0.9385 |
| Test accuracy | 0.7063 |
| Class | AUROC |
|---|---|
| Melanoma | 0.8829 |
| Actinic keratosis | 0.9744 |
| Benign keratosis | 0.8944 |
| Basal cell carcinoma | 0.9689 |
| Dermatofibroma | 0.9327 |
| Nevi | 0.9391 |
| Vascular | 0.9771 |
import torch
from PIL import Image
from torchvision import transforms
# Load checkpoint
state = torch.load("best.pt", map_location="cpu", weights_only=False)
# Initialise model (architecture definition required — see GitHub repo)
model = CrossAttentionFusionModel(meta_dim=35)
model.load_state_dict(state["model"])
model.eval()
# Image preprocessing
transform = transforms.Compose([
transforms.Resize((224, 224)),
transforms.ToTensor(),
transforms.Normalize(mean=[0.485, 0.456, 0.406],
std=[0.229, 0.224, 0.225]),
])
# Metadata: [age_normalised, sex_onehot(3), localization_onehot(31)]
# See GitHub repo for full encode_metadata() function
Trained on Google Colab free tier (T4 GPU) for 30 epochs. Full experimental methodology including architecture ablation, hyperparameter search, and fusion strategy comparison available in the GitHub repository.
Tschandl P., Rosendahl C. & Kittler H. The HAM10000 dataset, a large
collection of multi-source dermatoscopic images of common pigmented
skin lesions. Sci. Data 5, 180161 (2018).