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