Skip to content

danieletukudo/Brain_Tumor_Detection

Repository files navigation

Brain Tumor Detection Web Application and Training Pipeline

This project includes a Flask-based web application for detecting brain tumors using a pre-trained TensorFlow Lite model and a training pipeline for training the model using MRI scan images.

Web Application

The web application allows users to upload MRI scans of their brains, and the application predicts whether a tumor is present or not.

Features

  • Upload MRI scans of brain images.
  • Predict whether a brain tumor is present or not.
  • Display prediction results to the user.

Installation

  1. Clone the repository:

    git clone https://github.com/danieletukudo/Brain_Tumor_Detection.git
    
  2. Install the required dependencies:

    pip install -r requirements.txt
    
  3. Download the pre-trained TensorFlow Lite model and place it in the project directory.

Usage

  1. Run the Flask application:

    python app.py
    
  2. Open your web browser and navigate to http://localhost:7017.

  3. Upload an MRI scan image of a brain.

  4. Click the "Upload" button to make the detection.

  5. Wait for the prediction result to be displayed.

Model and Training Pipeline

The training pipeline includes data augmentation, model training, and quantization steps.

Model

The model is implemented using the VGG16 architecture, pre-trained on the ImageNet dataset. It consists of convolutional layers followed by fully connected layers. The model outputs probabilities for two classes: "No Brain Tumor Detected" and "Brain Tumor Detected".

Training Pipeline

  1. Data Augmentation: Data augmentation is performed using the ImageDataGenerator class from TensorFlow. It includes random transformations such as rotation, horizontal and vertical flips, shear, and shift.

  2. Model Training: The model is trained using the augmented data generated by the ImageDataGenerator. Training is performed using the fit method of the model, with specified number of epochs and batch size.

  3. Model Quantization: After training, the model can be quantized to reduce its size while preserving accuracy. Quantization is performed using TensorFlow Lite, which converts the model to a quantized TensorFlow Lite format.

Usage

To train the model and perform quantization, execute the training class:

if __name__ == "__main__":
    trained_model_name = "1model.h5"
    train = training()
    training = False  # Set to True to perform training

    if training:
        train.training(epochs=100, train_path="dataset/train",
                       val_path="dataset/val",
                       input_shape=(100, 100, 3),
                       trained_model_name="trained_model_name")

    train.quantize_model(trained_model_name)

Credits

  • The TensorFlow Lite model was trained using TensorFlow and converted to the TensorFlow Lite format.
  • The model and Flask web application developed by me (Daniel Etukudo).

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published