# quangdungluong/deepstream-yolov11 architecture

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

- Interactive diagram: https://gitdiagram.com/quangdungluong/deepstream-yolov11
- Repository: https://github.com/quangdungluong/deepstream-yolov11

## Overview

##### Project type and purpose
- This is an open-source toolkit that supplies custom TensorRT parsers (C++ plugins) for AI models in NVIDIA’s DeepStream SDK.
- It streamlines the end-to-end flow of exporting backbone networks (YOLOv11, SCRFD, D-FINE) to ONNX, converting them to TRT engines, and loading them into a DeepStream pipeline.

##### File structure
- Top level
– configs/: DeepStream and parser configuration files for multiple model modes (det, seg, pose).
– libs/: Custom parser code (C++/CUDA) organized by model type (yolo, yolo_pose, yolo_seg) plus build/install scripts.
– models/: Python export scripts and model-specific assets for ONNX conversion.
– scripts/: Shell helpers to compile parsers.
– docs/: Usage guides for each model and feature.
– CI/config files (.github, .pre-commit, etc.).
- Architectural cues
– libs/ → plugin architecture for DeepStream.
– models/ → code-based model export pipeline.
– configs/ → declarative wiring between parsers, engines, and deepstream-app.

##### README for additional insights
- Workflow stages documented:
1. Clone repo
2. Build custom parser with compile_nvdsinfer.sh
3. Export model to ONNX via Python scripts
4. Convert ONNX to TRT engine with trtexec
5. Edit parser & DeepStream config (.txt)
6. Run deepstream-app
- Target platforms: Jetson & dGPU, DeepStream SDK 6.2–7.1.

