Spaces:
Sleeping
Sleeping
File size: 10,783 Bytes
5af7726 7e05b9f 4e817fd 7e05b9f 4e817fd 7e05b9f 4e817fd 7e05b9f 4e817fd 7e05b9f | 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 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 | ---
title: DermAI Skin Disease Classifier
emoji: π¬
colorFrom: blue
colorTo: blue
sdk: docker
pinned: false
license: mit
app_port: 7860
---
<div align="center">
# π¬ DermAI β Skin Disease Classifier
### AI-Powered Dermatology Assistant
[](https://huggingface.co/spaces/Yashvardhan1/dermaAI)
[](https://github.com/yashvardhanshah/dermAI)
[](https://python.org)
[](https://fastapi.tiangolo.com)
[](https://streamlit.io)
[](LICENSE)
*Upload a skin photo. Get an AI diagnosis in seconds.*
  
</div>
---
## π Table of Contents
- [Overview](#-overview)
- [Features](#-features)
- [Tech Stack](#-tech-stack)
- [Model Architecture](#-model-architecture)
- [Disease Classes](#-disease-classes)
- [Project Structure](#-project-structure)
- [Local Setup](#-local-setup)
- [API Reference](#-api-reference)
- [Deployment](#-deployment)
- [Screenshots](#-screenshots)
- [Disclaimer](#-medical-disclaimer)
- [License](#-license)
- [Author](#-author)
---
## π§ 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
```bash
git clone https://github.com/yashvardhanshah/dermAI.git
cd dermAI
```
### 2. Create environment & install dependencies
```bash
conda create -n dermai python=3.12
conda activate dermai
pip install -r requirements.txt
```
### 3. Set environment variable (Windows)
```bash
set KMP_DUPLICATE_LIB_OK=TRUE
```
### 4. Start the FastAPI backend
```bash
cd app
uvicorn backend.main:app --reload --port 8000
```
### 5. Start the Streamlit frontend (new terminal)
```bash
cd app/frontend
streamlit run Home.py
```
### 6. Open in browser
- **App:** http://localhost:8501
- **API Docs:** http://localhost:8000/docs
---
## π‘ API Reference
### Base URL
```
https://huggingface.co/spaces/Yashvardhan1/dermaAI (production)
http://localhost:8000 (local)
```
### Endpoints
#### `GET /health`
Health check β returns model load status.
```json
{
"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:**
```json
{
"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](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**
[](https://github.com/yashvardhanshah)
[](https://huggingface.co/Yashvardhan1)
---
<div align="center">
**β Star this repo if you found it useful!**
*Built with β€οΈ using FastAPI, Streamlit, and fastai*
</div> |