A production-grade medical AI system for skin disease classification and LLM-powered clinical advice. This project combines Deep Learning (PyTorch) for disease classification with Large Language Models (Gemini/Groq/Ollama) to provide structured medical recommendations.
- Disease Detection: Image classification using ResNet-50 / EfficientNet-B0 / Yolov8.
- LLM Integration: Real-time advice via Groq (Cloud) or Ollama (Local) LLM.
- Patient Management: Track history by Patient ID and Name.
- Reports: Automated PDF report generation with patient details, AI recommendations and download full report.
- Production Ready: Async I/O, Environment-based configuration, and Dockerized deployment.
- Backend: FastAPI (Python 3.13)
- Frontend: Streamlit
- Database: SQLAlchemy (SQLite for Development)
- AI/ML: PyTorch
- LLM: Groq API / Ollama (Local Llama 3.2:3b)
- Deployment: Docker & Docker Compose
- Python 3.13
- Ollama (Optional for local LLM)
- Groq / Gemini API Key for using Cloud LLM
- Docker & Docker Compose (For containerized deployment)
-
Clone the repository:
git clone https://github.com/Ghost-141/SkinCare-AI.git cd SkinCare-AI -
Create and activate a virtual environment:
python -m venv .venv source .venv/bin/activate # Linux/macOS .venv\Scripts\activate # Windows
-
Install dependencies:
pip install uv uv sync
| File | Used By | Recommended Contents |
|---|---|---|
.env |
Docker Compose | Variables for the container (API keys, Ollama URL). |
.env.dev |
Local Python | Local file paths, ENV_MODE=dev, dev API keys. |
.env.prod |
App (Internal) | Production settings (usually mirrored from .env). |
Create a .env.dev file in the root directory. Paste the followings in that file:
APP_NAME=SkinCare_AI
ENV_MODE=dev
LLM_PROVIDER=Gemini
# LLM Provider: Groq
GROQ_API_KEY=groq_api_key_here
GROQ_MODEL=llama-3.1-8b-instant
# LLM Provider: Gemini
GOOGLE_API_KEY=gemini_api_key_here
GEMINI_MODEL=gemini-2.5-flash
# LLM Provider: Ollama
OLLAMA_BASE_URL=http://127.0.0.1:11434
OLLAMA_MODEL=qwen3-vl:2b
# Storage
DATABASE_URL=sqlite+aiosqlite:///./data/db/skin_app.db
UPLOAD_DIR=data/uploads
-
If you prefer to run the LLM locally for privacy or offline use:
-
Install Ollama: Download and install from ollama.ai.
-
Pull the required model:
ollama pull qwen3-vl:2b
-
Configure Environment: Ensure your
.env.devfile hasLLM_PROVIDER=OllamaandOLLAMA_MODEL=qwen3-vl:2b. -
CORS/Docker Note: If running the backend in Docker while Ollama is on the host, set the ollama based url as following:
OLLAMA_BASE_URL=http://your_local_machine_ip:11434
-
-
If you prefer to use models from google cloud use following steps:
- Use your google account and head to google developer api.
- Create an API Key from the
API Keystab. - Put the api key in the
.env.devatGOOGLE_API_KEYand ensure theLLM Provider=Gemini.
-
If you prefer to use models from cloud provides your can use groq.
- Create an account at Groq
- Create an API Key from the
API Keystab. - Put the api key in the
.env.devatGROQ_API_KEYand ensure theLLM Provider=Groq.
- To run backend use the following commnad:
rav run dev
- To run the frontend use the following command:
rav run ui
Access the backend: http://127.0.0.1:8000/docs
Access the frontend: http://localhost:8501/
The project is configured for easy deployment using Docker Compose. Before running the docker compose make sure to create .env in the root directory with all variables mentioned above. If using Ollama as LLM provides change the following:
OLLAMA_BASE_URL=http://your_local_machine_ip:11434rav run docker-compose- Edit
docker-compose.ymland changedockerfile: Dockerfiletodockerfile: Dockerfile.gpu. - Ensure NVIDIA Container Toolkit is installed on your host.
- Run:
docker compose up --build -d
Once the backend is running, you can access the interactive documentation:
- Swagger UI:
http://localhost:8000/docs - ReDoc:
http://localhost:8000/redoc
Analyzes an uploaded skin image and provides streaming LLM advice.
Request: multipart/form-data
user_id(integer): Unique Patient ID.patient_name(string): Full name of the patient.age(integer): Patient age.file(binary): Image file (JPG, PNG).
Response: text/event-stream
The stream starts with a JSON metadata block followed by LLM tokens:
{
"user_id": "123",
"patient_name": "John Doe",
"age": 25,
"prediction": "Eczema",
"accuracy": 0.95,
"created_at": "2026-04-02T12:00:00Z"
}Retrieves all past scan records for a specific patient.
Response Body:
{
"id": 1,
"user_id": "123",
"patient_name": "Imtiaz Ahammed",
"age": 25,
"image_path": "data/uploads/01.jpg",
"prediction": "Eczema",
"accuracy": 0.70,
"llm_recommendation": "The diagnosis is Eczema...",
"llm_provider": "Ollama",
"created_at": "2026-04-02T12:00:00Z"
}
Checks the operational status of all backend dependencies.
Response Body:
{
"status": "healthy",
"services": {
"database": "online",
"skin_model": {
"status": "loaded",
"device": "cpu",
"model_path": "models/weights/resnet.pt"
},
"llm": {
"provider": "Ollama",
"status": "online",
"model": "qwen3-vl:2b"
}
}
}Lists all available pre-trained model weights in the system. Response:
{
"available_models": [
"resnet.pt",
"efficientet.pt",
"yolov8-cls.pt"
],
"active_model": "resnet_v1.pt"
} Switches between the available pre-trained skin-disease model.
Query Parameter: model_name=resnet.pt
Response:
{
"message": "Active model successfully switched to resnet.pt",
"status": "success",
"active_model": "resnet.pt"
}The model was mainly trained on kaggle for better gpu support and longer training. However, with strong GPU we can train the model on our local environment. The scripts folder contains the training scripts to train, plot and save the models for deployment. Currently, it supports training the following models:
Resnet50EfficientNet_b0Yolov8n_cls
python scripts/train.py --data_path "C:/path/to/dataset" --model_type resnet --epochs 20Outputs: It contains model weights, training history plots, confusion matrix under the scripts/output/<model_type>/.
βββ api/ Β Β Β Β Β Β
β Β βββ v1/ Β Β Β Β # API endpoints
βββ core/ Β Β Β Β Β # Central Config
β Β βββ config.py Β Β Β
β Β βββ logger.py Β # App logger
β Β βββ db.py Β Β Β # Db engine
β Β βββ dependency.py Β
βββ models/ Β # Data Structures & Weights
β Β βββ db_models.py Β
β Β βββ schemas.py # Pydantic models
β Β βββ weights/ Β # .pt files
βββ services/ Β Β Β Β Β
β Β βββ interface/ # AbstractClasses
β Β βββ skin_service.py
β Β βββ advisor_service.py
βββ system_prompts/ Β Β
β Β βββ prompt_v1.py Β Β
βββ utils/ Β Β Β Β Β Β
β Β βββ groq_client.py Β Β
β Β βββ ollama_client.py Β
β Β βββ gemini_client.py Β
β Β βββ file_validator.py
β Β βββ visualization.py
β Β βββ ui_helpers.py Β Β
βββ data/ Β Β Β Β Β Β Β Β Β
β Β βββ db/ Β # SQLite file
β Β βββ uploads/ Β Β Β
β Β βββ class_mapping.json
βββ scripts/ Β Β Β Β Β Β Β Β
β Β βββ train.py Β Β Β Β Β # YOLO/CNN Training script
βββ tests/ Β Β Β Β Β Β
β Β βββ test_api.py Β Β Β Β # Pytest for API endpoints
βββ logs/ Β Β Β Β Β Β Β Β Β
β Β βββ app_date.log
βββ ui.py Β Β Β Β
βββ main.py Β Β Β
βββ Dockerfile Β Β Β Β
βββ docker-compose.yml Β Β
βββ pyproject.toml Β
βββ README.md Β Β Β Β Β
βββ LICENSE