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**