Skip to content

coderzaman/Skin-Disease-Detection-AI

Repository files navigation

🩺 Skin Disease Detection & LLM Advisor System

An end-to-end AI-powered diagnostic assistant that analyzes skin images, detects 10 different categories of skin diseases using Deep Learning (Transfer Learning), and provides real-time, actionable medical recommendations using a Large Language Model (LLM).

🌟 Key Features

  • Accurate Image Classification: Utilizes a fine-tuned MobileNetV2 architecture to classify complex skin conditions.
  • High Precision on Critical Diseases: Achieved 97% precision for Melanoma and 89% for Basal Cell Carcinoma, making it highly reliable for detecting critical skin cancers.
  • LLM-Powered Insights: Integrates Gemini AI to generate detailed explanations, treatment recommendations, and next steps in a structured JSON format.
  • Interactive UI: A user-friendly Streamlit frontend for seamless image uploading and result visualization.
  • Robust API: A high-performance FastAPI backend capable of real-time inference.
  • Containerized Deployment: Fully dockerized (frontend & backend) for consistent and isolated deployments.

📊 Model Performance & Evaluation

The model was trained for 46 epochs (Early Stopping triggered to prevent overfitting) and evaluated on an independent test set.

Overall Metrics:

  • Test Accuracy: 76.33%
  • Test Loss: 0.0894
  • Macro Avg F1-Score: 0.69
  • Weighted Avg F1-Score: 0.76

Detailed Performance on Key Classes:

Disease Category Precision Recall F1-Score
Melanoma 0.97 0.75 0.85
Basal Cell Carcinoma (BCC) 0.89 0.90 0.90
Melanocytic Nevi (NV) 0.88 0.94 0.91
Benign Keratosis-like Lesions 0.68 0.76 0.72
Seborrheic Keratoses 0.66 0.76 0.71
Warts, Molluscum & Viral 0.62 0.69 0.65

Note: The model demonstrates exceptional precision in distinguishing life-threatening conditions like Melanoma, while inflammatory conditions (like Eczema and Atopic Dermatitis) show moderate scores due to high visual similarity.

🛠️ Technology Stack

  • Backend: Python, FastAPI, Uvicorn
  • Frontend: Streamlit
  • AI / ML Model: TensorFlow / Keras (MobileNetV2 Transfer Learning)
  • LLM Integration: Google Gemini API
  • Deployment: Docker, Docker Compose

📁 Project Structure

├── main.py                 # FastAPI backend entry point
├── app.py                  # Streamlit frontend application
├── inference.py            # Deep learning model prediction logic
├── llm_advisor.py          # LLM prompt engineering and API logic
├── best_skin_model.keras   # Saved trained model
├── requirements.txt        # Python dependencies
├── Dockerfile.backend      # Dockerfile for FastAPI
├── Dockerfile.frontend     # Dockerfile for Streamlit
└── docker-compose.yml      # Multi-container orchestration

## 🚀 How to Run the Project

### Method 1: Using Docker (Recommended)
Make sure Docker Desktop is installed and running on your machine.
1. Clone the repository.
2. Open your terminal in the project directory.
3. Run the following command:
   ```bash
   docker compose up --build
  1. Access the Application: http://localhost:8501
  2. Access the API Docs: http://localhost:8000/docs

Method 2: Running Locally (Without Docker)

  1. Install dependencies:
    pip install -r requirements.txt
  2. Start the Backend API (Terminal 1):
    uvicorn main:app --reload --port 8000
  3. Start the Frontend UI (Terminal 2):
    streamlit run app.py

About

An AI-powered skin disease detection system using Deep Learning (MobileNetV2) to classify 10 skin conditions. It features a FastAPI backend, Streamlit UI, and Gemini LLM integration for real-time medical recommendations. Fully containerized with Docker.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors