skin_ai / README.md
Pro-Coder's picture
Upload 3 files
6b52e57 verified
|
Raw
History Blame Contribute Delete
3.88 kB

A newer version of the Gradio SDK is available: 6.22.0

Upgrade
metadata
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 (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 โ†’ 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:

    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:

    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:

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

pip install -r requirements.txt
export HF_TOKEN=your_token_here   # optional, for chat
python app.py