File size: 3,321 Bytes
52f527e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
---
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**
|