dermaAI / README.md
yashvardhanshah
restore HF metadata
5af7726
|
Raw
History Blame Contribute Delete
10.8 kB
metadata
title: DermAI Skin Disease Classifier
emoji: πŸ”¬
colorFrom: blue
colorTo: blue
sdk: docker
pinned: false
license: mit
app_port: 7860

πŸ”¬ DermAI β€” Skin Disease Classifier

AI-Powered Dermatology Assistant

Live Demo GitHub Python FastAPI Streamlit License

Upload a skin photo. Get an AI diagnosis in seconds.

DermAI Banner Classes Deployment


πŸ“‹ Table of Contents


🧠 Overview

DermAI is a full-stack AI-powered web application that classifies skin diseases from photographs using deep learning. Built with a fine-tuned ResNet-34 convolutional neural network trained via the fastai framework, it identifies 21 distinct skin conditions and provides detailed medical information, treatment options, and urgency flags for conditions requiring immediate attention.

The application features a FastAPI REST backend for model inference and a Streamlit multi-page frontend β€” both running concurrently inside a single Docker container deployed on Hugging Face Spaces.


✨ Features

Feature Description
πŸ”¬ AI Diagnosis Upload any skin photo and receive top-3 predictions with confidence scores
πŸ“– Disease Encyclopedia Detailed profiles for all 21 classifiable conditions
πŸ₯ Dermatology Hub Expert articles on skincare, sun protection, and dermatology tips
⚠️ Urgency Flags Automatic red alerts for high-risk conditions (Skin Cancer, Actinic Keratosis)
πŸŒ™ Dark UI Modern dark-themed interface with responsive layout
⚑ Fast Inference Direct tensor inference bypassing DataLoader threading issues
🐳 Dockerized Single-container deployment with supervisor managing both services

πŸ›  Tech Stack

Backend

  • FastAPI β€” REST API framework
  • Uvicorn β€” ASGI server
  • fastai / PyTorch β€” Model loading and inference
  • Pydantic β€” Data validation and serialization

Frontend

  • Streamlit β€” Multi-page web interface
  • Custom CSS β€” Dark theme with Orbitron + DM Sans typography

ML / Model

  • Architecture: ResNet-34 (pretrained on ImageNet, fine-tuned)
  • Framework: fastai 2.7
  • Input Size: 448Γ—448px (progressive resizing from 224β†’448)
  • Output: Top-3 predictions with softmax confidence scores

Infrastructure

  • Docker β€” Containerization
  • Supervisor β€” Process management (FastAPI + Streamlit)
  • Hugging Face Spaces β€” Cloud deployment
  • Git LFS β€” Large file storage for model weights

πŸ€– Model Architecture

Input Image (any size)
        ↓
    Resize to 448Γ—448
        ↓
    Normalization (ImageNet stats)
        ↓
    ResNet-34 Backbone
    (pretrained on ImageNet)
        ↓
    Custom Classification Head
        ↓
    Softmax (21 classes)
        ↓
    Top-3 Predictions + Confidence Scores

Training Details

  • Base Model: ResNet-34 (ImageNet pretrained)
  • Training Strategy: Progressive resizing (224 β†’ 448)
  • Framework: fastai with 1-cycle learning rate policy
  • Augmentations: Random flip, rotation, zoom, lighting adjustments
  • Optimizer: Adam with weight decay

🦠 Disease Classes

The model classifies the following 21 skin conditions:

# Medical Name Category
1 Acne Inflammatory
2 Rosacea Inflammatory
3 Tinea (Ringworm) Fungal
4 Candidiasis Fungal
5 Warts Viral
6 Eczema / Dermatitis Inflammatory
7 Psoriasis Autoimmune
8 Normal Skin Healthy
9 Skin Cancer Oncological ⚠️
10 Actinic Keratosis Pre-Cancerous ⚠️
11 Benign Tumors Growth
12 Bullous Disorders Autoimmune
13 Drug Eruptions Allergic
14 Infestations & Bites Parasitic
15 Lichen Disorders Inflammatory
16 Lupus-Related Conditions Autoimmune
17 Moles (Nevi) Growth
18 Seborrheic Keratoses Growth
19 Vascular Tumors Growth
20 Vasculitis Inflammatory
21 Vitiligo Autoimmune

πŸ“ Project Structure

