Skip to content

Implementation of a very lighweight U-net based encoder-decoder anchitecture and comparing its performance with Grabcut algorithm on segmentation tasks

Notifications You must be signed in to change notification settings

leopers/semantic-seg-comparison

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Image Segmentation: Classical vs Deep Learning Approaches


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.


Requirements

  • Python 3.8+
  • PyTorch
  • OpenCV
  • torchvision
  • matplotlib
  • tqdm

Install the dependencies:

pip install -r requirements.txt

Setup

Before running any scripts, set the PYTHONPATH to the project root:

export PYTHONPATH=$(pwd)

How to Run

1.Train Neural Network (The dataset will be downloaded automatically)

python methods/deep.py --mode train --plot

This will save :

  • the model in models/trained/unet.pth
  • the training metrics in outputs/training/

2. Run U-Net Prediction

python methods/deep.py --mode predict

This will save the segmentation masks in outputs/unet/


5. Run GrabCut

python methods/classical.py --all

This will save the segmentation masks in outputs/classical/


6.Evaluate Results

python evaluation/evaluate.py

This will show the metrics for each model and save the comparative histograms in:

  • outputs/classical_metrics/
  • outputs/unet_metrics/

7. Visual Comparison

python scripts/visualize.py

Saves the figure in:
outputs/visualize/visualize.pdf


Project Structure

datasets/         # Dataset loader
models/           # encoder -decoder model
methods/          # Training and classical segmentation scripts
utils/            # Metrics
evaluation/       # Evaluation pipeline
scripts/          # Visual comparison

About

Implementation of a very lighweight U-net based encoder-decoder anchitecture and comparing its performance with Grabcut algorithm on segmentation tasks

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •