# lijia7/sddr architecture

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

- Interactive diagram: https://gitdiagram.com/lijia7/sddr
- Repository: https://github.com/lijia7/sddr

## Overview

##### Project type and purpose
- This is a research‐code Python pipeline for “Self‐Distilled Depth Refinement with Noisy Poisson Fusion,” implemented as a CLI/inference tool (not a web app).
- It takes stereo/rgb inputs, runs one‐ or two‐stage depth estimation (LeRes, MiDaS, SGR submodels), fuses/refines them, and writes out depth maps.

##### File structure
- Top-level:
- demo.py, previous_evaluate_mid21.py – entry‐point scripts (CLI interface, evaluation).
- requirements.txt – Python dependencies.
- checkpoints/ – pretrained PyTorch model weights.
- demo_input/, demo_output/ – folders for test data and results.
- utils/ – project‐specific helper modules (backbone definitions, fusion functions, loss, model wrappers).
- thirdrepo/ – three external repositories integrated as subpackages:
– LeRes/ (ResNet‐based depth net)
– MiDaS/ (MiDaS base model and transforms)
– SGR/ (another depth network + custom synchronized‐batchnorm C/CUDA extension)
- assets/ – static assets (e.g., NeurIPS logo).

##### README for additional insights
- The README confirms the CLI usage (one-stage vs two-stage), weight arguments, input/output paths, and evaluation script.
- It points out core steps: load base depth predictions (high/low resolution), refine via Poisson fusion and self‐distillation.

##### Elements
CLI → Data Loader → Base Depth Nets → Fusion Engine → Output Writer → Evaluation
– Blue for code modules (demo.py, utils, thirdrepo)
– Green for data artifacts (demo_input, checkpoints, demo_output)
– Orange for external/C++ extension (SGR syncbn)

##### Final advice
- Core algorithmic stages (base net inference, Poisson fusion, self-distillation).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% CLI Layer
    subgraph "CLI Layer"
        CLI["demo.py"]:::code
    end

    %% Data Layer
    subgraph "Data Layer"
        DataIn["demo_input/"]:::data
    end

    %% Base Depth Estimation Subsystems
    subgraph "Base Depth Estimation"
        LeRes["LeRes Module"]:::code
        MiDaS["MiDaS Module"]:::code
        SGR["SGR Module"]:::code
        SGRExt["SGR SyncBN Extension"]:::ext
    end

    %% Fusion & Refinement Engine
    subgraph "Fusion & Refinement Engine"
        FusionCore["utils/func.py"]:::code
        TwoStageLogic["utils/utils_2stage.py"]:::code
        DistillLoss["utils/loss_my.py"]:::code
        Backbone["utils/backbone.py"]:::code
        CVT["utils/cvt.py"]:::code
        ModelWrap["utils/model/"]:::code
    end

    %% Model Checkpoints
    subgraph "Model Checkpoints"
        Checkpts["checkpoints/"]:::data
    end

    %% Output Layer
    subgraph "Output Layer"
        DataOut["demo_output/"]:::data
    end

    %% Evaluation Module
    subgraph "Evaluation"
        Eval["previous_evaluate_mid21.py"]:::code
    end

    %% Static Assets
    Assets["assets/"]:::data

    %% Decision
    Decision{"Two-Stage?"}:::decision

    %% Connections
    CLI -->|"loads args"| DataIn
    CLI -->|points to| Checkpts
    DataIn -->|"RGB images"| LeRes
    DataIn -->|"RGB images"| MiDaS
    DataIn -->|"RGB images"| SGR
    Checkpts -->|load weights| LeRes
    Checkpts -->|load weights| MiDaS
    Checkpts -->|load weights| SGR
    SGR -->|uses| SGRExt
    LeRes -->|"depth maps"| Decision
    MiDaS -->|"depth maps"| Decision
    SGR -->|"depth maps"| Decision
    Decision -->|"one/two branch"| TwoStageLogic
    Decision -->|"to fusion"| FusionCore
    TwoStageLogic -->|"refine"| FusionCore
    FusionCore -->|"self-distill"| DistillLoss
    FusionCore -->|"uses backbones"| Backbone
    FusionCore -->|"uses utils"| CVT
    FusionCore -->|"wrap models"| ModelWrap
    FusionCore -->|"writes maps"| DataOut
    DataOut -->|"metrics"| Eval
    Assets --> CLI

    %% Click Events
    click CLI "https://github.com/lijia7/sddr/blob/master/demo.py"
    click Eval "https://github.com/lijia7/sddr/blob/master/previous_evaluate_mid21.py"
    click DataIn "https://github.com/lijia7/sddr/tree/master/demo_input/"
    click Checkpts "https://github.com/lijia7/sddr/tree/master/checkpoints/"
    click DataOut "https://github.com/lijia7/sddr/tree/master/demo_output/"
    click LeRes "https://github.com/lijia7/sddr/tree/master/thirdrepo/LeRes/"
    click MiDaS "https://github.com/lijia7/sddr/tree/master/thirdrepo/MiDaS/"
    click SGR "https://github.com/lijia7/sddr/tree/master/thirdrepo/SGR/"
    click SGRExt "https://github.com/lijia7/sddr/tree/master/thirdrepo/SGR/syncbn/"
    click FusionCore "https://github.com/lijia7/sddr/blob/master/utils/func.py"
    click TwoStageLogic "https://github.com/lijia7/sddr/blob/master/utils/utils_2stage.py"
    click DistillLoss "https://github.com/lijia7/sddr/blob/master/utils/loss_my.py"
    click Backbone "https://github.com/lijia7/sddr/blob/master/utils/backbone.py"
    click CVT "https://github.com/lijia7/sddr/blob/master/utils/cvt.py"
    click ModelWrap "https://github.com/lijia7/sddr/tree/master/utils/model/"
    click Assets "https://github.com/lijia7/sddr/tree/master/assets/"

    %% Styles
    classDef code fill:#D0E6FF,stroke:#02457A,color:#02457A;
    classDef data fill:#E6FFEA,stroke:#027320,color:#027320;
    classDef ext fill:#FFE5CC,stroke:#D26900,color:#D26900;
    classDef decision fill:#FFF7CC,stroke:#C89F00,color:#C89F00,stroke-dasharray: 5 5;
```
