Downloads · 30 days
0
Ai-Adam-Six-Sigma/melanoma-segmentation
melanoma-segmentation is a image segmentation model from Ai-Adam-Six-Sigma. Use it for the image segmentation task on the model card, and read the license before you ship it in a product. It is set up for pytorch. The card lists the license as apache-2.0.
U-Net segmentation model with an EfficientNet-B0 encoder, trained to segment melanoma lesions in dermoscopic images. Part of a 3-stage melanoma analysis pipeline (detection → segmentation → classification) — see melan…
Downloads · 30 days
0
Access
Public
Updated Aug 18, 2026
Repo size
25.3 MB
Likes
1
Public
Click a slice to open those files.
.pth25.3 MB · 100%
From the Hugging Face model README
U-Net segmentation model with an EfficientNet-B0 encoder, trained to segment melanoma lesions in dermoscopic images. Part of a 3-stage melanoma analysis pipeline (detection → segmentation → classification) — see melanoma-pipeline for the full inference chain.
segmentation_models_pytorchunet_melanoma.pth (state_dict)smp.losses.DiceLoss(mode='binary'))This model is intended for research and educational purposes — as a component in an experimental melanoma analysis pipeline. It is not a certified medical device and must not be used for clinical diagnosis without validation by qualified medical professionals and regulatory approval.
import torch
import segmentation_models_pytorch as smp
from huggingface_hub import hf_hub_download
# Download weights
weights_path = hf_hub_download(
repo_id="Ai-Adam-Six-Sigma/melanoma-segmentation",
filename="unet_melanoma.pth"
)
model = smp.Unet(
encoder_name="efficientnet-b0",
encoder_weights=None,
in_channels=3,
classes=1,
)
model.load_state_dict(torch.load(weights_path, map_location="cpu"))
model.eval()
# Preprocessing: resize to 256x256, scale to [0, 1] (no ImageNet mean/std normalization)
from PIL import Image
import numpy as np
img = Image.open("lesion.jpg").convert("RGB").resize((256, 256))
input_tensor = torch.tensor(np.array(img)).permute(2, 0, 1).float().unsqueeze(0) / 255.0
# Inference
with torch.no_grad():
mask_logits = model(input_tensor)
mask = torch.sigmoid(mask_logits) > 0.5
Trained on the ISIC 2018 Task 1 lesion segmentation dataset (dermoscopic images with binary lesion masks). Split: first 2,000 images for training, remainder for validation (sequential, not shuffled).
Trained for 5 epochs with binary Dice Loss:
| Epoch | Train Loss | Val Loss |
|---|---|---|
| 1 | 0.2058 | 0.1386 |
| 2 | 0.1346 | 0.1583 |
| 3 | 0.1195 | 0.1126 |
| 4 | 0.1091 | 0.1340 |
| 5 | 0.0972 | 0.1194 |
Since the loss is Dice Loss (1 - Dice coefficient), the final epoch corresponds to a validation Dice coefficient of ≈ 0.88. Note validation loss fluctuates across epochs (best at epoch 3: 0.1126 → Dice ≈ 0.89) rather than decreasing monotonically, likely due to the small dataset split and no learning rate scheduling.
Apache 2.0