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