# anuragmundhada/pose-hgreg-gan architecture

> Architecture diagram of the GitHub repository anuragmundhada/pose-hgreg-gan, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/anuragmundhada/pose-hgreg-gan
- Repository: https://github.com/anuragmundhada/pose-hgreg-gan

## Overview

##### Project type and purpose
- This is a research‐oriented machine‑learning pipeline for 3D human‑pose estimation using a GAN (generator + discriminator) approach in PyTorch, providing weak depth supervision when full 3D ground truth is unavailable.

##### File structure
- Top‑level “data/” holds raw datasets (Human3.6M, MPII) with annotations.
- “exp/” is the experiment output root (checkpoints, logs).
- “src/” contains:
- datasets/ – data loaders and wrappers (h36m.py, mpii.py, fusion.py)
- models/ – network definitions (hg_3d.py, hg_3d_gan.py, discriminators.py) and custom layers (Residual, FusionCriterion, adversarial losses)
- train.py & demo.py – entry points for training and inference
- main.py – orchestrates parsing options (opts.py), kicking off train/ref processes
- utils/ – logging, image/pose utilities, evaluation metrics
- tools/ – dataset download/preparation scripts
- Config and dependency hints: readme.md (PyTorch, h5py, OpenCV, tensorboard), .gitignore, LICENSE.

##### README
- Confirms GAN approach for weak supervision, based on Zhou et al.’s PyTorch pose code.
- Lists deep‑learning stack and optional tensorboard.

1. Data Sources
- raw H36M & MPII folders
- annotation files (.h5, .mat, .txt)
2. Data Loader & Preprocessing
- src/datasets modules
- normalization, augmentation (fusion.py)
3. Model
- Generator (hg_3d.py)
- Discriminator (discriminators.py)
- Custom Layers (Residual, FusionCriterionAdversarial)
4. Training Engine
- train.py orchestrating forward/backward passes
- Loss computation (L2, adversarial)
- Optimizer step (SGD/Adam)
5. Evaluation & Metrics
- src/utils/eval.py
- tensorboard summaries / progress bar
6. Experiment Management
- src/utils/logger.py
- exp/ checkpoint storage
7. Demo / Inference
- demo.py for visualization of predicted 3D pose
8. Supporting Tools
- tools/GetH36M.py

- Data Sources → Data Loader
- Data Loader → Model (Generator + Discriminator)
- Model outputs & ground‑truth → Loss Module
- Loss Module → Training Engine → Model weights
- Training Engine → Experiment Manager (logging, checkpoints)
- Model weights → Demo / Inference

c. Architectural patterns & principles:
- Layered modular structure (separate folders for datasets, models, utils)
- Clear separation of concerns: data ingestion, model definition, training loop, evaluation
- Reusable components: custom layers and loss criteria factored into their own modules
- Script‑based orchestration (main.py, train.py, demo.py)

