Skip to content

vams2krish/Kidney-prediction-deep-learning

Repository files navigation

Python TensorFlow Flask MLflow DVC License Docker Deep Learning


KidneyScan AI Logo

πŸ₯ Kidney CT Scan Classification Project

AI-Powered Medical Image Classification using Deep Learning


πŸ“‹ Table of Contents


πŸ“– Overview

KidneyScan AI is an end-to-end deep learning pipeline for classifying kidney CT scan images as either "Tumor" or "Normal". The project leverages transfer learning with the VGG16 pre-trained model to achieve accurate medical image classification.

This production-ready application includes:

  • πŸ”„ Automated ML pipeline orchestration with DVC
  • πŸ“ˆ Experiment tracking with MLflow
  • 🌐 RESTful API with Flask
  • 🎨 Modern, responsive web interface
  • 🐳 Docker containerization support

⚠️ Disclaimer: This model is for educational and research purposes only. It should NOT be used as a substitute for professional medical diagnosis.


✨ Key Features

Feature Description
πŸ”¬ Medical Image Classification Classify kidney CT scans as Tumor or Normal using deep learning
🧠 Transfer Learning Utilizes VGG16 pre-trained on ImageNet for feature extraction
πŸ“Š Experiment Tracking Full MLflow integration for metrics, parameters, and model versioning
πŸ”„ Pipeline Automation DVC-powered reproducible ML pipeline from data ingestion to evaluation
🌐 REST API Flask-based API for seamless integration with other applications
πŸ’« Modern UI Beautiful, responsive web interface with drag-and-drop functionality
🐳 Containerization Docker support for easy deployment and scaling
⚑ Lazy Model Loading Efficient memory usage with on-demand model loading

πŸ› οΈ Tech Stack

πŸ€– Machine Learning & Deep Learning

TensorFlow Keras NumPy Pandas Matplotlib

🌐 Web Development

Flask HTML5 CSS3 JavaScript

πŸ”§ MLOps & DevOps

MLflow DVC Docker AWS

πŸ“¦ Python Libraries

  • python-box - Configuration management
  • pyYAML - YAML file handling
  • gdown - Google Drive file downloads
  • tqdm - Progress bars
  • joblib - Model serialization

πŸ—οΈ Project Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                           KIDNEY CT SCAN CLASSIFIER                         β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                              β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”       β”‚
β”‚  β”‚   DATA SOURCE   β”‚     β”‚   DATA SOURCE   β”‚     β”‚   DATA SOURCE   β”‚       β”‚
β”‚  β”‚  (Google Drive) │────▢│   (DVC Cache)    │────▢│  (Training)     β”‚       β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜       β”‚
β”‚         β”‚                                               β”‚                   β”‚
β”‚         β–Ό                                               β–Ό                   β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”‚
β”‚  β”‚                        DVC PIPELINE                           β”‚         β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β” β”‚         β”‚
β”‚  β”‚  β”‚  Stage 01   │─▢│   Stage 02   │─▢│  Stage 03  │─▢│ Stage β”‚ β”‚         β”‚
β”‚  β”‚  β”‚Data Ingestionβ”‚  β”‚Prepare Base  β”‚  β”‚  Training  β”‚  β”‚   04  β”‚ β”‚         β”‚
β”‚  β”‚  β”‚              β”‚  β”‚    Model     β”‚  β”‚            β”‚  β”‚ Eval  β”‚ β”‚         β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚         β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜         β”‚
β”‚                                    β”‚                                        β”‚
β”‚                                    β–Ό                                        β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”        β”‚
β”‚  β”‚                        MLflow Tracking                           β”‚        β”‚
β”‚  β”‚  πŸ“Š Metrics β”‚ πŸ“ˆ Parameters β”‚ πŸ“¦ Model Registry β”‚ πŸ•’ Runs    β”‚        β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜        β”‚
β”‚                                    β”‚                                        β”‚
β”‚                                    β–Ό                                        β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”        β”‚
β”‚  β”‚                    FLASK WEB APPLICATION                         β”‚        β”‚
β”‚  β”‚                                                                  β”‚        β”‚
β”‚  β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚        β”‚
β”‚  β”‚   β”‚   /train    β”‚  β”‚  /predict   β”‚  β”‚     / (Home)            β”‚ β”‚        β”‚
β”‚  β”‚   β”‚  (API)      β”‚  β”‚   (API)     β”‚  β”‚   (Web Interface)       β”‚ β”‚        β”‚
β”‚  β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚        β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜        β”‚
β”‚                                    β”‚                                        β”‚
β”‚                                    β–Ό                                        β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”        β”‚
β”‚  β”‚                      FRONTEND (HTML/CSS/JS)                      β”‚        β”‚
β”‚  β”‚  🎨 Drag & Drop β”‚ πŸ“· Image Preview β”‚ πŸ“Š Results Display        β”‚        β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜        β”‚
β”‚                                                                              β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Pipeline Stages

  1. Data Ingestion (stage_01_data_ingestion.py)

    • Downloads dataset from Google Drive
    • Extracts and organizes CT scan images
    • Version control with DVC
  2. Prepare Base Model (stage_02_prepare_base_model.py)

    • Loads VGG16 pre-trained on ImageNet
    • Removes top classification layers
    • Configures for transfer learning
  3. Model Training (stage_03_model_training.py)

    • Trains custom classification head
    • Applies data augmentation
    • Logs parameters and metrics to MLflow
    • Saves trained model
  4. Model Evaluation (stage_04_model_evaluation.py)

    • Evaluates model on test set
    • Calculates loss and accuracy
    • Logs metrics to MLflow
    • Saves evaluation scores

