This project presents a comparative study between two binary semantic segmentation approaches applied to the Oxford-IIIT Pet Dataset:
(1) a classical approach based on OpenCV's GrabCut algorithm, and
(2) a convolutional encoder-decoder architecture implemented in PyTorch.
- Python 3.8+
- PyTorch
- OpenCV
- torchvision
- matplotlib
- tqdm
Install the dependencies:
pip install -r requirements.txt
Before running any scripts, set the PYTHONPATH
to the project root:
export PYTHONPATH=$(pwd)
python methods/deep.py --mode train --plot
This will save :
- the model in
models/trained/unet.pth
- the training metrics in
outputs/training/
python methods/deep.py --mode predict
This will save the segmentation masks in outputs/unet/
python methods/classical.py --all
This will save the segmentation masks in outputs/classical/
python evaluation/evaluate.py
This will show the metrics for each model and save the comparative histograms in:
outputs/classical_metrics/
outputs/unet_metrics/
python scripts/visualize.py
Saves the figure in:
outputs/visualize/visualize.pdf
datasets/ # Dataset loader
models/ # encoder -decoder model
methods/ # Training and classical segmentation scripts
utils/ # Metrics
evaluation/ # Evaluation pipeline
scripts/ # Visual comparison