This project focuses on the segmentation of the Left Ventricle (LV) in medical images using a U-Net model, a type of convolutional neural network designed for image segmentation tasks. The goal is to accurately identify and delineate the LV region in cardiac images, which is crucial for various diagnostic and therapeutic applications. By leveraging the U-Net architecture, this notebook guides you through the entire process, from data loading and preprocessing to model training, evaluation, and visualization of results.
This notebook demonstrates the process of Left Ventricle (LV) segmentation using a U-Net model. The steps include:
- Mounting Google Drive: Accessing the dataset stored in Google Drive.
- Cloning the Repository: Downloading the necessary code and data from a GitHub repository.
- Installing Packages: Installing required Python packages for segmentation models.
- Setting Environment Variables: Configuring environment variables for TensorFlow Keras.
- Importing Libraries: Importing essential libraries for data processing, model building, and visualization.
- Loading and Preprocessing Data: Loading images and masks, applying data augmentation, and creating TensorFlow datasets.
- Defining the U-Net Model: Setting model parameters, defining, compiling, and summarizing the U-Net model.
- Training the Model: Training the model on the training dataset and validating it on the validation dataset.
- Saving the Model: Saving the trained model for future use.
- Evaluating the Model: Evaluating the model's performance using the Mean Intersection over Union (IoU) metric.
- Testing on Random Images: Testing the model on random images from the validation dataset and visualizing the results.
Notably, the model achieved a Mean Intersection over Union (IoU) of 91.8% on the test data, demonstrating its high accuracy and effectiveness.
The dataset that I have used for this project is located in this GitHub repository, and you can use the following command to get it:
git clone https://github.com/alandgabriel/LV-Segmentation-with-U-Net.git
To run this notebook, you need to have Python and the following packages installed:
- TensorFlow
- segmentation-models
- numpy
- matplotlib
- glob
- random
- os
You can install the required packages using the following commands:
pip install tensorflow
pip install segmentation-models
pip install numpy==1.23
pip install matplotlib
-
Clone the repository:
git clone https://github.com/4prince8/LV-Segmentation-with-U-Net.git cd LV-Segmentation-with-U-Net
-
Open the Jupyter notebook:
jupyter notebook LV_Segmentation.ipynb
-
Run the notebook: Follow the steps in the notebook to mount Google Drive, install necessary packages, load and preprocess data, define and train the model, and evaluate the results.
LV-Segmentation-with-U-Net/
├── DATA/
│ ├── frames/
│ └── masks/
├── LV_Segmentation.ipynb
└── README.md
DATA/
: Directory containing the image frames and masks.LV_Segmentation_with_U_Net.ipynb
: Jupyter notebook with the complete code for LV segmentation.README.md
: This file.
The model achieved a Mean Intersection over Union (IoU) of 91.8% on the test data, demonstrating its high accuracy and effectiveness. Below are some sample results:
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.