πŸ“ Project Structure

kidney-prediction-deep-learning/
β”‚
β”œβ”€β”€ πŸ“„ app.py                          # Flask web application entry point
β”œβ”€β”€ πŸ“„ main.py                         # Direct pipeline execution script
β”œβ”€β”€ πŸ“„ dvc.yaml                        # DVC pipeline definition
β”œβ”€β”€ πŸ“„ params.yaml                     # Hyperparameters and configuration
β”œβ”€β”€ πŸ“„ config/
β”‚   └── config.yaml                    # Application configuration
β”‚
β”œβ”€β”€ πŸ“„ requirements.txt                # Python dependencies
β”œβ”€β”€ πŸ“„ setup.py                        # Package setup configuration
β”œβ”€β”€ πŸ“„ Dockerfile                      # Docker container configuration
β”‚
β”œβ”€β”€ πŸ“‚ src/
β”‚   └── cnnClassifer/
β”‚       β”œβ”€β”€ πŸ“‚ components/              # ML pipeline components
β”‚       β”‚   β”œβ”€β”€ data_ingestion.py      # Data download & extraction
β”‚       β”‚   β”œβ”€β”€ prepare_base_model.py  # VGG16 base model setup
β”‚       β”‚   β”œβ”€β”€ model_training.py      # Model training logic
β”‚       β”‚   └── model_evaluation_mlflow.py  # Evaluation with MLflow
β”‚       β”‚
β”‚       β”œβ”€β”€ πŸ“‚ pipeline/                # Pipeline stage executors
β”‚       β”‚   β”œβ”€β”€ stage_01_data_ingestion.py
β”‚       β”‚   β”œβ”€β”€ stage_02_prepare_base_model.py
β”‚       β”‚   β”œβ”€β”€ stage_03_model_training.py
β”‚       β”‚   β”œβ”€β”€ stage_04_model_evaluation.py
β”‚       β”‚   └── prediction.py          # Prediction pipeline
β”‚       β”‚
β”‚       β”œβ”€β”€ πŸ“‚ config/                  # Configuration management
β”‚       β”‚   └── configuration.py        # Config manager class
β”‚       β”‚
β”‚       β”œβ”€β”€ πŸ“‚ entity/                   # Data entities
β”‚       β”‚   └── config_entity.py        # Configuration entities
β”‚       β”‚
β”‚       β”œβ”€β”€ πŸ“‚ utils/                    # Utility functions
β”‚       β”‚   └── Common.py               # Common utilities
β”‚       β”‚
β”‚       β”œβ”€β”€ πŸ“‚ constants/               # Constants
β”‚       β”‚   └── __init__.py
β”‚       β”‚
β”‚       └── πŸ“‚ __init__.py              # Package initializer
β”‚
β”œβ”€β”€ πŸ“‚ model/
β”‚   └── model.h5                        # Trained Keras model
β”‚
β”œβ”€β”€ πŸ“‚ templates/
β”‚   └── index.html                      # Frontend web interface
β”‚
β”œβ”€β”€ πŸ“‚ research/
β”‚   β”œβ”€β”€ 01_data_ingestion.ipynb         # Data exploration notebook
β”‚   β”œβ”€β”€ 02_prepare_base_model.ipynb     # Base model notebook
β”‚   β”œβ”€β”€ 03_model_training.ipynb         # Training notebook
β”‚   β”œβ”€β”€ 04_model_evaluation_with_mlflow.ipynb  # Evaluation notebook
β”‚   └── trials.ipynb                    # Experiment trials
β”‚
β”œβ”€β”€ πŸ“‚ artifacts/                       # ML pipeline outputs
β”‚   β”œβ”€β”€ data_ingestion/                 # Downloaded dataset
β”‚   β”œβ”€β”€ prepare_base_model/             # Base model files
β”‚   └── training/                       # Trained model files
β”‚
β”œβ”€β”€ πŸ“‚ logs/                            # Application logs
β”‚   └── (log files)
β”‚
β”œβ”€β”€ πŸ“‚ mlruns/                          # MLflow tracking data
β”‚   └── 0/
β”‚       └── meta.yaml
β”‚
β”œβ”€β”€ πŸ“„ scores.json                      # Evaluation metrics
β”œβ”€β”€ πŸ“„ dvc.lock                         # DVC lock file
β”œβ”€β”€ πŸ“„ LICENSE                          # MIT License
└── πŸ“„ .gitignore                       # Git ignore file

