# vnk8071/depth-anything-triton architecture

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

- Interactive diagram: https://gitdiagram.com/vnk8071/depth-anything-triton
- Repository: https://github.com/vnk8071/depth-anything-triton

## Overview

##### Project Type and Purpose
- This is a machine-learning inference toolkit and simple UI that:
- Converts a PyTorch depth-estimation model to ONNX and TensorRT formats
- Provides both CLI-based and Triton-based inference
- Hosts a minimal web UI for interactive use

##### File Structure
- Top-level scripts:
- export.py – exports PyTorch → ONNX
- onnx2trt.py – compiles ONNX → TensorRT engine
- infer.py – CLI ONNX/TensorRT inference
- depth_anything_triton_infer.py – CLI Triton server client
- app.py – launches local web UI
- Deployment artifacts:
- Dockerfile & compose.yml – build/run Triton server container
- model_repository/… – Triton model repository layout with config.pbtxt
- Assets & support:
- assets/ – sample images, videos, UI screenshots
- utils.py – shared helper functions
- requirements.txt – Python dependencies

##### README Insights
- Conversion workflows (ONNX, TensorRT)
- CLI usage flags and model inputs/outputs
- Web UI serving on port 7860
- Docker/Triton deployment steps and performance benchmarking

##### Main Components
a. Model Conversion Pipeline
­– PyTorch checkpoint → export.py → ONNX model
­– onnx2trt.py or trtexec → TensorRT engine
b. Local Inference Layer
­– infer.py (direct ONNX/engine)
­– app.py (UI calls infer.py under the hood)
c. Triton Inference Server
­– Docker/compose.yml containerizing Triton
­– model_repository/depth_anything
­– config.pbtxt + model.plan
d. Triton Client
­– depth_anything_triton_infer.py
­– HTTP/gRPC calls to Triton API
e. External Inputs/Outputs
­– User uploads images/videos (CLI flags or UI)
­– Depth maps returned (files or HTTP responses)

##### Relationships and Data Flow
- Conversion scripts produce model artifacts stored in local folders (`models/`, `model_repository/`).
- CLI inference and UI both load from these artifacts when `--mode onnx`/`trt` is selected.
- Triton container mounts `model_repository` and exposes gRPC/HTTP endpoints.
- Triton client script calls those endpoints and retrieves depth results.
- Web UI (`app.py`) may call local inference functions directly or send requests to Triton if configured.

##### Architectural Patterns and Technologies
- Pattern: modular pipeline (conversion → inference → UI/deployment)
- Technologies: Python, ONNX, TensorRT, NVIDIA Triton Inference Server, Docker, Flask/FastAPI (likely behind `app.py`), polygraphy/trtexec, perf_analyzer

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Model Conversion Pipeline
    subgraph "Model Conversion"
        direction TB
        M1["PyTorch Checkpoint"]:::model
        A["export.py"]:::script
        M2["ONNX Model"]:::model
        B["onnx2trt.py"]:::script
        M3["TensorRT Engine"]:::model
    end

    M1 -->|"export.py"| A
    A -->|"produces ONNX"| M2
    M2 -->|"onnx2trt.py"| B
    B -->|"produces TensorRT"| M3

    %% Local Inference Layer
    subgraph "Local Inference"
        direction TB
        C["infer.py"]:::script
        U["utils.py"]:::script
    end

    M2 -->|loads ONNX| C
    M3 -->|loads Engine| C

    %% Triton Inference Server
    subgraph "Triton Server"
        direction TB
        Container["Docker Container"]:::container
        Dker["Dockerfile"]:::container
        Compose["compose.yml"]:::container
        RT["Triton Server\n(Ports: 8000/8001/8002)"]:::container
        subgraph "Model Repository"
            direction TB
            Repo["model_repository/depth_anything/"]:::model
            G1["1/.gitkeep"]:::model
            Cfg["config.pbtxt"]:::model
        end
    end

    M3 -->|mounts TensorRT| Repo
    Repo -->|serves model| RT

    %% Client/UI Layer
    subgraph "Client/UI"
        direction TB
        UI["app.py\n(Web UI, port 7860)"]:::script
        TC["depth_anything_triton_infer.py"]:::script
        Assets["assets/"]:::external
        Req["requirements.txt"]:::external
    end

    UI -->|calls infer.py| C
    UI -->|"HTTP/gRPC"| RT
    TC -->|"HTTP/gRPC"| RT
    Assets -->|sample I/O| UI
    Req -->|dependencies| UI

    %% External User
    ExternalUser["User\n(CLI/UI)"]:::external
    ExternalUser -->|uses CLI| C
    ExternalUser -->|uploads via UI| UI
    ExternalUser -->|runs Triton client| TC

    %% Click Events
    click A "https://github.com/vnk8071/depth-anything-triton/blob/main/export.py"
    click B "https://github.com/vnk8071/depth-anything-triton/blob/main/onnx2trt.py"
    click C "https://github.com/vnk8071/depth-anything-triton/blob/main/infer.py"
    click U "https://github.com/vnk8071/depth-anything-triton/blob/main/utils.py"
    click UI "https://github.com/vnk8071/depth-anything-triton/blob/main/app.py"
    click TC "https://github.com/vnk8071/depth-anything-triton/blob/main/depth_anything_triton_infer.py"
    click Dker "https://github.com/vnk8071/depth-anything-triton/tree/main/Dockerfile"
    click Compose "https://github.com/vnk8071/depth-anything-triton/blob/main/compose.yml"
    click Repo "https://github.com/vnk8071/depth-anything-triton/tree/main/model_repository/depth_anything/"
    click G1 "https://github.com/vnk8071/depth-anything-triton/blob/main/model_repository/depth_anything/1/.gitkeep"
    click Cfg "https://github.com/vnk8071/depth-anything-triton/blob/main/model_repository/depth_anything/config.pbtxt"
    click Assets "https://github.com/vnk8071/depth-anything-triton/tree/main/assets/"
    click Req "https://github.com/vnk8071/depth-anything-triton/blob/main/requirements.txt"

    %% Styles
    classDef script fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef model fill:#90EE90,stroke:#333,stroke-width:1px
    classDef container fill:#FFA500,stroke:#333,stroke-width:1px
    classDef external fill:#F4F4F4,stroke:#333,stroke-width:1px
```