d. Key technologies & frameworks:
- PyTorch (core deep‑learning)
- Python h5py, OpenCV (data handling)
- Optional TensorBoard for visualization
- Standard Python packaging and script invocation

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Sources
    subgraph "Data Sources"
        H36M["H36M Dataset<br/>(data/h36m/)"]:::data
        MPII["MPII Dataset<br/>(data/mpii/)"]:::data
    end

    %% Data Loader & Preprocessing
    subgraph "Data Loader & Preprocessing"
        LoaderH36M["h36m.py<br/>(src/datasets/h36m.py)"]:::loader
        LoaderMPII["mpii.py<br/>(src/datasets/mpii.py)"]:::loader
        Fusion["fusion.py<br/>(src/datasets/fusion.py)"]:::loader
    end

    %% Models
    subgraph "Models"
        subgraph "Generator"
            GeneratorHG["hg_3d.py<br/>(src/models/hg_3d.py)"]:::model
            GeneratorGAN["hg_3d_gan.py<br/>(src/models/hg_3d_gan.py)"]:::model
        end
        subgraph "Discriminator"
            Discriminator["discriminators.py<br/>(src/models/discriminators.py)"]:::model
        end
        subgraph "Custom Layers & Loss"
            ResLayer["Residual.py<br/>(src/models/layers/Residual.py)"]:::model
            FusionCrit["FusionCriterion.py<br/>(src/models/layers/FusionCriterion.py)"]:::model
            AdvCrit["FusionCriterionAdversarial.py<br/>(src/models/layers/FusionCriterionAdversarial.py)"]:::model
        end
    end

    %% Training Engine & Orchestration
    subgraph "Training Engine"
        Main["main.py<br/>(src/main.py)"]:::engine
        Train["train.py<br/>(src/train.py)"]:::engine
        Opts["opts.py<br/>(src/opts.py)"]:::engine
    end

    %% Evaluation & Metrics
    subgraph "Evaluation & Metrics"
        Eval["eval.py<br/>(src/utils/eval.py)"]:::utils
    end

    %% Logging & Experiment Management
    subgraph "Logging & Experiment Management"
        Logger["logger.py<br/>(src/utils/logger.py)"]:::utils
        ExpOut["exp/"]:::experiment
    end

    %% Demo / Inference
    Demo["demo.py<br/>(src/demo.py)"]:::demo

    %% Supporting Tools
    subgraph "Supporting Tools"
        GetH36M["GetH36M.py<br/>(src/tools/GetH36M.py)"]:::tools
    end

    %% Data Flow
    H36M --> LoaderH36M
    MPII --> LoaderMPII
    LoaderH36M --> GeneratorHG
    LoaderMPII --> GeneratorHG
    Fusion --> GeneratorHG
    GeneratorHG --> Discriminator
    Discriminator --> AdvCrit
    ResLayer --> GeneratorHG
    FusionCrit --> GeneratorHG
    AdvCrit --> Train
    GeneratorHG --> Train
    Main --> Train
    Opts --> Train
    Train --> Logger
    Train --> ExpOut
    Train --> Eval
    Train --> GeneratorHG
    GeneratorHG --> Demo

    %% Click Events
    click H36M "https://github.com/anuragmundhada/pose-hgreg-gan/tree/GAN/data/h36m/"
    click MPII "https://github.com/anuragmundhada/pose-hgreg-gan/tree/GAN/data/mpii/"
    click LoaderH36M "https://github.com/anuragmundhada/pose-hgreg-gan/blob/GAN/src/datasets/h36m.py"
    click LoaderMPII "https://github.com/anuragmundhada/pose-hgreg-gan/blob/GAN/src/datasets/mpii.py"
    click Fusion "https://github.com/anuragmundhada/pose-hgreg-gan/blob/GAN/src/datasets/fusion.py"
    click GeneratorHG "https://github.com/anuragmundhada/pose-hgreg-gan/blob/GAN/src/models/hg_3d.py"
    click GeneratorGAN "https://github.com/anuragmundhada/pose-hgreg-gan/blob/GAN/src/models/hg_3d_gan.py"
    click Discriminator "https://github.com/anuragmundhada/pose-hgreg-gan/blob/GAN/src/models/discriminators.py"
    click ResLayer "https://github.com/anuragmundhada/pose-hgreg-gan/blob/GAN/src/models/layers/Residual.py"
    click FusionCrit "https://github.com/anuragmundhada/pose-hgreg-gan/blob/GAN/src/models/layers/FusionCriterion.py"
    click AdvCrit "https://github.com/anuragmundhada/pose-hgreg-gan/blob/GAN/src/models/layers/FusionCriterionAdversarial.py"
    click Main "https://github.com/anuragmundhada/pose-hgreg-gan/blob/GAN/src/main.py"
    click Train "https://github.com/anuragmundhada/pose-hgreg-gan/blob/GAN/src/train.py"
    click Opts "https://github.com/anuragmundhada/pose-hgreg-gan/blob/GAN/src/opts.py"
    click Eval "https://github.com/anuragmundhada/pose-hgreg-gan/blob/GAN/src/utils/eval.py"
    click Logger "https://github.com/anuragmundhada/pose-hgreg-gan/blob/GAN/src/utils/logger.py"
    click ExpOut "https://github.com/anuragmundhada/pose-hgreg-gan/tree/GAN/exp/"
    click Demo "https://github.com/anuragmundhada/pose-hgreg-gan/blob/GAN/src/demo.py"
    click GetH36M "https://github.com/anuragmundhada/pose-hgreg-gan/blob/GAN/src/tools/GetH36M.py"

    %% Styles
    classDef data fill:#AEDFF7,stroke:#333,stroke-width:1px
    classDef loader fill:#C8E6C9,stroke:#333,stroke-width:1px
    classDef model fill:#F8BBD0,stroke:#333,stroke-width:1px
    classDef engine fill:#FFD54F,stroke:#333,stroke-width:1px
    classDef utils fill:#FFF59D,stroke:#333,stroke-width:1px
    classDef experiment fill:#CFD8DC,stroke:#333,stroke-width:1px
    classDef demo fill:#E1BEE7,stroke:#333,stroke-width:1px
    classDef tools fill:#FFCCBC,stroke:#333,stroke-width:1px
```