πŸš€ Quick Start

Prerequisites

Requirement Version Description
🐍 Python 3.8+ Programming language
🐳 Docker 20.10+ Containerization (optional)
πŸ’Ύ GPU CUDA 11.8+ For faster training (optional)

One-Line Installation & Run

# Clone the repository
git clone https://github.com/vams2krish/Kidney-Disease-Classification-MLflow-DVC.git
cd Kidney-Disease-Classification-MLflow-DVC

# Install dependencies
pip install -r requirements.txt

# Start the web application
python app.py

Then open your browser and navigate to: http://localhost:8080


πŸ“¦ Installation

1. Clone the Repository

git clone https://github.com/vams2krish/Kidney-Disease-Classification-MLflow-DVC.git
cd Kidney-Disease-Classification-MLflow-DVC

2. Create Virtual Environment (Recommended)

# Create virtual environment
python -m venv venv

# Activate on Windows
venv\Scripts\activate

# Activate on Linux/Mac
source venv/bin/activate

3. Install Dependencies

pip install -r requirements.txt

4. Verify Installation

python -c "import tensorflow; import flask; import mlflow; print('All packages installed successfully!')"

πŸ’» Usage

Running the ML Pipeline

Option 1: Using DVC (Recommended)

# Run the complete ML pipeline
dvc repro

Option 2: Using main.py

# Run pipeline directly
python main.py

Option 3: Run Individual Stages

# Stage 1: Data Ingestion
python src/cnnClassifer/pipeline/stage_01_data_ingestion.py

# Stage 2: Prepare Base Model
python src/cnnClassifer/pipeline/stage_02_prepare_base_model.py

# Stage 3: Model Training
python src/cnnClassifer/pipeline/stage_03_model_training.py

# Stage 4: Model Evaluation
python src/cnnClassifer/pipeline/stage_04_model_evaluation.py

Starting the Web Application

# Start Flask app (default port: 8080)
python app.py

# Or specify custom port
python app.py --port 5000

