# bharath5673/deepstream architecture

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

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

## Overview

This repository is a **DeepStream 8.0 video-analytics demo stack**, not a single application. Its architecture splits cleanly into **offline model preparation** and **runtime inference pipelines**.

1. **Primary purpose**
   The repo shows how to run NVIDIA DeepStream pipelines for:
   - YOLO object detection
   - YOLO pose estimation
   - multi-object tracking
   - ROI-based analytics/counting
   - multi-model / multi-stream processing
   - custom CNN deployment through ONNX conversion

2. **Main runtime entry points**
   The top-level orchestration is centered around:
   - `QuickDemo.sh` for a quick end-to-end launch
   - `test_ds.py` for basic testing
   - multiple Python DeepStream demos under `DeepStream-Python/`

   These are the likely “start here” nodes in an architecture diagram.

3. **Config-driven DeepStream layer**
   `DeepStream-Configs/` contains the pipeline configuration boundary:
   - `config_infer_primary_yoloV8.txt`
   - `config_infer_primary_yoloV8_pose.txt`
   - `dstest2_tracker_config.txt`
   - `labels.txt`

   This layer defines how DeepStream loads models, interprets outputs, and applies tracking. The design is strongly configuration-driven rather than hard-coded.

4. **Python pipeline layer**
   `DeepStream-Python/` contains several pipeline variants built around DeepStream’s Python bindings:
   - `deepstream_test_1.py` — baseline sample
   - `deepstream_test_yolo_save_vid.py` — detection + video output
   - `deepstream_test_yolo_track_save_vid.py` — detection + tracking
   - `deepstream_test_yolo_track_ROI_save_vid.py` — tracking + ROI analytics
   - `deepstream_test_yolo_track_multimodel.py` — multi-model pipeline
   - `deepstream_test_yolo_track_pose_save_vid.py` — pose pipeline with tracking/output

   These scripts are the execution layer that ties together sources, inference, tracking, and sinks.

5. **Input/output data flow**
   The repository uses local media files as inputs:
   - `inputs/4ktraffic.mp4`
   - `inputs/people-detection.mp4`

   Output artifacts are written locally, such as:
   - `outputs/test.txt`
   - saved video files produced by the demo scripts

   So the basic flow is: **video file input → DeepStream pipeline → inference/tracking/analytics → file output**.

6. **Model artifacts**
   The `weights/` directory contains deployed model artifacts in ONNX format:
   - `yolov8n.onnx`
   - `yolov8n-pose.onnx`
   - `yolo11n-pose.onnx`
   - `yolov8n-face.onnx`

   These models are the inference boundary between offline training and runtime deployment. In the DeepStream setup, they are consumed through the config files and executed via NVIDIA’s inference stack.

7. **Custom CNN conversion workflow**
   `CNN-to-DeepStream/` is a separate offline preparation subsystem for adapting a custom classifier into the DeepStream runtime:
   - `convert_2_onnx.py` handles model conversion
   - `gender/content/gender_model.h5` is the trained Keras model
   - `gender_model_training_log.json` records training history
   - `custom_CNN_utkTest.ipynb` and `UTKFace_test.zip` support experimentation/validation

   This subsystem represents a distinct pipeline: **training artifact → ONNX conversion → DeepStream-compatible deployment**.

8. **Tracking and ROI boundary**
   Tracking is not just a model feature here; it is a separate analytics stage configured through DeepStream tracker settings. ROI scripts suggest a pipeline shape of:
   - detection
   - object association/tracking
   - region-of-interest logic
   - event/count output

   That makes tracking/ROI a post-inference analytics layer rather than part of the detector itself.

9. **Multi-model / pose specialization**
   The repo includes specialized branches for:
   - object detection
   - pose estimation
   - combined detection + pose
   - multi-model inference in one pipeline

   This implies the architecture supports multiple inference branches feeding a shared downstream tracker/renderer/sink path.

10. **Deployment and environment assumptions**
   The stack is explicitly tuned for:
   - DeepStream 8.0
   - CUDA 12.x
   - Python 3.10+
   - Ubuntu 24.04
   - Docker with NVIDIA Container Runtime, or bare-metal installation

   These are important architectural constraints because DeepStream pipelines depend on GPU-accelerated inference and NVIDIA runtime support.

11. **Repository boundary**
   The repo is best understood as three connected subsystems:
   - **runtime demos** (`DeepStream-Python/`)
   - **pipeline configuration** (`DeepStream-Configs/`)
   - **offline model prep/conversion** (`CNN-to-DeepStream/`, `weights/`)

   A diagram should show these as separate but connected layers, with models/configs flowing into the runtime pipelines.

