# gajuuzz/human-falling-detect-tracks architecture

> Architecture diagram of the GitHub repository gajuuzz/human-falling-detect-tracks, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gajuuzz/human-falling-detect-tracks
- Repository: https://github.com/gajuuzz/human-falling-detect-tracks

## Overview

##### Main Components
- Video/Data Input: The system accepts video input either from a file or a camera. This is managed via modules such as CameraLoader.py and main.py.
- Detection Module: The “Detection” directory (and related loader, DetectorLoader.py) encapsulates the Tiny-YOLO oneclass model used to detect persons.
- Pose Estimation Module: Under SPPE (and associated PoseEstimateLoader.py), the AlphaPose implementation (i.e., FastPose) processes detected persons to extract skeleton keypoints.
- Tracking Module: The “Track” directory contains tracking utilities (Tracker.py, iou_matching.py, kalman_filter.py, etc.) that track persons across frames.
- Action Recognition Module: Using the “Actionsrecognition” folder and supporting scripts (e.g., train.py and Models inside TSSTG), the ST-GCN model analyzes the tracked skeleton data to predict actions.
- Preprocessing/Data Creation: The “Data” folder houses scripts (create_dataset_1.py, etc.) for dataset creation/augmentation used during model training.
- Visualization: Visualizer.py and other helper files (fn.py, pose_utils.py) support the drawing of results and possibly debugging.

##### File Structure to Define Container Boundaries
- Modules like “Actionsrecognition”, “Detection”, “SPPE”, and “Track” clearly delineate different pipeline phases.
- “Models” contains subdirectories for pre-trained models for different parts (TSSTG for ST-GCN, sppe for AlphaPose, and yolo-tiny-onecls for detection).
- The presence of loaders (e.g., DetectorLoader.py, PoseEstimateLoader.py, ActionsEstLoader.py) suggests a design where each component can be dynamically swapped or reloaded, which might be an architectural decision towards modularity.

- “Detection Module” to “Pose Estimation Module”, which leverages the SPPE pipeline (showing use of AlphaPose via SPPE’s components, such as FastPose models and associated layers). Also indicate the use of pre-trained SPPE models from “Models/sppe”.
- A “Visualization” block linked after tracking and action recognition to output results on screen or save visual debug files.
- For training or model updating, branch off a side process that includes the “Data” scripts and “Actionsrecognition/train.py”.

##### Relationships and Data Flow
- Dependency flows between the data input, processing modules, and output, highlighting that each module feeds processed information to the next stage.

##### Incorporate Architectural Patterns and Important Technologies
- The project leverages a modular design where each component (detection, pose estimation, tracking, recognition) is self-contained but integrated via loader scripts.
- Use of key libraries like PyTorch (for model inference/training), Python 3.6+ as specified, and dependency on CUDA (for GPU acceleration).
- That the modular “Loader” approach (e.g., DetectorLoader.py, PoseEstimateLoader.py) supports plug-and-play model integration, which is an important design principle.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Input Layer
    subgraph "Input Layer"
        VI["Video/Data Input"]:::input
    end

    %% Processing Pipeline
    subgraph "Processing Pipeline"
        D["Detection (Tiny-YOLO)"]:::detection
        PE["Pose Estimation (SPPE/AlphaPose)"]:::pose
        T["Tracking (KalmanFilter/IOU)"]:::tracking
        AR["Action Recognition (ST-GCN)"]:::action
        V["Visualization"]:::visualization
    end

    %% Training Lifecycle
    subgraph "Training Lifecycle"
        DC["Data Creation & Preprocessing"]:::training
        MT["Model Training"]:::training
    end

    %% Connections
    VI -->|"feeds"| D
    D -->|"processes"| PE
    PE -->|"estimates"| T
    PE -->|"estimates"| AR
    T -->|"tracks"| V
    AR -->|"predicts"| V
    DC -->|"prepares"| MT
    MT -.->|"updates"| AR

    %% Click Events for Video/Data Input
    click VI "https://github.com/gajuuzz/human-falling-detect-tracks/blob/master/main.py"
    click VI "https://github.com/gajuuzz/human-falling-detect-tracks/blob/master/CameraLoader.py"
    click VI "https://github.com/gajuuzz/human-falling-detect-tracks/blob/master/App.py"

    %% Click Events for Detection Module
    click D "https://github.com/gajuuzz/human-falling-detect-tracks/blob/master/Detection/Models.py"
    click D "https://github.com/gajuuzz/human-falling-detect-tracks/blob/master/Detection/Utils.py"
    click D "https://github.com/gajuuzz/human-falling-detect-tracks/blob/master/DetectorLoader.py"
    click D "https://github.com/gajuuzz/human-falling-detect-tracks/tree/master/Models/yolo-tiny-onecls"

    %% Click Events for Pose Estimation Module
    click PE "https://github.com/gajuuzz/human-falling-detect-tracks/blob/master/SPPE/src/main_fast_inference.py"
    click PE "https://github.com/gajuuzz/human-falling-detect-tracks/blob/master/SPPE/src/models/FastPose.py"
    click PE "https://github.com/gajuuzz/human-falling-detect-tracks/blob/master/PoseEstimateLoader.py"
    click PE "https://github.com/gajuuzz/human-falling-detect-tracks/tree/master/Models/sppe"

    %% Click Events for Tracking Module
    click T "https://github.com/gajuuzz/human-falling-detect-tracks/blob/master/Track/Tracker.py"
    click T "https://github.com/gajuuzz/human-falling-detect-tracks/blob/master/Track/iou_matching.py"
    click T "https://github.com/gajuuzz/human-falling-detect-tracks/blob/master/Track/kalman_filter.py"
    click T "https://github.com/gajuuzz/human-falling-detect-tracks/blob/master/Track/linear_assignment.py"

    %% Click Events for Action Recognition Module
    click AR "https://github.com/gajuuzz/human-falling-detect-tracks/blob/master/Actionsrecognition/Models.py"
    click AR "https://github.com/gajuuzz/human-falling-detect-tracks/blob/master/Actionsrecognition/Utils.py"
    click AR "https://github.com/gajuuzz/human-falling-detect-tracks/blob/master/Actionsrecognition/train.py"
    click AR "https://github.com/gajuuzz/human-falling-detect-tracks/blob/master/ActionsEstLoader.py"
    click AR "https://github.com/gajuuzz/human-falling-detect-tracks/tree/master/Models/TSSTG"

    %% Click Events for Preprocessing/Data Creation
    click DC "https://github.com/gajuuzz/human-falling-detect-tracks/blob/master/Data/create_dataset_1.py"
    click DC "https://github.com/gajuuzz/human-falling-detect-tracks/blob/master/Data/create_dataset_2.py"
    click DC "https://github.com/gajuuzz/human-falling-detect-tracks/blob/master/Data/create_dataset_3.py"

    %% Click Events for Visualization
    click V "https://github.com/gajuuzz/human-falling-detect-tracks/blob/master/Visualizer.py"
    click V "https://github.com/gajuuzz/human-falling-detect-tracks/blob/master/pose_utils.py"
    click V "https://github.com/gajuuzz/human-falling-detect-tracks/blob/master/fn.py"

    %% Styles
    classDef input fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef detection fill:#87CEFA,stroke:#000,stroke-width:2px;
    classDef pose fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef tracking fill:#FFD700,stroke:#000,stroke-width:2px;
    classDef action fill:#FF6347,stroke:#000,stroke-width:2px;
    classDef visualization fill:#DDA0DD,stroke:#000,stroke-width:2px;
    classDef training fill:#F0E68C,stroke:#000,stroke-width:2px;
```
