Developed as part of Mobile Application Development with AI coursework.
For issues, questions, or contributions:
- Open an issue on GitHub
- Check the troubleshooting section
- Review configuration guides
- TensorFlow/Keras team for the ML framework
- Android development community
- Open-source contributors
- Dataset providers
Made with โค๏ธ for better healthcare accessibility
# Backend
cd skin-disease-detection-main
python -m venv venv
venv\Scripts\activate
pip install -r requirements.txt
python run_for_phone.py
# Android (in Android Studio)
# File โ Open โ Select project folder
# Run โ Run 'app'Now you're ready to detect skin diseases! ๐
An end-to-end mobile application that uses artificial intelligence and deep learning to detect and classify skin diseases from smartphone images.
- Overview
- How It Works
- Features
- Technology Stack
- Project Structure
- Prerequisites
- Local Setup Guide
- Running the Application
- Troubleshooting
- Contributing
- License
Skin diseases affect millions of people worldwide. Early detection and accurate diagnosis are crucial for effective treatment, but there's a shortage of dermatologists, especially in remote areas. Manual diagnosis is time-consuming, subjective, and often inaccessible to those who need it most.
This application provides an accessible, instant, AI-powered skin disease detection system that:
- Democratizes Healthcare - Anyone with a smartphone can get instant preliminary diagnosis
- Reduces Diagnosis Time - From days/weeks to seconds
- Assists Healthcare Workers - Provides a second opinion and helps prioritize cases
- Maintains Privacy - Images are processed locally, not shared publicly
- Educational Tool - Helps users understand different skin conditions
The AI model can detect various skin diseases including:
- Fungal Infections (FU): Ringworm, Athlete's Foot, Candidiasis
- Viral Infections (VI): Shingles, Herpes, Warts
- Parasitic Infections (PA): Cutaneous Larva Migrans, Scabies
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ANDROID APPLICATION โ
โ โ
โ โโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โ
โ โ Camera โ โ Gallery โ โ Results Display โ โ
โ โ Capture โ โ Selection โ โ Screen โ โ
โ โโโโโโโฌโโโโโ โโโโโโโโฌโโโโโโโ โโโโโโโโโโฒโโโโโโโโโโ โ
โ โ โ โ โ
โ โโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ
โ โโโโโโโโโโผโโโโโโโโโโโโโ โ
โ โ MainActivity โ โ
โ โ (Image Handler) โ โ
โ โโโโโโโโโโฌโโโโโโโโโโโโโ โ
โ โ โ
โ โโโโโโโโโโผโโโโโโโโโโโโโ โ
โ โ RetrofitClient โ โ
โ โ (HTTP Client) โ โ
โ โโโโโโโโโโฌโโโโโโโโโโโโโ โ
โ โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โ HTTP POST (Image)
โ
โโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ PYTHON BACKEND โ
โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Quart Web Server (Async Python) โ โ
โ โ Port: 5000 โ โ
โ โโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ API Endpoint: /api/v1/predictions/ โ โ
โ โ (Receives Image, Returns Prediction) โ โ
โ โโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ
โ โโโโโโโโโโโโโโโผโโโโโโโโโโโโโโ โ
โ โ โ โ โ
โ โโโโโโโโผโโโโโโโ โโโโโผโโโโโโ โโโโโโผโโโโโโโโโ โ
โ โ Image Save โ โ CNN โ โ Database โ โ
โ โ & Rename โ โ Model โ โ Logging โ โ
โ โโโโโโโโฌโโโโโโโ โโโโโฌโโโโโโ โโโโโโฌโโโโโโโโโ โ
โ โ โ โ โ
โ โโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโโผโโโโโโโโโ โ
โ โ Classification Result โ โ
โ โ DiseaseName_YYYY-MM-DD_HH-MM-SS.jpg โ โ
โ โโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ
โโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโ
โ JSON Response โ
โ to Mobile โ
โโโโโโโโโโโโโโโโโโ
- User opens the Android app
- Chooses to either take a photo with the camera or select from gallery
- Image is loaded into memory
- App uses Retrofit (HTTP client) to send the image to the backend
- Image is sent as multipart/form-data to
http://YOUR_SERVER:5000/api/v1/predictions/ - Request includes the image file
- Step 1: Quart server receives the image
- Step 2: Image is temporarily saved with a timestamp
- Step 3: Image is preprocessed:
- Resized to model's expected input size
- Normalized pixel values
- Converted to array format
- Step 4: Deep learning model (CNN) analyzes the image
- Step 5: Model outputs prediction (disease category)
- Step 6: Image is renamed to descriptive format:
DiseaseName_YYYY-MM-DD_HH-MM-SS.jpg - Step 7: Prediction is logged to SQLite database
- Backend sends JSON response:
{"prediction": "Fungal Infection"} - Android app receives and parses the response
- Results are displayed in a beautiful Material Design card
- User sees the detected disease type
- Image stored locally on server:
backend/image_bucket/DiseaseName_2025-11-07_14-30-45.jpg - Database record created with:
- Timestamp
- Prediction result
- Image filename
- Processing time
- ๐ท Camera Integration - Capture images directly
- ๐ผ๏ธ Gallery Selection - Choose existing images
- ๐ค AI Analysis - Instant disease detection
- ๐ Results Display - Clear, easy-to-understand results
- โ๏ธ Settings - Configure backend server URL
- ๐ Dynamic URL Configuration - Change server address without recompiling
- ๐จ Modern UI - Material Design 3 components
- ๐ Dark Mode Support - Automatic theme switching
- ๐ง Deep Learning - TensorFlow/Keras CNN model
- ๐พ Database Logging - SQLite for prediction history
- ๐ Smart Naming - Auto-rename images with results
- ๐ Async Processing - Fast, non-blocking operations
- ๐ก RESTful API - Clean, standardized endpoints
- ๐ Comprehensive Logging - Debug and monitor everything
- ๐ Error Handling - Robust validation and error responses
- Language: Java
- IDE: Android Studio Koala | 2024.1.1
- Build System: Gradle 8.7
- Min SDK: Android 11 (API 30)
- Target SDK: Android 14 (API 35)
Key Libraries:
- Retrofit 2.9.0 - HTTP networking
- OkHttp 4.11.0 - HTTP client
- Gson 2.10.1 - JSON parsing
- Material Design 3 - UI components
- Language: Python 3.11
- Framework: Quart (async Flask)
- ML Framework: TensorFlow 2.x / Keras
- Database: SQLite 3
- Image Processing: Pillow (PIL)
Key Libraries:
quart==0.19.4
tensorflow==2.x
pillow==10.0.0
numpy==1.24.3
- Architecture: Convolutional Neural Network (CNN)
- Training: Google Colab / Jupyter Notebook
- Input Size: 224x224x3 (RGB images)
- Output: Multi-class classification
- Model Format: HDF5 (.h5 file)
Skin_Disease/
โโโ app/ # Android Application
โ โโโ src/
โ โ โโโ main/
โ โ โ โโโ java/com/ahaanmehta/skin_disease/
โ โ โ โ โโโ MainActivity.java # Image upload & analysis
โ โ โ โ โโโ HomeActivity.java # Landing page
โ โ โ โ โโโ SplashActivity.java # Startup screen
โ โ โ โ โโโ AboutActivity.java # About page
โ โ โ โ โโโ SettingsActivity.java # Backend URL config
โ โ โ โ โโโ RetrofitClient.java # HTTP client setup
โ โ โ โ โโโ ApiService.java # API endpoints
โ โ โ โ โโโ PredictionResponse.java # Response model
โ โ โ โโโ res/
โ โ โ โ โโโ layout/ # XML layouts
โ โ โ โ โโโ drawable/ # Icons & graphics
โ โ โ โ โโโ values/ # Strings, colors, themes
โ โ โ โ โโโ xml/ # Network & file configs
โ โ โ โโโ AndroidManifest.xml # App configuration
โ โ โโโ test/ # Unit tests
โ โโโ build.gradle.kts # App dependencies
โโโ skin-disease-detection-main/ # Python Backend
โ โโโ backend/
โ โ โโโ app.py # Main application
โ โ โโโ blueprints/
โ โ โ โโโ model_blueprint.py # API routes
โ โ โโโ classification/
โ โ โ โโโ predictions.py # ML prediction logic
โ โ โ โโโ categories.json # Disease categories
โ โ โ โโโ final_file_tech_proj.ipynb # Model training notebook
โ โ โโโ database/
โ โ โ โโโ genesis.py # Database setup
โ โ โ โโโ population.py # Data operations
โ โ โโโ config/
โ โ โ โโโ app_config.toml # App settings
โ โ โ โโโ server_config.toml # Server settings
โ โ โโโ instance/
โ โ โ โโโ classifier.h5 # โ ๏ธ ML model (required!)
โ โ โ โโโ app.db # SQLite database
โ โ โโโ image_bucket/ # Uploaded images
โ โโโ requirements.txt # Python dependencies
โ โโโ run_for_phone.py # Server startup script
โโโ .gitignore # Git exclusions
โโโ CONFIG_SETUP.md # Configuration guide
โโโ GITHUB_READY_CHECKLIST.md # Deployment checklist
โโโ README.md # This file
Before you begin, ensure you have the following installed:
- โ
Android Studio (latest version)
- Download: https://developer.android.com/studio
- โ Java Development Kit (JDK) 11 or higher
- โ Android SDK (automatically installed with Android Studio)
- โ
Android Device or Emulator
- Physical device: Android 11 (API 30) or higher
- Emulator: Use Android Studio AVD Manager
- โ
Python 3.11 or higher
- Download: https://www.python.org/downloads/
โ ๏ธ During installation, check "Add Python to PATH"
- โ pip (Python package manager - comes with Python)
- โ
Git (for cloning the repository)
- Download: https://git-scm.com/downloads
- โ Same WiFi Network - Phone and computer must be on the same network
- โ Firewall Configuration - Allow Python through Windows Firewall
# Clone the repository
git clone https://github.com/de-code-bot/skin-disease-detection.git
# Navigate to the project directory
cd skin-disease-detection# Navigate to the backend directory
cd skin-disease-detection-main
# Create a virtual environment (recommended)
python -m venv venv
# Activate virtual environment
# On Windows:
venv\Scripts\activate
# On Mac/Linux:
source venv/bin/activate
# Install required packages
pip install -r requirements.txtThe model file classifier.h5 should be placed in:
skin-disease-detection-main/backend/instance/classifier.h5
Options to get the model:
-
Train your own model using the Jupyter notebook:
- Open
backend/classification/final_file_tech_proj.ipynb - Run all cells in Google Colab or Jupyter
- Save the trained model as
classifier.h5
- Open
-
Use a pre-trained model (if available)
- Download from project resources
- Place in
backend/instance/folder
# From the skin-disease-detection-main directory
python -m backend.database.genesisYou should see: Database initialized successfully!
Run Command Prompt as Administrator:
netsh advfirewall firewall add rule name="Python Server" dir=in action=allow program="C:\Path\To\Python\python.exe" enable=yesOr use the provided batch file:
# Run as Administrator
add_firewall_rule.bat- Launch Android Studio
- Click Open (or File โ Open)
- Navigate to the cloned repository folder
- Select the main
Skin_Diseasefolder - Click OK
- Wait for Gradle sync to complete (this may take a few minutes)
You have two options:
Option A: Use In-App Settings (Recommended)
- Just run the app and configure the URL in Settings
- No code changes needed!
Option B: Edit Source Code
Open app/src/main/java/com/ahaanmehta/skin_disease/RetrofitClient.java
Find this line (around line 67):
return "http://YOUR_SERVER_IP:5000/";Replace with:
- For Emulator:
http://10.0.2.2:5000/ - For Physical Device:
http://YOUR_COMPUTER_IP:5000/
How to find your computer's IP:
# On Windows
ipconfig
# Look for "IPv4 Address" under your WiFi adapter
# Example: 192.168.1.15If using a physical device, edit:
app/src/main/res/xml/network_security_config.xml
Add your computer's IP:
<domain includeSubdomains="true">192.168.1.15</domain># Navigate to backend directory
cd skin-disease-detection-main
# Activate virtual environment (if not already active)
venv\Scripts\activate # Windows
# source venv/bin/activate # Mac/Linux
# Start the server
python run_for_phone.pyExpected Output:
Starting Skin Disease Detection Backend
============================================================
๐ Server will be accessible at:
- From this computer: http://127.0.0.1:5000/
- From your phone: http://192.168.1.15:5000/
============================================================
* Running on all addresses (0.0.0.0)
* Running on http://127.0.0.1:5000
* Running on http://192.168.1.15:5000
โ Backend is now running! Keep this terminal open.
- Open Android Studio
- Click Run (
โถ๏ธ button) or pressShift + F10 - Select an emulator device
- Wait for the app to install and launch
- The emulator will automatically use
http://10.0.2.2:5000/
-
Enable Developer Options on your phone:
- Go to Settings โ About Phone
- Tap "Build Number" 7 times
-
Enable USB Debugging:
- Settings โ Developer Options โ USB Debugging
-
Connect phone via USB cable
-
In Android Studio:
- Click Run (
โถ๏ธ ) - Select your device
- Wait for installation
- Click Run (
-
Configure Backend URL:
- Open app โ Settings
- Click "Change Backend URL"
- Enter your computer's IP:
http://192.168.1.15:5000 - Click "Test Connection"
- Should show "โ Connection successful!"
- Launch the app - Opens with splash screen
- Home screen - Click "Start Detection"
- Main screen - Select image source:
- Click "๐ท Camera" to take a new photo
- Click "๐ผ๏ธ Gallery" to choose existing image
- Select/capture an image of a skin condition
- Click "Analyze Image" button
- Wait for results (usually 1-3 seconds)
- View diagnosis - Results appear in a card showing the detected disease type
Error: Could not find classifier.h5
Solution:
- Ensure
classifier.h5exists inbackend/instance/ - Train the model using the Jupyter notebook
- Check file permissions
Error: Failed to connect to /192.168.1.15:5000
Solutions:
- โ
Verify backend is running (
python run_for_phone.py) - โ Check devices are on same WiFi network
- โ Verify firewall allows Python
- โ
Ping the server from your phone's browser:
http://192.168.1.15:5000/ - โ Check the IP address is correct
Error: Unable to resolve host "YOUR_SERVER_IP"
Solution:
- You forgot to replace
YOUR_SERVER_IPwith actual IP - Edit
RetrofitClient.javaor use in-app Settings
Error: Could not resolve dependencies
Solution:
# In Android Studio terminal:
./gradlew clean
./gradlew build --refresh-dependenciesModuleNotFoundError: No module named 'quart'
Solution:
# Activate virtual environment first!
venv\Scripts\activate
pip install -r requirements.txtSolution:
- Use x86_64 system image (not ARM)
- Enable hardware acceleration (HAXM/WHPX)
- Allocate more RAM to emulator
- Or use a physical device
Error: Address already in use
Solution:
# Find what's using port 5000
netstat -ano | findstr :5000
# Kill the process (replace PID with actual number)
taskkill /PID <PID> /F
# Or change port in server_config.toml-
Check Logs:
- Android: Android Studio โ Logcat
- Backend: Terminal output
-
Test Backend Directly:
# Open browser or use curl curl http://localhost:5000/ -
Verify Network:
# From phone, open browser and visit: http://YOUR_COMPUTER_IP:5000/ # You should see a webpage
The model was trained on a skin disease dataset containing:
- Multiple disease categories
- Thousands of labeled images
- Various skin types and conditions
Training notebook: backend/classification/final_file_tech_proj.ipynb
Contributions are welcome! Here's how you can help:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Add more disease categories
- Improve model accuracy
- Add multi-language support
- Implement user authentication
- Create prediction history in app
- Add confidence scores to results
IMPORTANT: This application is intended for educational and research purposes only. It is NOT a substitute for professional medical advice, diagnosis, or treatment.
- โ Do NOT use for actual medical diagnosis
- โ Do NOT delay seeking professional medical care
- โ Always consult a qualified dermatologist
- โ Use as a learning tool only
This project is for educational purposes. Feel free to use, modify, and distribute for learning and non-commercial purposes.