|
|
--- |
|
|
license: gpl-3.0 |
|
|
language: |
|
|
- en |
|
|
metrics: |
|
|
- accuracy |
|
|
tags: |
|
|
- medical |
|
|
- cancer |
|
|
- chemistry |
|
|
- biology |
|
|
- skin |
|
|
--- |
|
|
|
|
|
# π§ Model Card for Skin Cancer ResNet18 Classifier |
|
|
|
|
|
This is a binary skin lesion classifier based on ResNet-18. It was trained to distinguish between **benign** and **malignant** dermoscopic images using the HAM10000 dataset. The model is part of a privacy-focused research project for on-device melanoma risk screening. |
|
|
|
|
|
## 𧬠Model Details |
|
|
|
|
|
### π Model Description |
|
|
|
|
|
- **π¨βπ» Developed by:** Conn Finnegan |
|
|
- **π§ Model type:** Image classifier (ResNet18) |
|
|
- **π§ Finetuned from model:** `torchvision.models.resnet18(pretrained=True)` |
|
|
- **πΌοΈ Input shape:** RGB image (3 x 224 x 224) |
|
|
- **π·οΈ Output classes:** |
|
|
- Class 0: Benign |
|
|
- Class 1: Malignant |
|
|
|
|
|
### π¦ Model Sources |
|
|
|
|
|
- **π Repository:** [https://huggingface.co/connfinnegan/skin-cancer-resnet18](https://huggingface.co/connfinnegan/skin-cancer-resnet18) |
|
|
- **π§ͺ Demo:** Coming soon via Hugging Face Spaces |
|
|
|
|
|
## π Uses |
|
|
|
|
|
### π― Direct Use |
|
|
|
|
|
Used for inference on dermoscopic mole/lesion images to estimate if a lesion is likely benign or malignant. |
|
|
|
|
|
### π« Out-of-Scope Use |
|
|
|
|
|
- Not intended as a diagnostic medical tool. |
|
|
- Not trained on diverse skin tones or photographic image types. |
|
|
|
|
|
## β οΈ Bias, Risks, and Limitations |
|
|
|
|
|
- Model trained on dermoscopic images from the HAM10000 dataset, which is not representative of all skin types or lesion types. |
|
|
- False negatives (missed malignancies) could be harmful. |
|
|
- False positives may cause unnecessary concern. |
|
|
|
|
|
### β
Recommendations |
|
|
|
|
|
- Always consult a healthcare professional. This model is a research prototype only. |
|
|
|
|
|
## π§ͺ How to Get Started with the Model |
|
|
|
|
|
```python |
|
|
import torch |
|
|
from torchvision import models, transforms |
|
|
from PIL import Image |
|
|
|
|
|
model = models.resnet18() |
|
|
model.fc = torch.nn.Linear(model.fc.in_features, 2) |
|
|
model.load_state_dict(torch.load("skin_cancer_resnet18_v1.pt", map_location='cpu')) |
|
|
model.eval() |
|
|
|
|
|
transform = transforms.Compose([ |
|
|
transforms.Resize((224, 224)), |
|
|
transforms.ToTensor() |
|
|
]) |
|
|
|
|
|
img = Image.open("your_image.jpg").convert("RGB") |
|
|
input_tensor = transform(img).unsqueeze(0) |
|
|
|
|
|
with torch.no_grad(): |
|
|
output = model(input_tensor) |
|
|
pred = torch.argmax(output, dim=1).item() |
|
|
print("Prediction:", "benign" if pred == 0 else "malignant") |
|
|
``` |
|
|
|
|
|
## ποΈ Training Details |
|
|
|
|
|
### ποΈ Training Data |
|
|
|
|
|
- Dataset: HAM10000 (Kaggle) |
|
|
- Malignant classes grouped: melanoma, bcc, akiec |
|
|
- Benign classes grouped: nv, bkl, df, vasc |
|
|
|
|
|
### βοΈ Training Procedure |
|
|
|
|
|
- π Input resolution: 224x224 |
|
|
- π§ Optimiser: Adam |
|
|
- π Loss function: Weighted Cross Entropy |
|
|
- π Epochs: 50 with early stopping |
|
|
- βοΈ Class weights: applied (malignant overweighted \~3.5x) |
|
|
- π§± Framework: PyTorch 2.0.0 |
|
|
|
|
|
## π Evaluation |
|
|
|
|
|
- β
Accuracy: \~89% |
|
|
- π Malignant recall: \~78% |
|
|
- π― Benign precision: >90% |
|
|
|
|
|
## π§° Technical Specifications |
|
|
|
|
|
- **ποΈ Architecture:** ResNet18 (modified last FC layer) |
|
|
- **π§ͺ Framework:** PyTorch + Torchvision |
|
|
- **π Python version:** 3.10 |
|
|
- **π¦ Dependencies:** torchvision, torch, PIL, numpy |
|
|
|
|
|
## π¬ Model Card Contact |
|
|
|
|
|
- **π€ Author:** Conn Finnegan |
|
|
- **π LinkedIn: https://www.linkedin.com/in/conn-finnegan-09a98124b/** |
|
|
- **π GitHub: https://github.com/Conn-Finnegan** |
|
|
|
|
|
|