https://github.com/shervinnd/pet_segmentation_unet
A U-Net model for pet image segmentation using the Oxford-IIIT Pet dataset πΎ. Features preprocessing, training, and evaluation with IoU and ROC curves π. Perfect for computer vision enthusiasts! π
https://github.com/shervinnd/pet_segmentation_unet
computer-vision convolutional-neural-networks deep-learning image-segmentation keras machine-learning oxford-iiit-pet-dataset semantic-segmentation tensorflow unet
Last synced: 10 months ago
JSON representation
A U-Net model for pet image segmentation using the Oxford-IIIT Pet dataset πΎ. Features preprocessing, training, and evaluation with IoU and ROC curves π. Perfect for computer vision enthusiasts! π
- Host: GitHub
- URL: https://github.com/shervinnd/pet_segmentation_unet
- Owner: shervinnd
- License: mit
- Created: 2025-09-11T09:26:19.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-09-11T10:08:34.000Z (10 months ago)
- Last Synced: 2025-09-11T12:37:24.354Z (10 months ago)
- Topics: computer-vision, convolutional-neural-networks, deep-learning, image-segmentation, keras, machine-learning, oxford-iiit-pet-dataset, semantic-segmentation, tensorflow, unet
- Language: Jupyter Notebook
- Homepage:
- Size: 2.87 MB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PetSegmentationUNet πΎ
Welcome to **PetSegmentationUNet**! This project implements a U-Net
model for semantic segmentation of pet images using the Oxford-IIIT Pet
dataset π·. It segments images into three classes: pet, background, and
border, with robust preprocessing, training, and evaluation using IoU
and ROC curves π. Perfect for computer vision enthusiasts! π
## π Table of Contents
- Overview
- Features
- Installation
- Usage
- Results
- Contributing
- License
## π Overview
This project leverages a U-Net architecture to perform pixel-wise
segmentation on the Oxford-IIIT Pet dataset, which contains images of
cats and dogs with corresponding segmentation masks πΆπ±. The pipeline
includes data preprocessing, model training, evaluation with IoU and ROC
curves, and visualization of results.
## β¨ Features
- πΌοΈ **Data Preprocessing**: Resizes images and masks to 128x128,
normalizes images, and adjusts mask labels.
- π§ **U-Net Model**: A deep U-Net with encoder-decoder architecture
for accurate segmentation.
- π **Evaluation**: Computes IoU scores and ROC curves for each class
(pet, background, border).
- ποΈ **Visualization**: Displays input images, ground truth masks, and
predicted masks.
- πΎ **Model Saving**: Saves the trained model in HDF5 format.
## π οΈ Installation
1. **Clone the Repository**:
``` bash
git clone https://github.com/shervinnd/PetSegmentationUNet.git
cd PetSegmentationUNet
```
2. **Install Dependencies**: Ensure Python 3.8+ is installed, then run:
``` bash
pip install tensorflow tensorflow-datasets numpy matplotlib scikit-learn
```
3. **Verify TensorFlow**:
``` python
import tensorflow as tf
print(tf.__version__)
```
## π Usage
1. **Run the Pipeline**: Execute the scripts in order (provided as
separate Python files):
- `01_load_dataset.py`: Load the Oxford-IIIT Pet dataset π.
- `02_preprocess_dataset.py`: Preprocess images and masks πΌοΈ.
- `03_unet_model.py`: Define and compile the U-Net model π§ .
- `04_train_model.py`: Train the model for 10 epochs π.
- `05_evaluate_visualize.py`: Evaluate and visualize predictions
π.
- `06_calculate_iou_roc.py`: Compute IoU and ROC curves π.
- `07_save_model.py`: Save the trained model πΎ.
Run each script:
``` bash
python 01_load_dataset.py
python 02_preprocess_dataset.py
# ... and so on
```
2. **Expected Output**:
- Model summary with \~31M parameters.
- Training logs with loss and accuracy.
- Test accuracy and IoU scores per class (pet, background,
border).
- ROC curves with AUC scores for each class.
- Visualizations of images, masks, and predictions.
## π Results
- **Dataset**: Oxford-IIIT Pet with 3680 training and 3669 test
images.
- **Model**: U-Net with 3 output classes (pet, background, border).
- **Metrics**:
- IoU scores (example): `[0.6, 0.8, 0.4]` for pet, background,
border.
- ROC AUC scores (example): `[0.85, 0.90, 0.70]` for each class.
- **Visualizations**: Sample images, ground truth masks, and predicted
masks displayed in a 3x3 grid.
## π€ Contributing
Contributions are welcome! π To contribute:
1. Fork the repository.
2. Create a feature branch (`git checkout -b feature`).
3. Commit changes (`git commit -m`).
4. Push to the branch (`git push origin feature`).
5. Open a Pull Request.
Suggestions for improvement:
- Add data augmentation πΈ.
- Implement weighted loss for class imbalance βοΈ.
- Experiment with deeper architectures or learning rate schedules β³.
## π License
This project is licensed under the MIT License. See the LICENSE file for
details.\
\
***Powerd by Miracleβ‘***