A production-ready End-to-End Machine Learning project to classify kidney diseases from CT scan images using Deep Learning. The project implements a robust MLOps pipeline, utilizing DVC for pipeline tracking, and serves the model via a Flask web application.
A production-ready pipeline for classifying kidney diseases from CT scan images, built with robust Data Version Control, Transfer Learning, and served via a Flask web application.
-
Deep Learning Model: Uses a CNN architecture (Transfer Learning with pre-trained ImageNet weights) to classify CT scan images into 2 classes.
-
MLOps Pipeline: Fully automated Data Version Control (DVC) pipeline including data ingestion, base model preparation, training, and evaluation.
-
Web Application: An interactive Flask web interface for end-users to upload images and get real-time classification results.
-
Modular Codebase: Well-structured Python codebase ready for production and easy to scale.
-
CORS Enabled: The Flask app includes CORS support for cross-origin requests if integrated with separate front-end frameworks.
Medical image classification requires rigorous tracking of data, hyperparameters, and models. This project demonstrates a complete End-to-End MLOps Lifecycle to detect kidney diseases (like tumors, cysts, or stones) from CT scan images.
Instead of a scattered Jupyter Notebook approach, this project is modular, scalable, and version-controlled using DVC (Data Version Control), making it highly reproducible for teams and ready for production deployment.
- Transfer Learning: Utilizes pre-trained ImageNet models (VGG16/ResNet) tailored for binary/multiclass classification.
- Reproducible Pipelines: Every step from data ingestion to model evaluation is tracked via DVC.
- Dynamic Configuration: Easy experimentation by simply tweaking
params.yamlandconfig.yaml. - Interactive UI: A built-in Flask web application allowing users to upload CT scans and get real-time predictions.
- Cross-Origin Ready: Flask-Cors enabled, making it easy to attach a React/Vue frontend in the future.
| Domain | Tools & Frameworks |
|---|---|
| Deep Learning | TensorFlow, Keras |
| Data Processing | NumPy, Pandas, OpenCV |
| MLOps & Tracking | DVC, MLflow |
| Backend & Serving | Flask, Flask-CORS |
| Visualization | Matplotlib, Seaborn |
The workflow is managed entirely by DVC (dvc.yaml), ensuring that changes in data or code only trigger the necessary stages.
graph TD;
A[Stage 1: Data Ingestion] --> B[Stage 2: Prepare Base Model];
B --> C[Stage 3: Model Training];
A --> C;
C --> D[Stage 4: Model Evaluation];
data_ingestion: Fetches the dataset from a remote source, unzips, and prepares it in theartifacts/directory.prepare_base_model: Downloads the VGG16/ResNet base architecture, freezes layers, and attaches custom classification heads.training: Applies data augmentation, batches data, and trains the model utilizing parameters defined inparams.yaml.evaluation: Tests the trained model against a validation set and generatesscores.json.
To get a local copy up and running, follow these simple steps.
- Python 3.8 or higher
- Git
-
Clone the repo
git clone https://github.com/Rudraksh225/kidney-classification.git cd kidney-classification -
Create and activate a virtual environment
# Windows python -m venv venv .\venv\Scripts\activate # Linux/macOS python3 -m venv venv source venv/bin/activate
-
Install dependencies
pip install -r requirements.txt
You can interact with this project in two ways: as a researcher running the pipeline, or as a user running the web interface.
If you want to train the model from scratch, alter hyperparameters, or update the dataset:
# Execute the entire MLOps pipeline
dvc reproDVC will intelligently recognize which stages need to be run based on caching.
To serve the pre-trained model and use the UI:
python app.pyOpen your browser and navigate to http://localhost:8080.
- Home (
/): Upload an image for prediction. - Train (
/train): Remotely trigger pipeline training.
Experiment tracking is incredibly simple. You do not need to dive into the python code to change model parameters.
Update params.yaml:
IMAGE_SIZE: [224, 224, 3]
BATCH_SIZE: 16
EPOCHS: 10
LEARNING_RATE: 0.01Run dvc repro after changing params, and DVC will automatically detect the changes and retrain the model!
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your 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
Distributed under the MIT License. See LICENSE for more information.