File size: 3,882 Bytes
22a70b4 | 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 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | ---
title: SkinAI Diagnostics
emoji: π¬
colorFrom: blue
colorTo: purple
sdk: docker
app_port: 7860
pinned: false
---
# Skin Cancer Classifier API
SkinAI Diagnostics β a FastAPI-powered web application for skin cancer image classification using deep learning.
---
## Overview
This project delivers a professional web interface for classifying dermatoscopic images. It enables users to upload a skin lesion image and obtain a prediction with calibrated confidence scores, alongside links to technical details of the underlying model.
---
## Repository Structure
```
skin-cancer-api/
βββ app/
β βββ main.py # FastAPI application entry point
β βββ predict.py # Image preprocessing and prediction logic
β βββ model_loader.py # Loads the trained EfficientNetV2S model
β βββ model/ # Local model storage (auto-downloaded if missing)
β β βββ efficientnetv2s.h5 # Pretrained model file
βββ test_images/ # Sample images for testing the app
β βββ ...
βββ requirements.txt # Python dependencies
βββ Dockerfile # Docker setup for deployment
βββ .dockerignore # Docker ignore rules
βββ README.md # Project documentation (this file)
```
---
## Features
- Seven-class classification of dermatoscopic images:
- Actinic Keratoses and Intraepithelial Carcinoma (AKIEC)
- Basal Cell Carcinoma (BCC)
- Benign Keratosis-like Lesions (BKL)
- Dermatofibroma (DF)
- Melanoma (MEL)
- Melanocytic Nevi (NV)
- Vascular Lesions (VASC)
- Professional web interface built with FastAPI and Jinja2
- Temperature Scaling (T-scaling) for calibrated probabilities
- Technical transparency: model architecture, training setup, and metrics
- Confidence visualization with a probability chart
- Sample images available in `test_images/`
---
## Model Details
- Base Model: EfficientNetV2S (20.5 million parameters)
- Dataset: [HAM10000](https://dataverse.harvard.edu/dataset.xhtml?persistentId=doi:10.7910/DVN/DBW86T)
- Calibration: Temperature Scaling (optimal T=2.77)
- Performance:
- Accuracy: 0.88
- Macro F1-score: 0.80
- Expected Calibration Error (ECE): 0.022 (after T-scaling)
For full technical details, see the Model Technical Information section in the app.
---
## Model Download from Hugging Face
The model file `efficientnetv2s.h5` is hosted on [Hugging Face Hub](https://huggingface.co/Miguel764/efficientnetv2s-skin-cancer-classifier) and is automatically downloaded the first time the app runs.
How it works:
- Expected local path: `app/model/efficientnetv2s.h5`
- On startup, `app/model_loader.py` checks for the file
- If missing, it is downloaded via `huggingface_hub` and saved to `app/model/`
- Subsequent runs load the local copy
Note for Docker users: When running inside a container, the downloaded model is stored inside the containerβs filesystem. Mount a volume if you need to persist it on the host.
Manual download link (optional): https://huggingface.co/Miguel764/efficientnetv2s-skin-cancer-classifier
---
## Installation & Usage
### 1) Clone the repository
```sh
git clone https://github.com/yourusername/skin-cancer-api.git
cd skin-cancer-api
```
### 2) Install dependencies
```sh
pip install -r requirements.txt
```
Note: Requires Python 3.8+ and TensorFlow 2.10.0 (GPU recommended).
### 3) Run the application
```sh
uvicorn app.main:app --reload
```
The app will be available at http://localhost:8000
Access the API docs at http://127.0.0.1:8000/docs
### 4) Try with sample images
Use the images in the `test_images/` folder to test the classifier.
---
## Docker Deployment
Build and run the app in a container:
```sh
docker build -t skin-cancer-api .
docker run -p 8000:8000 skin-cancer-api
```
---
|