a. Main components
– Developer workstation (or CI) with code repository & build environment
– Build system (compile_nvdsinfer.sh, Makefiles) producing .so parser libraries
– Model export subsystem (Python scripts under models/) outputting ONNX
– TensorRT conversion (trtexec) producing .engine files
– DeepStream runtime: deepstream-app + SDK plugins + custom parser libraries + TRT engines
– Video I/O: camera/file input → inference → overlay/tracker → output
– External dependencies: NVIDIA GPU/Jetson hardware, CUDA, ONNX, DeepStream SDK, TensorRT
b. Relationships & data flow
– Code repo → Build system → Parser shared libraries
– Code repo → Model export scripts → ONNX files → TensorRT conversion → engine files
– DeepStream-app loads configs, custom parser .so, TRT engine → ingests video → GIE plugin → metadata → display or downstream bus
c. Architectural patterns & principles
– Plugin architecture: libs/nvdsinfer_customparser_* are dynamically loaded by DeepStream’s GIE plugin.
– Dataflow/streaming pipeline: DeepStream’s mux → GIE → tracker → OSD → sink.
– Separation of concerns: export, conversion, configuration, runtime all live in distinct directories.
d. Key technologies/frameworks
– C++, CUDA, cuDNN (through TRT), Python (model export), ONNX, TensorRT, DeepStream SDK

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Source and CI
    subgraph "Source Code & CI"
        Repo["Code Repository\n(libs/, scripts/, models/, configs/)"]:::code
        CIPipeline["CI & Quality"]:::code
    end

    %% Build System
    subgraph "Build System"
        BuildScript["compile_nvdsinfer.sh"]:::code
        InstallScript["install.sh"]:::code
        CleanScript["clean.sh"]:::code
        Makefiles["Makefiles"]:::code
    end

    %% Model Export
    subgraph "Model Export Subsystem"
        YOLODetExport["export_yolov11_det.py"]:::code
        YOLOPoseExport["export_yolov11_pose.py"]:::code
        YOLOSegExport["export_yolov11_seg.py"]:::code
        SCRFDExport["export_scrfd.py"]:::code
        DFineExport["export_onnx_deepstream.py"]:::code
    end

    %% Conversion
    ONNX["ONNX Files"]:::artifact
    TensorRT["TensorRT Engine\n(.engine)"]:::artifact

    %% Configurations
    subgraph "Configuration Files"
        ConfigGIE["config_primary_gie.txt"]:::code
        ConfigYoloDet["config_primary_yolov11.txt"]:::code
        ConfigYoloPose["config_primary_yolov11_pose.txt"]:::code
        ConfigYoloSeg["config_primary_yolov11_seg.txt"]:::code
        DSPresets["deepstream_app_*.txt"]:::code
        LabelMaps["labels*.txt"]:::code
    end

    %% Runtime
    subgraph "Runtime Pipeline"
        DSTool["deepstream_pose.py"]:::runtime
        DSApp["deepstream-app"]:::runtime
        DS_SDK["DeepStream SDK Plugins"]:::runtime
        ParserLibs["Custom Parser Libraries"]:::runtime
        TRTEngines["Loaded TRT Engines"]:::runtime
        Inference["Inference Pipeline\n(GIE→Tracker→OSD)"]:::runtime
        VideoIO["Video Source/Sink"]:::external
        GPU["NVIDIA GPU/Jetson"]:::external
    end

    %% Flows
    Repo -->|triggers build| BuildScript
    BuildScript -->|builds .so| ParserLibs
    InstallScript --> BuildScript
    CleanScript --> BuildScript
    Makefiles --- BuildScript

    Repo -->|runs exports| YOLODetExport
    Repo --> YOLOPoseExport
    Repo --> YOLOSegExport
    Repo --> SCRFDExport
    Repo --> DFineExport

    YOLODetExport -->|outputs| ONNX
    YOLOPoseExport --> ONNX
    YOLOSegExport --> ONNX
    SCRFDExport --> ONNX
    DFineExport --> ONNX

    ONNX -->|trtexec conversion| TensorRT

    ParserLibs -->|configured by| ConfigYoloDet
    ParserLibs --> ConfigYoloPose
    ParserLibs --> ConfigYoloSeg

    TensorRT -->|referenced in| ConfigGIE
    DSPresets --> DSApp
    LabelMaps --> DSApp

    ConfigGIE --> DSApp

    DSApp -->|loads| ParserLibs
    DSApp -->|loads| DS_SDK
    DSApp -->|loads| TRTEngines

    DSApp --> Inference
    Inference --> VideoIO
    VideoIO --> Inference
    Inference --> VideoIO
    GPU --> DSApp

    Repo --> CIPipeline

    %% Click Events
    click BuildScript "https://github.com/quangdungluong/deepstream-yolov11/blob/master/scripts/compile_nvdsinfer.sh"
    click InstallScript "https://github.com/quangdungluong/deepstream-yolov11/blob/master/libs/install.sh"
    click CleanScript "https://github.com/quangdungluong/deepstream-yolov11/blob/master/libs/clean.sh"
    click Makefiles "https://github.com/quangdungluong/deepstream-yolov11/tree/master/libs/*/Makefile"
    click ParserLibs "https://github.com/quangdungluong/deepstream-yolov11/tree/master/libs/nvdsinfer_customparser_yolo/"
    click ParserLibs "https://github.com/quangdungluong/deepstream-yolov11/tree/master/libs/nvdsinfer_customparser_yolo_pose/"
    click ParserLibs "https://github.com/quangdungluong/deepstream-yolov11/tree/master/libs/nvdsinfer_customparser_yolo_seg/"
    click YOLODetExport "https://github.com/quangdungluong/deepstream-yolov11/blob/master/models/yolov11-det/export_yolov11_det.py"
    click YOLOPoseExport "https://github.com/quangdungluong/deepstream-yolov11/blob/master/models/yolov11-pose/export_yolov11_pose.py"
    click YOLOSegExport "https://github.com/quangdungluong/deepstream-yolov11/blob/master/models/yolov11-seg/export_yolov11_seg.py"
    click SCRFDExport "https://github.com/quangdungluong/deepstream-yolov11/blob/master/models/scrfd/export_scrfd.py"
    click DFineExport "https://github.com/quangdungluong/deepstream-yolov11/blob/master/models/d-fine/export_onnx_deepstream.py"
    click ConfigGIE "https://github.com/quangdungluong/deepstream-yolov11/blob/master/configs/config_primary_gie.txt"
    click ConfigYoloDet "https://github.com/quangdungluong/deepstream-yolov11/blob/master/configs/config_primary_yolov11.txt"
    click ConfigYoloPose "https://github.com/quangdungluong/deepstream-yolov11/blob/master/configs/config_primary_yolov11_pose.txt"
    click ConfigYoloSeg "https://github.com/quangdungluong/deepstream-yolov11/blob/master/configs/config_primary_yolov11_seg.txt"
    click DSPresets "https://github.com/quangdungluong/deepstream-yolov11/blob/master/deepstream_app_det_config.txt"
    click DSPresets "https://github.com/quangdungluong/deepstream-yolov11/blob/master/deepstream_app_seg_config.txt"
    click LabelMaps "https://github.com/quangdungluong/deepstream-yolov11/blob/master/configs/labels.txt"
    click LabelMaps "https://github.com/quangdungluong/deepstream-yolov11/blob/master/configs/labels-pose.txt"
    click DSTool "https://github.com/quangdungluong/deepstream-yolov11/blob/master/deepstream_pose.py"

    %% Styles
    classDef code fill:#add8e6,stroke:#000,stroke-width:1px;
    classDef artifact fill:#90ee90,stroke:#000,stroke-width:1px;
    classDef runtime fill:#ffa500,stroke:#000,stroke-width:1px;
    classDef external fill:#d3d3d3,stroke:#000,stroke-width:1px;
```
