File size: 3,883 Bytes
888b377 6b52e57 888b377 6b52e57 888b377 6b52e57 | 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 | ---
title: Skin Disease Detection Demo
emoji: π©Ί
colorFrom: blue
colorTo: pink
sdk: gradio
sdk_version: 4.44.0
app_file: app.py
pinned: false
license: apache-2.0
---
# π©Ί Skin Disease Detection β Demo
A demo Space where users can:
- **Upload a skin image** (or click a bundled test image) and get an AI classifier's
prediction across common skin-lesion categories, plus a plain-language explanation
from an LLM.
- **Chat with an assistant** about skin-health topics in general terms.
> β οΈ **This is an educational demo, not a medical device.** It does not diagnose
> anyone. Always see a licensed dermatologist or doctor for real concerns.
## How it works
| Component | What it does | Default model |
|---|---|---|
| Image classifier | Predicts a skin-lesion category from a photo | [`Anwarkh1/Skin_Cancer-Image_Classification`](https://huggingface.co/Anwarkh1/Skin_Cancer-Image_Classification) (ViT, trained on a HAM10000-derived dataset) |
| Chat / explanation | Turns predictions into plain language, answers general questions | `HuggingFaceH4/zephyr-7b-beta` via the Hugging Face Inference API |
Both model IDs are configurable via Space variables β see below.
## π Deploy in 3 steps
1. **Create a new Space**
Go to [huggingface.co/new-space](https://huggingface.co/new-space) β
choose **Gradio** as the SDK β CPU basic hardware is fine for the classifier.
2. **Upload these files**
Upload `app.py`, `requirements.txt`, this `README.md`, and the `examples/`
folder (if you generated test images β see below) to the Space repo,
either via the web UI ("Add file") or:
```bash
git clone https://huggingface.co/spaces/<your-username>/<your-space-name>
cp -r app.py requirements.txt README.md examples <your-space-name>/
cd <your-space-name>
git add . && git commit -m "Initial commit" && git push
```
3. **Add an `HF_TOKEN` secret (to enable the chatbot)**
In your Space β **Settings β Variables and secrets** β **New secret**:
- Name: `HF_TOKEN`
- Value: a Hugging Face access token (create one at
[huggingface.co/settings/tokens](https://huggingface.co/settings/tokens),
"Read" scope is enough)
Without this secret, image classification still works β only the
LLM-generated explanations and the chat tab need the token.
That's it β the Space will build and the app will be live.
## πΌοΈ Adding test images (optional but recommended)
So users have something to click without needing their own photo, generate a
few sample images once, locally, before you push:
```bash
pip install datasets pillow
python scripts/download_examples.py
```
This saves a handful of JPEGs into `examples/`. Include that folder when you
push to your Space. You can also just drop in your own sample `.jpg`/`.png`
files instead.
## βοΈ Configuration
Set these as Space **variables** (not secret, unless noted) to customize:
- `IMAGE_MODEL_ID` β any Hugging Face image-classification model compatible
with `transformers.pipeline("image-classification", ...)`.
- `CHAT_MODEL_ID` β any chat-completion-capable model available via the HF
Inference API.
- `HF_TOKEN` *(secret)* β required for the chat tab and the LLM explanations.
## π©Ή Limitations & responsible use
- The bundled classifier was trained on a research dataset (HAM10000-derived
dermatoscopic images) and has real, published accuracy limits β treat its
output as a talking point, not a result.
- Performance depends heavily on image quality, lighting, and skin tone
representation in the training data.
- This app must not be used as a substitute for professional medical
evaluation, and the chatbot is instructed to avoid giving diagnoses,
treatments, or dosages.
## Local development
```bash
pip install -r requirements.txt
export HF_TOKEN=your_token_here # optional, for chat
python app.py
```
|