12. **Practical architecture summary**
   If you were drawing the system, the core path would be:
   **input media or stream → DeepStream pipeline script → inference config + ONNX model → tracker/ROI/pose logic → output video or text artifacts**.

   The main boundary is between **model preparation** and **inference execution**; the repo’s value is in providing ready-to-run templates across that boundary.

Main entry points: [`DeepStream-Python/deepstream_test_yolo_track_ROI_save_vid.py`](https://github.com/bharath5673/deepstream/blob/main/DeepStream-Python/deepstream_test_yolo_track_ROI_save_vid.py) (ROI analytics), [`DeepStream-Python/deepstream_test_yolo_track_multimodel.py`](https://github.com/bharath5673/deepstream/blob/main/DeepStream-Python/deepstream_test_yolo_track_multimodel.py) (Multi-model), [`DeepStream-Python/deepstream_test_yolo_track_save_vid.py`](https://github.com/bharath5673/deepstream/blob/main/DeepStream-Python/deepstream_test_yolo_track_save_vid.py) (Track video), [`DeepStream-Python/deepstream_test_yolo_track_pose_save_vid.py`](https://github.com/bharath5673/deepstream/blob/main/DeepStream-Python/deepstream_test_yolo_track_pose_save_vid.py) (Pose video)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime_demos["Runtime demos"]
  node_quickdemo["QuickDemo.sh<br/>launcher<br/>[QuickDemo.sh]"]
  node_testds["test_ds.py<br/>smoke test<br/>[test_ds.py]"]
  node_ds_base["Baseline<br/>pipeline script"]
  node_ds_detect["Detect video<br/>pipeline script"]
  node_ds_track["Track video<br/>pipeline script"]
  node_ds_roi["ROI analytics<br/>pipeline script"]
  node_ds_multi["Multi-model<br/>pipeline script"]
  node_ds_pose["Pose video<br/>pipeline script"]
end

subgraph group_pipeline_config["Pipeline config"]
  node_infer_yolo["YOLO config<br/>infer config"]
  node_infer_pose["Pose config<br/>infer config"]
  node_tracker_cfg["Tracker config"]
  node_labels["Labels<br/>[labels.txt]"]
  node_onnx_yolo[("YOLOv8 ONNX<br/>model artifact<br/>[yolov8n.onnx]")]
  node_onnx_pose[("Pose ONNX<br/>model artifact<br/>[yolov8n-pose.onnx]")]
  node_onnx_pose11[("YOLO11 pose<br/>model artifact<br/>[yolo11n-pose.onnx]")]
  node_onnx_face[("Face ONNX<br/>model artifact<br/>[yolov8n-face.onnx]")]
end

subgraph group_model_prep["Model prep"]
  node_onnx_convert["ONNX convert<br/>conversion script<br/>[convert_2_onnx.py]"]
  node_gender_model[("Gender model<br/>keras model<br/>[gender_model.h5]")]
end

node_quickdemo -->|"launches"| node_ds_detect
node_quickdemo -->|"launches"| node_ds_track
node_quickdemo -->|"launches"| node_ds_pose
node_testds -->|"exercises"| node_ds_base
node_ds_detect -->|"loads"| node_infer_yolo
node_ds_detect -->|"runs"| node_onnx_yolo
node_ds_track -->|"loads"| node_infer_yolo
node_ds_track -->|"enables"| node_tracker_cfg
node_ds_track -->|"runs"| node_onnx_yolo
node_ds_roi -->|"loads"| node_infer_yolo
node_ds_roi -->|"enables"| node_tracker_cfg
node_ds_roi -->|"runs"| node_onnx_yolo
node_ds_roi -->|"labels"| node_labels
node_ds_multi -->|"loads"| node_infer_yolo
node_ds_multi -->|"loads"| node_infer_pose
node_ds_multi -->|"runs"| node_onnx_yolo
node_ds_multi -->|"runs"| node_onnx_pose
node_ds_pose -->|"loads"| node_infer_pose
node_ds_pose -->|"enables"| node_tracker_cfg
node_ds_pose -->|"runs"| node_onnx_pose
node_ds_base -->|"annotates"| node_labels
node_onnx_convert -->|"converts"| node_gender_model

click node_quickdemo "https://github.com/bharath5673/deepstream/blob/main/QuickDemo.sh"
click node_testds "https://github.com/bharath5673/deepstream/blob/main/test_ds.py"
click node_ds_base "https://github.com/bharath5673/deepstream/blob/main/DeepStream-Python/deepstream_test_1.py"
click node_ds_detect "https://github.com/bharath5673/deepstream/blob/main/DeepStream-Python/deepstream_test_yolo_save_vid.py"
click node_ds_track "https://github.com/bharath5673/deepstream/blob/main/DeepStream-Python/deepstream_test_yolo_track_save_vid.py"
click node_ds_roi "https://github.com/bharath5673/deepstream/blob/main/DeepStream-Python/deepstream_test_yolo_track_ROI_save_vid.py"
click node_ds_multi "https://github.com/bharath5673/deepstream/blob/main/DeepStream-Python/deepstream_test_yolo_track_multimodel.py"
click node_ds_pose "https://github.com/bharath5673/deepstream/blob/main/DeepStream-Python/deepstream_test_yolo_track_pose_save_vid.py"
click node_infer_yolo "https://github.com/bharath5673/deepstream/blob/main/DeepStream-Configs/config_infer_primary_yoloV8.txt"
click node_infer_pose "https://github.com/bharath5673/deepstream/blob/main/DeepStream-Configs/config_infer_primary_yoloV8_pose.txt"
click node_tracker_cfg "https://github.com/bharath5673/deepstream/blob/main/DeepStream-Configs/dstest2_tracker_config.txt"
click node_labels "https://github.com/bharath5673/deepstream/blob/main/DeepStream-Configs/labels.txt"
click node_onnx_yolo "https://github.com/bharath5673/deepstream/blob/main/weights/yolov8n.onnx"
click node_onnx_pose "https://github.com/bharath5673/deepstream/blob/main/weights/yolov8n-pose.onnx"
click node_onnx_pose11 "https://github.com/bharath5673/deepstream/blob/main/weights/yolo11n-pose.onnx"
click node_onnx_face "https://github.com/bharath5673/deepstream/blob/main/weights/yolov8n-face.onnx"
click node_onnx_convert "https://github.com/bharath5673/deepstream/blob/main/CNN-to-DeepStream/convert_2_onnx.py"
click node_gender_model "https://github.com/bharath5673/deepstream/blob/main/CNN-to-DeepStream/gender/content/gender_model.h5"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_quickdemo,node_testds,node_ds_base,node_ds_detect,node_ds_track,node_ds_roi,node_ds_multi,node_ds_pose toneBlue
class node_infer_yolo,node_infer_pose,node_tracker_cfg,node_labels,node_onnx_yolo,node_onnx_pose,node_onnx_pose11,node_onnx_face toneAmber
class node_onnx_convert,node_gender_model toneMint
```

## Components

### Runtime demos

Launch scripts and Python DeepStream pipeline variants.

- [QuickDemo.sh](https://github.com/bharath5673/deepstream/blob/main/QuickDemo.sh): launcher · End-to-end demo entry point. · `QuickDemo.sh`
- [test_ds.py](https://github.com/bharath5673/deepstream/blob/main/test_ds.py): smoke test · Basic repository test entry point. · `test_ds.py`
- [Baseline](https://github.com/bharath5673/deepstream/blob/main/DeepStream-Python/deepstream_test_1.py): pipeline script · Minimal DeepStream Python sample. · `DeepStream-Python/deepstream_test_1.py`
- [Detect video](https://github.com/bharath5673/deepstream/blob/main/DeepStream-Python/deepstream_test_yolo_save_vid.py): pipeline script · YOLO detection with video output. · `DeepStream-Python/deepstream_test_yolo_save_vid.py`
- [Track video](https://github.com/bharath5673/deepstream/blob/main/DeepStream-Python/deepstream_test_yolo_track_save_vid.py): pipeline script · Detection plus tracking and video output. · `DeepStream-Python/deepstream_test_yolo_track_save_vid.py`
- [ROI analytics](https://github.com/bharath5673/deepstream/blob/main/DeepStream-Python/deepstream_test_yolo_track_ROI_save_vid.py): pipeline script · Tracking pipeline with region-of-interest logic. · `DeepStream-Python/deepstream_test_yolo_track_ROI_save_vid.py`
- [Multi-model](https://github.com/bharath5673/deepstream/blob/main/DeepStream-Python/deepstream_test_yolo_track_multimodel.py): pipeline script · Multi-model DeepStream pipeline. · `DeepStream-Python/deepstream_test_yolo_track_multimodel.py`
- [Pose video](https://github.com/bharath5673/deepstream/blob/main/DeepStream-Python/deepstream_test_yolo_track_pose_save_vid.py): pipeline script · Pose estimation pipeline with tracking and output. · `DeepStream-Python/deepstream_test_yolo_track_pose_save_vid.py`

### Pipeline config

Inference, tracker, and label configuration consumed by runtime pipelines.

- [YOLO config](https://github.com/bharath5673/deepstream/blob/main/DeepStream-Configs/config_infer_primary_yoloV8.txt): infer config · Primary detector configuration. · `DeepStream-Configs/config_infer_primary_yoloV8.txt`
- [Pose config](https://github.com/bharath5673/deepstream/blob/main/DeepStream-Configs/config_infer_primary_yoloV8_pose.txt): infer config · Primary pose model configuration. · `DeepStream-Configs/config_infer_primary_yoloV8_pose.txt`
- [Tracker config](https://github.com/bharath5673/deepstream/blob/main/DeepStream-Configs/dstest2_tracker_config.txt): tracker config · DeepStream tracker settings. · `DeepStream-Configs/dstest2_tracker_config.txt`
- [Labels](https://github.com/bharath5673/deepstream/blob/main/DeepStream-Configs/labels.txt): class labels · Label map for inference outputs. · `DeepStream-Configs/labels.txt`
- [YOLOv8 ONNX](https://github.com/bharath5673/deepstream/blob/main/weights/yolov8n.onnx): model artifact · Object detection deployment model. · `weights/yolov8n.onnx`
- [Pose ONNX](https://github.com/bharath5673/deepstream/blob/main/weights/yolov8n-pose.onnx): model artifact · Pose estimation deployment model. · `weights/yolov8n-pose.onnx`
- [YOLO11 pose](https://github.com/bharath5673/deepstream/blob/main/weights/yolo11n-pose.onnx): model artifact · Alternative pose deployment model. · `weights/yolo11n-pose.onnx`
- [Face ONNX](https://github.com/bharath5673/deepstream/blob/main/weights/yolov8n-face.onnx): model artifact · Face detection deployment model. · `weights/yolov8n-face.onnx`

### Model prep

Offline conversion and training-artifact boundary for custom CNN deployment.

- [ONNX convert](https://github.com/bharath5673/deepstream/blob/main/CNN-to-DeepStream/convert_2_onnx.py): conversion script · Converts a custom CNN for DeepStream deployment. · `CNN-to-DeepStream/convert_2_onnx.py`
- [Gender model](https://github.com/bharath5673/deepstream/blob/main/CNN-to-DeepStream/gender/content/gender_model.h5): keras model · Trained Keras classifier used for conversion. · `CNN-to-DeepStream/gender/content/gender_model.h5`

## Connections

- QuickDemo.sh → Detect video: launches · Primary quick-start path.
- QuickDemo.sh → Track video: launches · Quick demo can run tracking pipeline.
- QuickDemo.sh → Pose video: launches · Quick demo can run pose pipeline.
- test_ds.py → Baseline: exercises · Basic smoke-test pipeline.
- Detect video → YOLO config: loads · Uses detector config.
- Detect video → YOLOv8 ONNX: runs · Consumes YOLO model artifact.
- Track video → YOLO config: loads · Uses detector config.
- Track video → Tracker config: enables · Adds object tracking stage.
- Track video → YOLOv8 ONNX: runs · Consumes YOLO model artifact.
- ROI analytics → YOLO config: loads · Detection input to ROI pipeline.
- ROI analytics → Tracker config: enables · Tracking boundary before ROI logic.
- ROI analytics → YOLOv8 ONNX: runs · Consumes YOLO model artifact.
- ROI analytics → Labels: labels · Uses class names for counting/annotation.
- Multi-model → YOLO config: loads · One branch uses detector config.
- Multi-model → Pose config: loads · Another branch uses pose config.
- Multi-model → YOLOv8 ONNX: runs · Detection branch model.
- Multi-model → Pose ONNX: runs · Pose branch model.
- Pose video → Pose config: loads · Uses pose model config.
- Pose video → Tracker config: enables · Adds tracking after pose inference.
- Pose video → Pose ONNX: runs · Consumes pose ONNX model.
- Baseline → Labels: annotates · Baseline sample output labeling.
- ONNX convert → Gender model: converts · Offline preparation for deployment.
