This project implements a U-Net deep learning model for medical image segmentation, specifically targeting segmentation of the gastrointestinal (GI) tract from medical scans. The pipeline includes custom data preprocessing, a modular training process, and exportable predictions in Run-Length Encoding (RLE) format.
Flexible test mode for visualizing individual predictions and ground truths.
Model Architecture:
Option to load pre-trained weights for transfer learning or train from scratch.
Evaluation:
Visualization overlays for ground truths and predictions on original images.
Export:
To set up and run the project, ensure the following dependencies are installed:
- TensorFlow 2.8+
- Keras
- NumPy
- Pandas
- OpenCV
- Matplotlib
- Scikit-learn
Run the main script to train, evaluate, or export predictions:
python GI-Tract-Image-Segmentation.py
If training from scratch:
- Automatically splits the data into training, validation, and test sets.
- Implements early stopping, learning rate scheduling, and model checkpointing.
- Saves the best model weights to the output/
directory.
During evaluation, the script:
- Computes Dice coefficient and loss for each test sample.
- Visualizes predictions and overlays with ground truths.
The project includes a highly modular pipeline:
- Custom Generator:
- Decodes RLE masks into binary masks dynamically.
- Handles resizing, augmentation, and batch generation.
- Training Pipeline:
- Modularized for scalability and customization.
- Includes checkpoints and CSV logging of training metrics.