Spaces:
Build error
Build error
File size: 4,714 Bytes
7ac57e1 0f9608b 7ac57e1 0f9608b 7ac57e1 0f9608b 7ac57e1 0f9608b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
---
title: Image_Segmentation_
app_file: app.py
sdk: gradio
sdk_version: 5.23.1
---
# Image Segmentation Toolkit
## Overview
This project implements a comprehensive image segmentation toolkit that combines classical computer vision techniques with deep learning-based approaches. The application provides an interactive interface to compare different segmentation algorithms on user-provided images.
## Features
- **Classical Segmentation Methods**:
- Otsu's Thresholding: Optimal global thresholding for binary segmentation
- K-means Clustering: Color-based segmentation with adjustable clusters
- SLIC (Simple Linear Iterative Clustering): Superpixel segmentation
- Watershed Algorithm: Gradient-based segmentation for separating touching objects
- Felzenszwalb Algorithm: Graph-based segmentation with adaptive thresholding
- **Deep Learning Models**:
- SegNet with EfficientNet B0 backbone: Pretrained semantic segmentation model
- SegNet with VGG backbone: Alternative architecture for comparison
- **Ensemble Methods**:
- Otsu + SegNet: Combining boundary information from Otsu with semantic labels from SegNet
- Custom ensemble segmentation with adjustable parameters
## Installation
### Prerequisites
- Python 3.8+
- PyTorch 1.10+
- CUDA-compatible GPU (recommended)
### Setup
1. Clone the repository:
```bash
git clone https://github.com/yourusername/CSL7360_Project.git
cd CSL7360_Project
```
2. Create and activate a virtual environment (optional but recommended):
```bash
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
```
3. Install required packages:
```bash
pip install -r requirements.txt
```
4. Download pretrained models:
```bash
python download_models.py
```
The application will also automatically download models when first launched.
## Usage
### Running the Application
Start the Gradio web interface:
```bash
python app.py
```
The interface will be available at http://127.0.0.1:7860 in your web browser.
### Using the Interface
1. Select a segmentation method from the tabs at the top
2. Upload an image using the file picker
3. Adjust algorithm parameters if available
4. Click the "Segment this image" button
5. View the results in the display area
### Algorithm Parameters
#### Otsu's Method
- No parameters, fully automatic threshold selection
#### K-means Segmentation
- **Number of Clusters (K)**: Controls how many color groups to segment into
#### SLIC Segmentation
- **Number of superpixels**: Controls the granularity of segmentation
- **Compactness factor**: Controls how much superpixels adhere to boundaries
- **Number of iterations**: Controls refinement of superpixel boundaries
#### Felzenszwalb Algorithm
- **Sigma**: Gaussian pre-processing smoothing parameter
- **K value**: Controls segment size preference
- **Min Size Factor**: Minimum component size
#### Ensemble Segmentation
- **Boundary Refinement Weight**: Controls influence of classical methods on deep learning boundaries
## Project Structure
```
CSL7360_Project/
βββ app.py # Main application with pretrained models
βββ experiments/ # Implementation of segmentation algorithms
β βββ ensemble_method.py # Ensemble segmentation implementation
β βββ felzenszwalb_segmentation/ # Felzenszwalb algorithm implementation
β βββ kmeans_segmenter.py # K-means segmentation implementation
β βββ enhanced_kmeans_segmenter.py # SLIC implementation
β βββ otsu_segmenter.py # Otsu thresholding implementation
β βββ watershed_segmenter.py # Watershed algorithm implementation
β βββ SegNet/ # Deep learning models
β βββ efficient_b0_backbone/ # EfficientNet backbone for SegNet
β βββ vgg_backbone/ # VGG backbone for SegNet
βββ saved_models/ # Directory for pretrained weights
βββ requirements.txt # Package dependencies
```
## Examples
The application works well on a variety of images:
- Natural scenes
- Urban environments
- Medical images
- Aerial/satellite imagery
- Objects with clear boundaries
## Technologies Used
- **PyTorch**: Deep learning framework
- **OpenCV**: Classical computer vision algorithms
- **NumPy**: Numerical computations
- **PIL/Pillow**: Image loading and manipulation
- **Gradio**: Interactive web interface
- **Matplotlib**: Visualization of results
## Credits
- Built as part of CSL7360 course project
- Uses pretrained models based on Pascal VOC and CamVid datasets
- Implements algorithms from classical computer vision literature
## License
This project is available under the MIT License. |