The web interface will be available at: http://localhost:8080

Making Predictions

Using cURL

curl -X POST http://localhost:8080/predict \
  -H "Content-Type: application/json" \
  -d '{"image": "<base64_encoded_image>"}'

Using Python

import base64
import requests

# Read and encode image
with open("test_image.jpg", "rb") as f:
    image_data = base64.b64encode(f.read()).decode('utf-8')

# Make prediction
response = requests.post(
    "http://localhost:8080/predict",
    json={"image": image_data}
)

print(response.json())

Using the Web Interface

  1. Open http://localhost:8080 in your browser
  2. Drag and drop a CT scan image or click to browse
  3. Click "Analyze CT Scan"
  4. View the prediction results

Training via API

# Trigger training pipeline via API
curl -X GET http://localhost:8080/train

# Or using Python
import requests
response = requests.get("http://localhost:8080/train")
print(response.text)  # "Training done successfully!"

πŸ”Œ API Documentation

Base URL

http://localhost:8080

Endpoints

Method Endpoint Description Request Body Response
GET / Home page - HTML page
GET /train Trigger training - String
POST /predict Make prediction {"image": "<base64>"} JSON

Response Formats

Prediction Response

[
  {
    "image": "Normal"
  }
]

Or with error:

{
  "error": "Error message here"
}

Error Codes

Code Description
200 Success
400 Bad Request - No image provided
500 Internal Server Error

🐳 Docker Deployment

Building the Docker Image

# Build the image
docker build -t kidney-scan-classifier:latest .

Running the Container

# Run the container
docker run -d -p 8080:8080 --name kidney-classifier kidney-scan-classifier:latest

# View logs
docker logs -f kidney-classifier

# Stop the container
docker stop kidney-classifier

Using Docker Compose

# docker-compose.yml
version: '3.8'

services:
  kidney-classifier:
    build: .
    ports:
      - "8080:8080"
    environment:
      - PYTHONUNBUFFERED=1
    volumes:
      - ./model:/app/model
      - ./artifacts:/app/artifacts
# Start with docker-compose
docker-compose up -d

Deployment to Cloud

AWS ECS

# Build and push to ECR
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin <account>.dkr.ecr.us-east-1.amazonaws.com
docker build -t kidney-classifier .
docker tag kidney-classifier:latest <account>.dkr.ecr.us-east-1.amazonaws.com/kidney-classifier:latest
docker push <account>.dkr.ecr.us-east-1.amazonaws.com/kidney-classifier:latest

Heroku

# Using Heroku Container Registry
heroku login
heroku create kidney-classifier
heroku container:push web -a kidney-classifier
heroku container:release web -a kidney-classifier

πŸ”§ Configuration

params.yaml

# Model Configuration
IMAGE_SIZE: [224, 224, 3]        # VGG16 standard input size
BATCH_SIZE: 16                   # Training batch size
EPOCHS: 10                       # Number of training epochs
CLASSES: 2                       # Number of output classes
WEIGHTS: imagenet                # Pre-trained weights
LEARNING_RATE: 0.01              # Initial learning rate
INCLUDE_TOP: False               # Exclude top layers
AUGMENTATION: True               # Enable data augmentation

config/config.yaml

artifacts_root: artifacts

data_ingestion:
  root_dir: artifacts/data_ingestion
  source_URL: https://drive.google.com/uc?id=<FILE_ID>
  local_data_file: artifacts/data_ingestion/data.zip
  unzip_dir: artifacts/data_ingestion

prepare_base_model:
  root_dir: artifacts/prepare_base_model
  base_model_path: artifacts/prepare_base_model/base_model.h5
  updated_base_model_path: artifacts/prepare_base_model/base_model_updated.h5

training:
  root_dir: artifacts/training
  trained_model_path: artifacts/training/model.h5

Environment Variables

Variable Default Description
PYTHONUNBUFFERED 1 Unbuffered Python output
LANG en_US.UTF-8 Language setting
LC_ALL en_US.UTF-8 Locale setting
MLFLOW_TRACKING_URI - MLflow tracking server URI