dermAI/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ backend/
β”‚   β”‚   β”œβ”€β”€ main.py              # FastAPI app & endpoints
β”‚   β”‚   β”œβ”€β”€ model.py             # Model loading & inference
β”‚   β”‚   β”œβ”€β”€ schemas.py           # Pydantic models
β”‚   β”‚   └── __init__.py
β”‚   β”œβ”€β”€ frontend/
β”‚   β”‚   β”œβ”€β”€ Home.py              # Streamlit entry point
β”‚   β”‚   β”œβ”€β”€ styles.py            # Global CSS injection
β”‚   β”‚   β”œβ”€β”€ .streamlit/
β”‚   β”‚   β”‚   └── config.toml      # Streamlit configuration
β”‚   β”‚   └── pages/
β”‚   β”‚       β”œβ”€β”€ 1_Diagnosis.py       # Image upload & prediction
β”‚   β”‚       β”œβ”€β”€ 2_Encyclopedia.py    # Disease database browser
β”‚   β”‚       β”œβ”€β”€ 3_Dermatology_Hub.py # Articles & tips
β”‚   β”‚       └── 4_About_FAQ.py       # About & FAQ
β”‚   └── data/
β”‚       └── disease_info.py      # Disease info database (21 conditions)
β”œβ”€β”€ skin_disease_classifier.pkl  # Trained model weights (88MB, Git LFS)
β”œβ”€β”€ Dockerfile                   # Multi-service Docker container
β”œβ”€β”€ requirements.txt             # Python dependencies
└── README.md

πŸš€ Local Setup

Prerequisites

  • Python 3.12+
  • Git LFS
  • Conda (recommended) or virtualenv

1. Clone the repository

git clone https://github.com/yashvardhanshah/dermAI.git
cd dermAI

2. Create environment & install dependencies

conda create -n dermai python=3.12
conda activate dermai
pip install -r requirements.txt

3. Set environment variable (Windows)

set KMP_DUPLICATE_LIB_OK=TRUE

4. Start the FastAPI backend

cd app
uvicorn backend.main:app --reload --port 8000

5. Start the Streamlit frontend (new terminal)

cd app/frontend
streamlit run Home.py

6. Open in browser


πŸ“‘ API Reference

Base URL

https://huggingface.co/spaces/Yashvardhan1/dermaAI (production)
http://localhost:8000 (local)

Endpoints

GET /health

Health check β€” returns model load status.

{
  "status": "ok",
  "model_loaded": true,
  "version": "1.0.0"
}

POST /predict

Upload a skin image and receive top-3 predictions.

Request: multipart/form-data with file field (JPEG/PNG/WEBP, max 15MB)

Response:

{
  "top3": [
    {
      "label": "Acne",
      "friendly_name": "Acne / Pimples",
      "confidence": 0.8923
    },
    ...
  ],
  "disclaimer": "This tool is for educational purposes only..."
}

GET /diseases

Returns summary list of all 21 classifiable conditions.

GET /disease/{disease_key}

Returns full detail for a single condition including symptoms, causes, treatments, and when to see a doctor.


🐳 Deployment

The app is deployed on Hugging Face Spaces as a Docker Space.

Architecture

Docker Container
β”œβ”€β”€ Supervisor (process manager)
β”‚   β”œβ”€β”€ FastAPI (port 8000) β€” model inference API
β”‚   └── Streamlit (port 7860) β€” web UI (exposed)
└── skin_disease_classifier.pkl β€” model weights

Deploy your own

  1. Fork this repository
  2. Create a new HuggingFace Space (Docker SDK)
  3. Push code to the Space repository
  4. The app builds and deploys automatically

⚠️ Medical Disclaimer

DermAI is an educational tool only and does NOT constitute medical advice.

This application is designed for informational and educational purposes. It should NOT be used as a substitute for professional medical diagnosis, advice, or treatment. Always consult a qualified dermatologist or healthcare professional for any skin concerns.

Results flagged as Skin Cancer or Actinic Keratosis should be evaluated by a medical professional immediately.


πŸ“„ License

This project is licensed under the MIT License β€” see the LICENSE file for details.

MIT License

Copyright (c) 2026 Yashvardhan Shah

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.

πŸ‘€ Author

Yashvardhan Shah

GitHub HuggingFace


⭐ Star this repo if you found it useful!

Built with ❀️ using FastAPI, Streamlit, and fastai