# fyp-hyz-mjj-2024/posture_mmpose architecture

> Architecture diagram of the GitHub repository fyp-hyz-mjj-2024/posture_mmpose, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/fyp-hyz-mjj-2024/posture_mmpose
- Repository: https://github.com/fyp-hyz-mjj-2024/posture_mmpose

## Overview

##### Major Components
- User Interface & Entry Point:
- The project’s entry point is main.py. There is also a GUI.py indicating a graphical interface.
- Data Management:
- The “data” folder holds raw input data, training samples (in npy format) and pre-trained models (pth files).
- Annotation Module:
- The “step01_annotate_image_mmpose” package handles image annotation and keypoint configuration.
- Model Training (CNN):
- The “step02_train_model_cnn” module contains scripts to train a CNN model. This module likely uses annotated data derived from pose estimation outputs.
- Phone Detection Module:
- “step03_yolo_phone_detection” carries the YOLO-based phone detection. It contains configurations, scripts for model running and training (with ONNX checkpoints provided).
- Pre-configured Model & Checkpoint Repository:
- The “model_config” folder stores configuration files and checkpoint files for both the detection and the pose estimation modules.
- Core MMPose & MM Packages:
- A huge “mmpose_configs” directory indicates an extensive set of configuration submodules covering 2D/3D keypoints, face, hand, whole-body keypoint detection, etc.
- Utility Tools:
- The “utils” folder includes additional scripts (for file parsing, plotting, opencv utilities) implemented as helper tools.
- Project Documentation/Supporting Materials:
- “project_docs” holds reference materials, and there are LICENSE texts and Notes.md.

##### Data Flow & Interactions
- Start at the User Interface (GUI or directly via main.py). The user initiates the process.
- Raw input data is ingested:
- Videos/images (from the “data” folder) are fed into the annotation module (step01) where pose keypoint data is extracted using mmpose configurations.
- The annotated data then flows into a training pipeline:
- The “step02_train_model_cnn” module uses this output along with associated configurations to train a CNN that helps decide whether a pedestrian is using a cell phone.
- Simultaneously, the “step03_yolo_phone_detection” module is responsible for detecting phones through object detection:
- It uses YOLO-based models (with checkpoints stored under model_config and step03 directories) to separately detect the phone’s presence.
- Finally, the outputs from pose estimation and phone detection modules can be fused (within main.py or an integration layer) to arrive at the final prediction.

##### Architectural Patterns & Technologies
- Modularity & Separation of Concerns:
- Different steps (annotation, training, detection) are kept in separate packages.
- Configuration-Driven:
- Extensive use of configuration files (in model_config and mmpose_configs) for components indicates a decoupled design where models and parameters can be interchanged.
- Pipeline-based Processing:
- Data flows sequentially through preprocessing, pose estimation, object detection, training and inference – which can be depicted as separate pipeline stages.
- Deep Learning & Computer Vision Libraries:
- Use of PyTorch (specific 2.1.0 version), mmcv, mmdet, and mmpose is central. Represent these libraries near the respective modules.
- Environment & Dependency Management:

## Diagram (Mermaid)

```mermaid
graph TD
    %% Subgraph: User Interface
    subgraph "User Interface"
        UI1["main.py"]:::ui
        UI2["GUI.py"]:::ui
    end

    %% Core Components
    B["Data Repository (data)"]:::data
    C["Annotation Module (step01_annotate_image_mmpose)"]:::module
    D["Pose Estimation Configs (mmpose_configs)"]:::external
    E["CNN Training Module (step02_train_model_cnn)"]:::module
    F["YOLO Phone Detection (step03_yolo_phone_detection)"]:::module
    G["Model Config & Checkpoints (model_config)"]:::config
    K["Final Integration & Prediction"]:::integration
    H["Utility Tools (utils)"]:::utility
    I["Documentation (project_docs, LICENSE, Notes)"]:::data
    J["Deep Learning Frameworks (PyTorch, mmcv, mmdet, mmpose)"]:::external

    %% Data Flow Connections
    UI1 -->|"starts"| B
    UI2 -->|"starts"| B

    B -->|"provides raw images"| C
    G -->|"config feeds"| C
    D -->|"mmpose parameters"| C

    C -->|"annotated data"| E

    B -->|"raw images"| F
    G -->|"model configs"| F

    E -->|"training output"| K
    F -->|"detection output"| K

    K -->|"results back"| UI1

    %% Utility and Dependency Support (dashed links)
    H -.-> C
    H -.-> E
    H -.-> F

    J -.-> E
    J -.-> F

    %% Class Definitions for Color Coding
    classDef ui fill:#f9c,stroke:#333,stroke-width:2px;
    classDef data fill:#bbf,stroke:#333,stroke-width:2px;
    classDef module fill:#afa,stroke:#333,stroke-width:2px;
    classDef config fill:#ffb,stroke:#333,stroke-width:2px;
    classDef integration fill:#fda,stroke:#333,stroke-width:2px;
    classDef external fill:#eef,stroke:#333,stroke-width:2px;
    classDef utility fill:#ddd,stroke:#333,stroke-dasharray: 5,5;

    %% Click Events
    click UI1 "https://github.com/fyp-hyz-mjj-2024/posture_mmpose/blob/master/main.py"
    click UI2 "https://github.com/fyp-hyz-mjj-2024/posture_mmpose/blob/master/GUI.py"
    click B "https://github.com/fyp-hyz-mjj-2024/posture_mmpose/tree/master/data/"
    click C "https://github.com/fyp-hyz-mjj-2024/posture_mmpose/tree/master/step01_annotate_image_mmpose/"
    click E "https://github.com/fyp-hyz-mjj-2024/posture_mmpose/tree/master/step02_train_model_cnn/"
    click F "https://github.com/fyp-hyz-mjj-2024/posture_mmpose/tree/master/step03_yolo_phone_detection/"
    click G "https://github.com/fyp-hyz-mjj-2024/posture_mmpose/tree/master/model_config/"
    click D "https://github.com/fyp-hyz-mjj-2024/posture_mmpose/tree/master/mmpose_configs/"
    click H "https://github.com/fyp-hyz-mjj-2024/posture_mmpose/tree/master/utils/"
    click I "https://github.com/fyp-hyz-mjj-2024/posture_mmpose/tree/master/project_docs/"
```
