Inspiration

What it does

How we built it

Challenges we ran into

Accomplishments that we're proud of

What we learned

What's next for Eye Disease Prediction

๐Ÿ‘๏ธ Eye Disease Prediction

Eye Disease Prediction is a deepโ€‘learningโ€“based image classification project that detects common eye diseases from retinal/eye images. It provides a web interface for quick predictions and Python tools for training and evaluation.


โœจ Features

๐ŸŽฏ Core Features

  • 7โ€‘Class Eye Disease Classifier: Predicts one of the following classes from an eye image:
    • Bulging, Cataract, Crossed, Glaucoma, Mucormycosis, Normal, Uveitis
  • Browserโ€‘based Inference: Run predictions directly in the browser using TensorFlow.js
  • Simple Web UI: Upload an eye image and get an instant prediction
  • Model Training Script: Train or retrain the model on your own dataset
  • Evaluation Tools: Generate and visualize a confusion matrix

๐Ÿ“Š Model

  • Architecture: Convolutional Neural Network (CNN) implemented in Python (Keras/TensorFlow)
  • Input: Preprocessed eye images (e.g., resized and normalized)
  • Output: Probability distribution over 7 classes with top predicted label

๐Ÿ› ๏ธ Tech Stack

Backend / Training

  • Python
  • TensorFlow / Keras
  • NumPy
  • OpenCV
  • scikitโ€‘learn
  • matplotlib

Web Frontend

  • HTML / CSS / JavaScript
  • TensorFlow.js (via model.json + weights.bin)

๐Ÿ“ฆ Installation (Training & Evaluation)

Prerequisites

  • Python 3.8+
  • pip
  • A dataset of labeled eye images organized by class (one folder per class)

Setup

  1. Clone or download this repository
  2. Install Python dependencies: bash pip install tensorflow opencv-python numpy scikit-learn matplotlib
  3. Configure dataset path in Model_Train.py (e.g., data_path variable)
  4. Train the model: bash python Model_Train.py
  5. (Optional) Generate confusion matrix: bash python "confusion matrix.py"

๐ŸŒ Web Demo (Browser Inference)

  1. Make sure index.html, model.json and weights.bin are in the same directory.
  2. Start a simple HTTP server: bash python -m http.server 8000
  3. Open your browser and navigate to http://localhost:8000.
  4. Open index.html, upload an eye image, and view the predicted disease class.

๐Ÿ“ Project Structure

eye-disease-prediction/
โ”œโ”€โ”€ index.html              # Web UI for image upload & prediction
โ”œโ”€โ”€ style1.css              # Styles for the web interface
โ”œโ”€โ”€ model.json              # TensorFlow.js model definition
โ”œโ”€โ”€ weights.bin             # TensorFlow.js model weights
โ”œโ”€โ”€ Model_Train.py          # Python script to train the CNN model
โ”œโ”€โ”€ confusion matrix.py     # Script to compute & plot confusion matrix
โ”œโ”€โ”€ model.weights.bin       # Additional/exported weights (if used)
โ”œโ”€โ”€ index.php               # Optional PHP entry point (if hosted on PHP server)
โ””โ”€โ”€ README.md               # Project documentation

๐ŸŽฎ Usage

Web Interface

  1. Open the web app (index.html) via a local server.
  2. Click Upload (or the file input control) and select an eye image.
  3. Wait for the model to process the image.
  4. View the predicted class (e.g., Glaucoma, Normal, etc.).

๐ŸŽฏ About the Project

๐Ÿ’ก Inspiration

Eye diseases often go undetected until they reach advanced stages, leading to preventable vision loss. Inspired by the potential of artificial intelligence in healthcare, we set out to create an accessible tool that could help in the early detection of common eye conditions. Our goal was to bridge the gap between advanced machine learning and practical healthcare applications, making eye disease screening more accessible to everyone.

๐Ÿง  What We Learned

Building this project was an incredible learning journey that deepened our understanding of:

  • Computer Vision: Implementing and fine-tuning CNN architectures for medical image classification
  • Model Optimization: Balancing model accuracy and performance for web deployment
  • Web Integration: Converting Keras models to TensorFlow.js for browser-based inference
  • Medical Imaging: Understanding the unique characteristics of retinal images and their preprocessing requirements

๐Ÿ› ๏ธ How We Built It

  1. Data Collection & Preprocessing

    • Gathered a diverse dataset of eye images across 7 disease categories
    • Implemented data augmentation to handle class imbalance and improve generalization
    • Normalized and resized images to a consistent format (224ร—224 pixels)
  2. Model Development

    • Built and trained a custom CNN architecture using Keras/TensorFlow
    • Experimented with transfer learning using pre-trained models
    • Optimized the model for both accuracy and inference speed
  3. Web Interface

    • Created an intuitive, responsive web interface using HTML/CSS/JavaScript
    • Integrated TensorFlow.js for client-side model inference
    • Ensured cross-browser compatibility and mobile responsiveness

๐Ÿง— Challenges Faced

  1. Data Scarcity

    • Limited availability of high-quality, labeled eye image datasets
    • Addressed through data augmentation and careful model regularization
  2. Class Imbalance

    • Some eye conditions had significantly fewer samples than others
    • Implemented class weighting and oversampling techniques
  3. Model Deployment

    • Converting the model to run efficiently in the browser
    • Managing model size while maintaining accuracy
    • Optimizing inference time for better user experience
  4. Real-world Variability

    • Handling variations in image quality, lighting, and angles
    • Ensuring the model generalizes well to real-world clinical images

๐Ÿ“ˆ Technical Insights

The model's performance was evaluated using:

  • Accuracy: $\frac{TP + TN}{TP + TN + FP + FN}$
  • Precision: $\frac{TP}{TP + FP}$
  • Recall: $\frac{TP}{TP + FN}$
  • F1-Score: $2 \times \frac{Precision \times Recall}{Precision + Recall}$

๐ŸŒŸ Future Improvements

  • Expand the dataset with more diverse eye images
  • Implement real-time video analysis capability
  • Add multi-language support for global accessibility
  • Develop a mobile app version for field diagnostics

Training & Evaluation

  1. Place your dataset in the folder referenced by Model_Train.py.
  2. Run python Model_Train.py to train and save the model.
  3. Run python "confusion matrix.py" to evaluate and visualize performance.

๐Ÿ” Ethical & Clinical Disclaimer

  • This project is intended for research and educational purposes only.
  • It is not a certified medical device and must not be used for clinical diagnosis or treatment decisions.
  • Always consult a qualified ophthalmologist or medical professional for any medical concerns.

๐Ÿ“ License

This project is licensed under the terms specified in the LICENSE file.

Built With

Share this project:

Updates