A comprehensive web application for analyzing Optical Coherence Tomography (OCT) retinal images using deep learning models. Built with Flask, PyTorch, and advanced computer vision techniques for medical image analysis.
This application provides an interactive platform for:
- OCT Image Upload & Analysis - Upload retinal OCT images for automated analysis
- Multiple ML Models - Support for various deep learning models for image classification
- Image Quality Assessment - Comprehensive image quality evaluation with recommendations
- Visualization Suite - Advanced visualizations and heatmaps for interpretability
- Performance Benchmarking - Compare model performance with detailed metrics
- Export & Reporting - Generate downloadable analysis reports and results
- π¬ Medical Image Analysis - Specialized for OCT retinal imaging
- π€ Multiple AI Models - Support for various pre-trained deep learning models
- π Advanced Visualizations - Heatmaps, confusion matrices, and detailed analytics
- π¨ Interactive Web Interface - User-friendly Flask-based UI
- β Quality Assessment - Automatic image quality validation and recommendations
- π Benchmarking Tools - Compare model performance and accuracy metrics
- π³ Docker Support - Easy containerization and deployment
- π CSRF Protection - Secure web forms with Flask-WTF
- π Batch Processing - Analyze multiple images at once
- πΎ Export Results - Download analysis reports and visualizations
- Framework: Flask 2.3.3
- Server: Gunicorn 21.2.0
- Python: 3.11+
- Deep Learning: PyTorch
- Image Processing: OpenCV, scikit-image, Pillow
- ML Utilities: scikit-learn
- Data Processing: NumPy, SciPy, Pandas
- Plotting: Matplotlib, Seaborn
- Interactive Charts: Chart.js
- Template Engine: Jinja2
- Styling: HTML5/CSS3
- Interactivity: Vanilla JavaScript
- Containerization: Docker
- Web Server: Nginx (reverse proxy)
- Python 3.11+
- CUDA 11.8+ (for GPU acceleration)
- Docker & Docker Compose (for containerized deployment)
- 4GB+ RAM
- GPU recommended for faster inference
- Clone the repository:
git clone https://github.com/yourusername/Deep-Retina-OCT-image-analysis.git
cd Deep-Retina-OCT-image-analysis- Create a Python virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Run the Flask application:
python app.py- Open your browser and visit:
http://localhost:5000
- Build the Docker image:
docker build -f Dockerfile -t oct-analysis:latest .- Run the container:
docker run -p 5000:5000 oct-analysis:latest- Access the application at
http://localhost:5000
docker-compose up -dThe application will be available at http://localhost (via Nginx reverse proxy)
Deep-Retina-OCT-image-analysis/
βββ app.py # Flask application entry point
βββ requirements.txt # Python dependencies
βββ Dockerfile # Docker configuration
βββ docker-compose.yml # Docker Compose configuration
βββ nginx.conf # Nginx reverse proxy config
βββ templates/ # HTML templates
β βββ index.html # Main web interface
βββ static/ # Static files
β βββ css/ # Stylesheets
β βββ js/ # JavaScript files
β βββ images/ # Images and assets
βββ utils/ # Utility modules
β βββ __init__.py
β βββ preprocessing.py # Image preprocessing
β βββ model_loader.py # Model loading and management
β βββ visualization.py # Visualization generation
β βββ quality_assessment.py # Image quality metrics
β βββ benchmarking.py # Performance benchmarking
β βββ advanced_visualization.py # Advanced visualization suite
βββ README.md # This file
βββ LICENSE # MIT License
Create a .env file in the project root:
FLASK_ENV=production
FLASK_DEBUG=0
PYTHONUNBUFFERED=1
UPLOAD_FOLDER=uploads
MAX_CONTENT_LENGTH=52428800 # 50MB max file sizeModels and metadata are loaded from model_loader.py. Add custom models by:
- Adding model files to the models directory
- Registering in
get_all_model_metadata()function - Updating preprocessing pipelines if needed
- Open the web application
- Click "Upload OCT Image"
- Select an OCT image file (PNG, JPG, DICOM format)
- Choose an AI model for analysis
- Click "Analyze"
- View results, visualizations, and quality metrics
- Upload multiple images
- Select model and processing options
- Start batch analysis
- Download combined report when complete
The application automatically:
- Checks image dimensions
- Validates pixel intensity ranges
- Assesses signal-to-noise ratio
- Provides improvement recommendations
Compare model performance:
- Select multiple models
- Run on test dataset
- View confusion matrices and metrics
- Export comparison report
The application supports various deep learning models including:
- ResNet-based architectures
- Vision Transformers
- Custom medical imaging models
- Ensemble models
Add new models by modifying utils/model_loader.py
- Classification Results - Class predictions with confidence scores
- Heatmaps - Attention/activation maps showing analysis regions
- Confusion Matrix - Model performance visualization
- Quality Metrics - Image quality visualization
- ROC Curves - Model performance curves
- Statistical Reports - Detailed analysis statistics
- CSRF protection on all forms
- Secure file upload handling
- Input validation
- Error handling and logging
- Rate limiting support
- GPU acceleration support
- Image preprocessing optimization
- Batch processing capability
- Caching mechanisms
- Efficient model inference
- Average inference time: 100-500ms per image (depends on model)
- Quality assessment: < 50ms per image
- Visualization generation: 200-1000ms
GPU not detected:
# Verify CUDA installation
python -c "import torch; print(torch.cuda.is_available())"Model loading errors:
- Ensure all model files are in correct directory
- Check model compatibility with installed PyTorch version
High memory usage:
- Reduce batch size
- Enable model quantization
- Use GPU acceleration
Check application logs for debugging:
# View logs
tail -f app.log-
AWS EC2/ECS:
- Push Docker image to ECR
- Deploy using ECS or Fargate
- Configure load balancer
-
Heroku:
git push heroku main
-
DigitalOcean:
- Use App Platform
- Select Docker as deployment method
-
GCP/Azure:
- Use Cloud Run or App Service
- Configure environment variables
- Use production WSGI server (Gunicorn)
- Configure Nginx caching
- Enable GZIP compression
- Optimize image preprocessing
GET /- Main application interfacePOST /analyze- Analyze single imagePOST /batch-analyze- Batch analysisGET /results/<id>- Retrieve analysis resultsGET /benchmark- Run model benchmarkingGET /quality-check/<id>- Image quality assessment
Contributions are welcome! Areas for improvement:
- Additional ML models
- Performance optimization
- UI/UX enhancements
- New visualization types
- Documentation improvements
MIT License - Copyright (c) 2025 Abhijith Krishna G
See LICENSE file for details.
- Email: abhijithkrishnag234@gmail.com
- GitHub: @yourusername
- Medical imaging datasets and validation
- Open-source ML frameworks (PyTorch, scikit-learn)
- Computer vision libraries (OpenCV)
This application is for research and educational purposes only. It is not intended for clinical diagnosis. Always consult qualified medical professionals for medical decisions.
Made with β€οΈ by Abhijith Krishna G