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