# dhruvak001/image-segmentation-suite-classical-deep-learning-united architecture

> Architecture diagram of the GitHub repository dhruvak001/image-segmentation-suite-classical-deep-learning-united, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dhruvak001/image-segmentation-suite-classical-deep-learning-united
- Repository: https://github.com/dhruvak001/image-segmentation-suite-classical-deep-learning-united

## Overview

##### Project type and purpose
- This is a Python‐based interactive image segmentation toolkit that presents a Gradio web UI for comparing multiple segmentation algorithms. It is neither a distributed microservices system nor a multi‐tiered enterprise app—it's a modular monolith with a UI layer, a core algorithm library, model storage, and external dependencies.

##### File structure
- Top level:
- app.py – entry point and Gradio interface controller
- requirements.txt – dependency list
- saved_models/ – pretrained PyTorch weights (SegNet variants)
- experiments/ – contains all segmentation algorithm implementations:
- Classical methods: otsu_segmenter.py, kmeans_segmenter.py, enhanced_kmeans_segmenter.py (SLIC), watershed_segmenter.py, felzenszwalb_segmentation package
- Deep learning: experiments/SegNet/{efficient_b0_backbone, vgg_backbone}
- ensemble_method.py – combines outputs of classical + DL modules

##### README for additional insights
- The README confirms the two algorithm categories (classical vs. DL) and an ensemble strategy that merges boundary cues from classical methods with semantic labels from SegNet. It highlights PyTorch, OpenCV, NumPy, PIL, Matplotlib, and Gradio as the technology stack.

##### Detail level
- Related modules under a “Classical Methods” cluster and a “Deep Learning Methods” cluster.
- Ensemble module taking inputs from both clusters.
- External dependencies at the boundary of the system to highlight their use by the algorithm modules.

## Diagram (Mermaid)

```mermaid
flowchart TD
    User["User"]:::user
    GradioUI["Gradio UI"]:::ui
    subgraph "UI Layer"
        GradioUI
    end

    subgraph "Core Algorithm Layer"
        subgraph "Classical Methods"
            Otsu["Otsu Thresholding"]:::classical
            KMeans["K-Means Clustering"]:::classical
            EnhancedK["Enhanced K-Means (SLIC)"]:::classical
            Watershed["Watershed Transform"]:::classical
            Felzenszwalb["Felzenszwalb Segmentation"]:::classical
        end
        subgraph "Deep Learning Methods"
            SegNetEff["SegNet w/ EfficientNet-B0"]:::deep
            SegNetVGG["SegNet w/ VGG16"]:::deep
        end
        Ensemble["Ensemble Module"]:::ensemble
    end

    Storage["Model Storage"]:::storage

    subgraph "External Libraries"
        PyTorch["PyTorch"]:::external
        OpenCV["OpenCV"]:::external
        NumPy["NumPy"]:::external
        PIL["PIL"]:::external
        Matplotlib["Matplotlib"]:::external
    end

    User -->|submit image & choose method| GradioUI
    GradioUI -->|route request| Otsu
    GradioUI -->|route request| KMeans
    GradioUI -->|route request| EnhancedK
    GradioUI -->|route request| Watershed
    GradioUI -->|route request| Felzenszwalb
    GradioUI -->|route request| SegNetEff
    GradioUI -->|route request| SegNetVGG
    GradioUI -->|route request| Ensemble

    Otsu -->|segment image| OpenCV
    KMeans -->|segment image| OpenCV
    EnhancedK -->|segment image| OpenCV
    Watershed -->|segment image| OpenCV
    Felzenszwalb -->|segment image| OpenCV

    SegNetEff -->|load model| Storage
    SegNetVGG -->|load model| Storage
    SegNetEff -->|inference| PyTorch
    SegNetVGG -->|inference| PyTorch

    Otsu -->|return mask| GradioUI
    KMeans -->|return mask| GradioUI
    EnhancedK -->|return mask| GradioUI
    Watershed -->|return mask| GradioUI
    Felzenszwalb -->|return mask| GradioUI
    SegNetEff -->|return mask| GradioUI
    SegNetVGG -->|return mask| GradioUI

    Otsu -->|input| Ensemble
    KMeans -->|input| Ensemble
    EnhancedK -->|input| Ensemble
    Watershed -->|input| Ensemble
    Felzenszwalb -->|input| Ensemble
    SegNetEff -->|input| Ensemble
    SegNetVGG -->|input| Ensemble

    Ensemble -->|combine & return| GradioUI
    Ensemble -->|use libraries| PyTorch
    Ensemble -->|use libraries| OpenCV

    click GradioUI "https://github.com/dhruvak001/image-segmentation-suite-classical-deep-learning-united/blob/main/app.py"
    click Otsu "https://github.com/dhruvak001/image-segmentation-suite-classical-deep-learning-united/blob/main/experiments/otsu_segmenter.py"
    click KMeans "https://github.com/dhruvak001/image-segmentation-suite-classical-deep-learning-united/blob/main/experiments/kmeans_segmenter.py"
    click EnhancedK "https://github.com/dhruvak001/image-segmentation-suite-classical-deep-learning-united/blob/main/experiments/enhanced_kmeans_segmenter.py"
    click Watershed "https://github.com/dhruvak001/image-segmentation-suite-classical-deep-learning-united/blob/main/experiments/watershed_segmenter.py"
    click Felzenszwalb "https://github.com/dhruvak001/image-segmentation-suite-classical-deep-learning-united/tree/main/experiments/felzenszwalb_segmentation/"
    click SegNetEff "https://github.com/dhruvak001/image-segmentation-suite-classical-deep-learning-united/tree/main/experiments/SegNet/efficient_b0_backbone/"
    click SegNetVGG "https://github.com/dhruvak001/image-segmentation-suite-classical-deep-learning-united/tree/main/experiments/SegNet/vgg_backbone/"
    click Ensemble "https://github.com/dhruvak001/image-segmentation-suite-classical-deep-learning-united/blob/main/experiments/ensemble_method.py"
    click Storage "https://github.com/dhruvak001/image-segmentation-suite-classical-deep-learning-united/tree/main/saved_models/"

    classDef user fill:#f0f0f0,stroke:#333,stroke-width:1px
    classDef ui fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef classical fill:#90EE90,stroke:#333,stroke-width:1px
    classDef deep fill:#20B2AA,stroke:#333,stroke-width:1px
    classDef ensemble fill:#FFFF99,stroke:#333,stroke-width:1px
    classDef storage fill:#FFA500,stroke:#333,stroke-width:1px
    classDef external fill:#D8BFD8,stroke:#333,stroke-width:1px
```
