# orsopranav/cv_project_sem_6 architecture

> Architecture diagram of the GitHub repository orsopranav/cv_project_sem_6, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/orsopranav/cv_project_sem_6
- Repository: https://github.com/orsopranav/cv_project_sem_6

## Overview

##### Project Type and Purpose
- This is primarily a machine-learning research & demo project implementing a semi-supervised semantic segmentation framework that combines CNNs and Vision Transformers (ViTs).
- It includes:
- Jupyter Notebooks for model development and experiments (Notebooks/…)
- A minimal Flask web app (App/app.py + templates/) for inference demonstration.

##### Key Components
a. Data Sources
- Labeled Dataset
- Unlabeled Dataset
b. Model Training Pipeline
- Hybrid Encoder (CNN + ViT)
- Pseudo-Label Generator & Refiner
- Custom Loss Module
- Optimization Extensions (LoRA, FP16)
c. Model Artifacts
- Checkpoint Storage
- Metrics & Logs
d. Inference Service (Flask App)
- Frontend (index.html, result.html)
- Backend (app.py)
- Model Loading & Preprocessing
e. Experiment Environment
- Jupyter Notebooks as interactive clients
f. Compute Infrastructure
- GPU Nodes / Cluster (for training & inference acceleration)

##### Relationships and Data Flows
- From “Training Pipeline” → “Model Artifacts” (Checkpoint + Logs).
- “Model Artifacts” → “Inference Service” (Flask backend loads final checkpoint).
- “User” → “Frontend” → “Backend” → “Model” → “Result.”
- “Jupyter Notebooks” link bidirectionally to “Training Pipeline” (for experiments & hyperparameter tuning).

##### Architectural Patterns and Design Principles
- Layered on top of Python components:
- Data layer (datasets on disk)
- Compute layer (training and inference modules)
- Presentation layer (Flask + HTML templates)
- Modular separation: training code in Notebooks, inference code in App/
- Reusable components: pseudo-label logic and custom loss function are independent modules that feed into both LoRA and FP16 variants.

##### Technologies and Frameworks
- Python / PyTorch (or TensorFlow) for model definition and training
- Jupyter for interactive experimentation
- Flask for lightweight web service
- LoRA library + mixed-precision (FP16) for efficient training
- HTML/CSS for simple UI

##### Final Recommendations
- Be exhaustive: represent every major directory or logical grouping as a component.
- Keep it uncluttered by collapsing low-level details (don’t show every function, only modules).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Layer
    subgraph "Data Layer"
        direction TB
        Labeled["Labeled Dataset"]:::data
        Unlabeled["Unlabeled Dataset"]:::data
    end

    %% Compute Layer
    subgraph "Compute Layer"
        direction TB
        subgraph "Semi-Supervised Loop"
            direction TB
            HybridEncoder["Hybrid Encoder\n(CNN + ViT)"]:::code
            PseudoV1["Pseudo-Label Generator & Refiner v1"]:::code
            PseudoV2["Pseudo-Label Generator & Refiner v2"]:::code
        end
        CustomLoss["Custom Loss Module & FixMatch"]:::code
        LoRA["Optimization Extensions\n(LoRA, FP16)"]:::code
    end

    %% Model Artifacts
    subgraph "Model Artifacts"
        direction TB
        Checkpoints["Checkpoint Storage"]:::data
        Logs["Metrics & Logs"]:::data
    end

    %% Inference Service
    subgraph "Inference Service"
        direction TB
        Frontend["Frontend\n(index.html, result.html)"]:::ui
        Backend["Backend\n(app.py)"]:::code
        Preproc["Model Loading & Preprocessing"]:::code
    end

    %% Experiment Environment
    subgraph "Experiment Environment"
        direction TB
        NotebooksPranav["Jupyter Client\nPranav"]:::ui
        NotebooksRohil["Jupyter Client\nRohil"]:::ui
        NotebooksSidhardha["Jupyter Client\nSidhardha"]:::ui
    end

    %% Compute Infrastructure
    GPU["GPU Cluster"]:::infra

    %% User
    User["User"]:::ui

    %% Relationships
    Labeled -->|images, labels| HybridEncoder
    Unlabeled -->|images| PseudoV1
    Unlabeled -->|images| PseudoV2

    PseudoV1 -->|pseudo-labels| HybridEncoder
    PseudoV2 -->|pseudo-labels| HybridEncoder
    HybridEncoder -->|features| CustomLoss
    CustomLoss -->|loss| LoRA
    LoRA -->|updates| HybridEncoder

    HybridEncoder -->|model| Checkpoints
    CustomLoss -->|metrics| Logs

    Checkpoints -->|checkpoint| Backend
    Backend -->|serves| Frontend
    Frontend -->|HTTP request| Backend
    Backend -->|inference| Preproc
    Preproc -->|segmentation mask| Frontend
    Frontend -->|HTTP response| User

    NotebooksPranav <-->|experiment/training| HybridEncoder
    NotebooksRohil <-->|experiment/training| CustomLoss
    NotebooksSidhardha <-->|experiment/training| HybridEncoder

    GPU -->|accelerates| HybridEncoder
    GPU -->|accelerates| Preproc

    %% Click Events
    click Backend "https://github.com/orsopranav/cv_project_sem_6/blob/main/App/app.py"
    click Frontend "https://github.com/orsopranav/cv_project_sem_6/blob/main/App/templates/index.html"
    click Frontend "https://github.com/orsopranav/cv_project_sem_6/blob/main/App/templates/result.html"
    click NotebooksPranav "https://github.com/orsopranav/cv_project_sem_6/tree/main/Notebooks/Pranav/"
    click NotebooksRohil "https://github.com/orsopranav/cv_project_sem_6/tree/main/Notebooks/Rohil/"
    click NotebooksSidhardha "https://github.com/orsopranav/cv_project_sem_6/tree/main/Notebooks/Sidhardha/"
    click HybridEncoder "https://github.com/orsopranav/cv_project_sem_6/blob/main/Notebooks/Pranav/CNN-ViT-Hybrid_Semi_Sup.ipynb"
    click PseudoV1 "https://github.com/orsopranav/cv_project_sem_6/blob/main/Notebooks/Pranav/unimatchv1-10.ipynb"
    click PseudoV2 "https://github.com/orsopranav/cv_project_sem_6/blob/main/Notebooks/Pranav/unimatchv2-10.ipynb"
    click CustomLoss "https://github.com/orsopranav/cv_project_sem_6/blob/main/Notebooks/Rohil/FixMatch.py"
    click CustomLoss "https://github.com/orsopranav/cv_project_sem_6/blob/main/Notebooks/Rohil/fixmatch-v2.ipynb"
    click LoRA "https://github.com/orsopranav/cv_project_sem_6/blob/main/Notebooks/Pranav/Hybrid_PEFT_LORA.ipynb"
    click UNetExp "https://github.com/orsopranav/cv_project_sem_6/blob/main/Notebooks/Sidhardha/unet-history.ipynb"
    click README "https://github.com/orsopranav/cv_project_sem_6/blob/main/README.md"
    click LICENSE "https://github.com/orsopranav/cv_project_sem_6/tree/main/LICENSE"

    %% Styles
    classDef code fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef data fill:#d4edda,stroke:#333,stroke-width:1px
    classDef infra fill:#ffe5b4,stroke:#333,stroke-width:1px
    classDef ui fill:#f8d7da,stroke:#333,stroke-width:1px
```