πŸ“Š Model Details

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   VGG16 Backbone                    β”‚
β”‚  (Pre-trained on ImageNet, weights frozen)         β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Input: 224 x 224 x 3 (RGB Image)                   β”‚
β”‚                                                     β”‚
β”‚  Block 1: Conv2D(64) Γ— 2 β†’ MaxPool                  β”‚
β”‚  Block 2: Conv2D(128) Γ— 2 β†’ MaxPool                 β”‚
β”‚  Block 3: Conv2D(256) Γ— 3 β†’ MaxPool                 β”‚
β”‚  Block 4: Conv2D(512) Γ— 3 β†’ MaxPool                 β”‚
β”‚  Block 5: Conv2D(512) Γ— 3 β†’ MaxPool                 β”‚
β”‚                                                     β”‚
β”‚  Output: 7 Γ— 7 Γ— 512                                β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚              Custom Classification Head             β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚
β”‚  β”‚  GlobalAveragePooling2D                      β”‚    β”‚
β”‚  β”‚  Dense(512, activation='relu')               β”‚    β”‚
β”‚  β”‚  Dropout(0.5)                                β”‚    β”‚
β”‚  β”‚  Dense(2, activation='softmax')              β”‚    β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚
β”‚                                                     β”‚
β”‚  Output: [Probability_Tumor, Probability_Normal]   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Training Configuration

Parameter Value
Optimizer Adam
Initial Learning Rate 0.01
Loss Function Categorical Crossentropy
Batch Size 16
Epochs 10
Image Size 224 Γ— 224 Γ— 3
Data Augmentation Yes (rotation, flip, zoom)

Dataset

  • Source: Kidney CT Scan Image Dataset
  • Classes: 2 (Tumor, Normal)
  • Split: Training, Validation, Test
  • Augmentation: Random horizontal flip, rotation, zoom

πŸ§ͺ Testing

Running Tests

# Run all tests
pytest tests/

# Run specific test file
pytest tests/test_prediction.py -v

# Run with coverage
pytest --cov=src tests/

Manual Testing

# Test data ingestion
python -c "from cnnClassifer.components.data_ingestion import DataIngestion; print('DataIngestion imported successfully')"

# Test configuration
python -c "from cnnClassifer.config.configuration import ConfigurationManager; print('Config imported successfully')"

# Test prediction pipeline
python -c "from cnnClassifer.pipeline.prediction import PredictionPipeline; print('PredictionPipeline imported successfully')"

πŸ“ˆ Results

Model Performance

Metric Value
Loss 22.63
Accuracy 48.2%

⚠️ Note: The current model performance can be improved with:

  • More training data
  • Extended training epochs
  • Hyperparameter tuning
  • Advanced architectures (ResNet, EfficientNet)
  • Learning rate scheduling

MLflow Tracking

To view experiment tracking:

# Start MLflow UI
mlflow ui

# Open browser at http://localhost:5000

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Development Workflow

# Fork the repository
# Create your feature branch
git checkout -b feature/AmazingFeature

# Make your changes
git commit -m 'Add some AmazingFeature'
git push origin feature/AmazingFeature

# Open a Pull Request

Coding Standards

  • Follow PEP 8 style guide
  • Write docstrings for all functions
  • Add type hints where applicable
  • Include unit tests for new features

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

MIT License

Copyright (c) 2024 KidneyScan AI

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

πŸ™ Acknowledgments


πŸ“§ Contact

Contact Details
πŸ‘€ Author Adam, Vamshi Krishna
πŸ“§ Email adam.vamshikrishna@gmail.com
πŸ”— GitHub vams2krish
πŸ’Ό LinkedIn Adam, Vamshi Krishna

⭐ Show Your Support

If you found this project helpful, please give it a ⭐ on GitHub!


Made with ❀️ by Adam Vamshi Krishna

GitHub stars GitHub forks Twitter Follow


Last updated: January 2024

About

Medical Project Implementation from End to End using python, MLflow, Dagshub and DVC tools [Deep learning]

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors