Conn Finnegan
commited on
Model card made
Browse files
README.md
CHANGED
|
@@ -1,3 +1,118 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: gpl-3.0
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: gpl-3.0
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
metrics:
|
| 6 |
+
- accuracy
|
| 7 |
+
tags:
|
| 8 |
+
- medical
|
| 9 |
+
- cancer
|
| 10 |
+
- chemistry
|
| 11 |
+
- biology
|
| 12 |
+
- skin
|
| 13 |
+
---
|
| 14 |
+
|
| 15 |
+
# π§ Model Card for Skin Cancer ResNet18 Classifier
|
| 16 |
+
|
| 17 |
+
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.
|
| 18 |
+
|
| 19 |
+
## 𧬠Model Details
|
| 20 |
+
|
| 21 |
+
### π Model Description
|
| 22 |
+
|
| 23 |
+
- **π¨βπ» Developed by:** Conn Finnegan
|
| 24 |
+
- **π§ Model type:** Image classifier (ResNet18)
|
| 25 |
+
- **π§ Finetuned from model:** `torchvision.models.resnet18(pretrained=True)`
|
| 26 |
+
- **πΌοΈ Input shape:** RGB image (3 x 224 x 224)
|
| 27 |
+
- **π·οΈ Output classes:**
|
| 28 |
+
- Class 0: Benign
|
| 29 |
+
- Class 1: Malignant
|
| 30 |
+
|
| 31 |
+
### π¦ Model Sources
|
| 32 |
+
|
| 33 |
+
- **π Repository:** [https://huggingface.co/connfinnegan/skin-cancer-resnet18](https://huggingface.co/connfinnegan/skin-cancer-resnet18)
|
| 34 |
+
- **π§ͺ Demo:** Coming soon via Hugging Face Spaces
|
| 35 |
+
|
| 36 |
+
## π Uses
|
| 37 |
+
|
| 38 |
+
### π― Direct Use
|
| 39 |
+
|
| 40 |
+
Used for inference on dermoscopic mole/lesion images to estimate if a lesion is likely benign or malignant.
|
| 41 |
+
|
| 42 |
+
### π« Out-of-Scope Use
|
| 43 |
+
|
| 44 |
+
- Not intended as a diagnostic medical tool.
|
| 45 |
+
- Not trained on diverse skin tones or photographic image types.
|
| 46 |
+
|
| 47 |
+
## β οΈ Bias, Risks, and Limitations
|
| 48 |
+
|
| 49 |
+
- Model trained on dermoscopic images from the HAM10000 dataset, which is not representative of all skin types or lesion types.
|
| 50 |
+
- False negatives (missed malignancies) could be harmful.
|
| 51 |
+
- False positives may cause unnecessary concern.
|
| 52 |
+
|
| 53 |
+
### β
Recommendations
|
| 54 |
+
|
| 55 |
+
- Always consult a healthcare professional. This model is a research prototype only.
|
| 56 |
+
|
| 57 |
+
## π§ͺ How to Get Started with the Model
|
| 58 |
+
|
| 59 |
+
```python
|
| 60 |
+
import torch
|
| 61 |
+
from torchvision import models, transforms
|
| 62 |
+
from PIL import Image
|
| 63 |
+
|
| 64 |
+
model = models.resnet18()
|
| 65 |
+
model.fc = torch.nn.Linear(model.fc.in_features, 2)
|
| 66 |
+
model.load_state_dict(torch.load("skin_cancer_resnet18_v1.pt", map_location='cpu'))
|
| 67 |
+
model.eval()
|
| 68 |
+
|
| 69 |
+
transform = transforms.Compose([
|
| 70 |
+
transforms.Resize((224, 224)),
|
| 71 |
+
transforms.ToTensor()
|
| 72 |
+
])
|
| 73 |
+
|
| 74 |
+
img = Image.open("your_image.jpg").convert("RGB")
|
| 75 |
+
input_tensor = transform(img).unsqueeze(0)
|
| 76 |
+
|
| 77 |
+
with torch.no_grad():
|
| 78 |
+
output = model(input_tensor)
|
| 79 |
+
pred = torch.argmax(output, dim=1).item()
|
| 80 |
+
print("Prediction:", "benign" if pred == 0 else "malignant")
|
| 81 |
+
```
|
| 82 |
+
|
| 83 |
+
## ποΈ Training Details
|
| 84 |
+
|
| 85 |
+
### ποΈ Training Data
|
| 86 |
+
|
| 87 |
+
- Dataset: HAM10000 (Kaggle)
|
| 88 |
+
- Malignant classes grouped: melanoma, bcc, akiec
|
| 89 |
+
- Benign classes grouped: nv, bkl, df, vasc
|
| 90 |
+
|
| 91 |
+
### βοΈ Training Procedure
|
| 92 |
+
|
| 93 |
+
- π Input resolution: 224x224
|
| 94 |
+
- π§ Optimiser: Adam
|
| 95 |
+
- π Loss function: Weighted Cross Entropy
|
| 96 |
+
- π Epochs: 50 with early stopping
|
| 97 |
+
- βοΈ Class weights: applied (malignant overweighted \~3.5x)
|
| 98 |
+
- π§± Framework: PyTorch 2.0.0
|
| 99 |
+
|
| 100 |
+
## π Evaluation
|
| 101 |
+
|
| 102 |
+
- β
Accuracy: \~89%
|
| 103 |
+
- π Malignant recall: \~78%
|
| 104 |
+
- π― Benign precision: >90%
|
| 105 |
+
|
| 106 |
+
## π§° Technical Specifications
|
| 107 |
+
|
| 108 |
+
- **ποΈ Architecture:** ResNet18 (modified last FC layer)
|
| 109 |
+
- **π§ͺ Framework:** PyTorch + Torchvision
|
| 110 |
+
- **π Python version:** 3.10
|
| 111 |
+
- **π¦ Dependencies:** torchvision, torch, PIL, numpy
|
| 112 |
+
|
| 113 |
+
## π¬ Model Card Contact
|
| 114 |
+
|
| 115 |
+
- **π€ Author:** Conn Finnegan
|
| 116 |
+
- **π LinkedIn: https://www.linkedin.com/in/conn-finnegan-09a98124b/**
|
| 117 |
+
- **π GitHub: https://github.com/Conn-Finnegan**
|
| 118 |
+
|