tejaswinishelke18/Alzheimers_Disease_Prediction
0
๐ง Alzheimer's MRI Detection System
An AI-powered web application for early detection of Alzheimer's disease using brain MRI scans. Built with Streamlit and TensorFlow Lite for fast, accurate predictions.
  
๐ Features
- ๐ User Authentication: Secure login/register system with password hashing
- ๐ค AI-Powered Analysis: Ensemble of three deep learning models (MobileNet, DenseNet, ResNet)
- ๐ฑ Responsive UI: Clean, modern interface optimized for all devices
- ๐ Detailed Results: Individual model predictions + ensemble voting
- ๐ History Tracking: Save and review all previous analyses
- ๐ Fast Inference: Optimized TensorFlow Lite models for quick predictions
- โ๏ธ Cloud Ready: Deployable on Streamlit Cloud, Heroku, or Hugging Face Spaces
๐ฏ Model Performance
Our ensemble approach combines three state-of-the-art models:
๐ Quick Start
Local Installation
- Clone the repository
git clone https://github.com/yourusername/alzheimer-mri-detection.git
cd alzheimer-mri-detection- Install dependencies
pip install -r requirements.txt- Add your model files
# Place your .tflite model files in the models/ directory:
# - models/mobilenet.tflite
# - models/densenet.tflite
# - models/resnet.tflite- Run the application
streamlit run app.py- Open your browser to
http://localhost:8501
๐ Online Demo
Try the live demo: **Alzheimer's MRI Detection App**
๐ Project Structure
alzheimer-mri-detection/
โ
โโโ app.py # Main Streamlit application
โโโ requirements.txt # Python dependencies
โโโ README.md # This file
โโโ setup.sh # Streamlit Cloud setup
โโโ .gitignore # Git ignore rules
โโโ runtime.txt # Python version
โ
โโโ models/ # TensorFlow Lite models
โ โโโ mobilenet.tflite
โ โโโ densenet.tflite
โ โโโ resnet.tflite
โ
โโโ data/ # Sample MRI images
โ โโโ sample_alzheimer.jpg
โ โโโ sample_normal.jpg
โ
โโโ .streamlit/ # Streamlit configuration
โโโ config.toml๐ง Configuration
Model Requirements
- Format: TensorFlow Lite (.tflite)
- Input Shape: (1, 224, 224, 3)
- Output Shape: (1, 2) - [Alzheimer's probability, Normal probability]
- Preprocessing: Images are resized to 224x224 and normalized to [0,1]
Environment Variables
For production deployment, you can set:
# Optional: Custom database path
DB_PATH=/path/to/database.db
# Optional: Models directory
MODELS_DIR=/path/to/models/
# Optional: Enable debug mode
DEBUG=True๐ Usage
1. Register/Login
- Create a new account or login with existing credentials
- All data is stored locally in SQLite database
2. Upload MRI Scan
- Supported formats: JPG, JPEG, PNG
- Optimal resolution: 224x224 pixels
- Try sample images to test the system
3. Get AI Analysis
- View individual model predictions
- See ensemble result with confidence score
- Results are automatically saved to your history
4. Review History
- Access all previous analyses
- Compare results over time
- Export data for medical consultations
๐ฅ Medical Disclaimer
โ ๏ธ IMPORTANT: This application is for educational and research purposes only. - NOT a medical diagnosis tool - NOT a substitute for professional medical advice - Always consult healthcare professionals for medical decisions - Results should be verified by qualified radiologists
๐ Deployment
Streamlit Cloud
- Fork this repository
- Connect to Streamlit Cloud
- Deploy directly from GitHub
- Add your model files to the
models/directory
Hugging Face Spaces
- Create a new Space on Hugging Face
- Choose Streamlit as the SDK
- Upload your files including model files
- Your app will be live at
https://huggingface.co/spaces/USERNAME/SPACE_NAME
Heroku
- Install Heroku CLI
- Create a new Heroku app
- Deploy using Git:
git add .
git commit -m "Deploy to Heroku"
git push heroku main๐ ๏ธ Development
Adding New Models
- Train your model using TensorFlow/Keras
- Convert to TensorFlow Lite:
converter = tf.lite.TFLiteConverter.from_keras_model(model)
tflite_model = converter.convert()
with open('new_model.tflite', 'wb') as f:
f.write(tflite_model)- Add to the ensemble in
app.py:
model_files = {
"MobileNet": MODELS_DIR / "mobilenet.tflite",
"DenseNet": MODELS_DIR / "densenet.tflite",
"ResNet": MODELS_DIR / "resnet.tflite",
"NewModel": MODELS_DIR / "new_model.tflite", # Add here
}Running Tests
# Install test dependencies
pip install pytest pytest-streamlit
# Run tests
pytest tests/๐ Performance Optimization
- TensorFlow Lite: 5-10x faster inference than full TensorFlow
- Model Quantization: Reduces model size by 75% with minimal accuracy loss
- Caching: Models and database connections are cached for faster response
- Batch Processing: Support for multiple image analysis (coming soon)
๐ค Contributing
We welcome contributions! Please see our Contributing Guidelines.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
- Dataset: Augmented Alzheimer's MRI Dataset
- Models: Based on MobileNet, DenseNet, and ResNet architectures
- Framework: Built with Streamlit and TensorFlow
๐ Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: your.email@example.com
<div align="center">
๐ง Early Detection Saves Lives | Built with โค๏ธ for Healthcare
๐ Star this repo โข ๐ Report Bug โข ๐ก Request Feature
</div>
