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
- Clone or download this repository
- Install Python dependencies:
bash pip install tensorflow opencv-python numpy scikit-learn matplotlib - Configure dataset path in
Model_Train.py(e.g.,data_pathvariable) - Train the model:
bash python Model_Train.py - (Optional) Generate confusion matrix:
bash python "confusion matrix.py"
๐ Web Demo (Browser Inference)
- Make sure
index.html,model.jsonandweights.binare in the same directory. - Start a simple HTTP server:
bash python -m http.server 8000 - Open your browser and navigate to
http://localhost:8000. - 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
- Open the web app (
index.html) via a local server. - Click Upload (or the file input control) and select an eye image.
- Wait for the model to process the image.
- 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
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)
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
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
Data Scarcity
- Limited availability of high-quality, labeled eye image datasets
- Addressed through data augmentation and careful model regularization
Class Imbalance
- Some eye conditions had significantly fewer samples than others
- Implemented class weighting and oversampling techniques
Model Deployment
- Converting the model to run efficiently in the browser
- Managing model size while maintaining accuracy
- Optimizing inference time for better user experience
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
- Place your dataset in the folder referenced by
Model_Train.py. - Run
python Model_Train.pyto train and save the model. - 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
- css3
- git
- html5
- javascript
- jupyter-notebook
- keras
- matplotlib
- numpy
- opencv
- python
- scikit-learn
- tensorflow
- tensorflow.js
Log in or sign up for Devpost to join the conversation.