# fvl2020/2dimage2bmi architecture

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

- Interactive diagram: https://gitdiagram.com/fvl2020/2dimage2bmi
- Repository: https://github.com/fvl2020/2dimage2bmi

## Overview

##### Project type and purpose
- This is a full-stack research codebase for estimating human weight (BMI) from a single 2D image.

##### File structure
Top-level:
- ALL_feature/ – CSVs of precomputed features (train & test).
- bodyfeature/ – placeholders for anthropometric computations.
- modeling/ – PyTorch model definitions (resnet, segmentation module, affine alignment, skeleton feature extractor, build_model.py, templates.json).
- model.py – likely an entry point to assemble and run the network.
- util.py – shared utilities.
Key scripts:
- Data pipeline: Data.py (I/O), Datasets_BFDF.py (custom Dataset).
- Preprocessing/Extraction: Detected.py (object detection via Detectron2), Human_Parse.py (human parsing), BodyFeatureExtractor.py, DeepFeatureExtractor.py.
- Aggregation & regression: CombineAndRegress.py, OtherTypeNet.py.
- Lifecycle: Training.py (training loop, tensorboardX logging), Regression.py (inference/test), ANOVATest.py (statistical analysis).

##### README for additional insights
- Describes dual-branch architecture.
- Lists dependencies: PyTorch, CUDA, Detectron2, scikit-learn, scipy, pandas, OpenCV, tensorboardX.
- Points to pretrained models (downloaded from Google Drive).
- Shows result plots, cites the IEEE TMM paper.

##### Final recommendations
- Be very thorough: capture all Python scripts, modules, and data assets as distinct nodes.
- Don’t overcomplicate—focus on separating the project into logical components matching the file structure and README description.
- Reference the existing framework/framework.jpg as a starting template; expand it to show data I/O, training loop, and evaluation stages in detail.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data & I/O
    subgraph "Data & I/O"
        RawImages(("Raw Images Dataset")):::data
        CSVs(("Precomputed Feature CSVs")):::data
        DataPy([/Data.py/]):::data
        Datasets([/Datasets_BFDF.py/]):::data
        Util(["util.py"]):::data
    end

    %% Preprocessing & Detection
    subgraph "Preprocessing & Detection"
        Detected(["Detected.py"]):::pre
        HumanParse(["Human_Parse.py"]):::pre
        Skeleton(["skeleton_feat.py"]):::pre
    end

    %% Anthropometric Feature Branch
    subgraph "Anthropometric Feature Branch"
        BodyExtractor(["BodyFeatureExtractor.py"]):::feat
        BodyFeatureDir(["bodyfeature/"]):::feat
    end

    %% Deep Feature Branch
    subgraph "Deep Feature Branch"
        DeepExtractor(["DeepFeatureExtractor.py"]):::feat
        ResNet(["resnet.py"]):::feat
        SegModule(["seg_module.py"]):::feat
    end

    %% Aggregation & Regression
    subgraph "Aggregation & Regression"
        CombineReg(["CombineAndRegress.py"]):::agg
        OtherNet(["OtherTypeNet.py"]):::agg
        BuildModel(["build_model.py"]):::agg
        ModelEntry(["model.py"]):::agg
    end

    %% Training & Evaluation
    subgraph "Training & Evaluation"
        Training(["Training.py"]):::eval
        Regression(["Regression.py"]):::eval
        ANOVA(["ANOVATest.py"]):::eval
    end

    %% Data Flow
    RawImages --> DataPy
    RawImages --> Datasets
    DataPy --> Detected
    DataPy --> HumanParse
    DataPy --> Skeleton
    Datasets --> Detected
    Datasets --> HumanParse
    Datasets --> Skeleton
    Util --> DataPy
    Util --> Datasets
    Util --> Detected
    Util --> HumanParse
    Util --> Skeleton

    Detected --> BodyExtractor
    HumanParse --> BodyExtractor
    Skeleton --> BodyExtractor

    Detected --> DeepExtractor
    HumanParse --> DeepExtractor
    Skeleton --> DeepExtractor

    BodyExtractor --> CombineReg
    BodyFeatureDir --> BodyExtractor

    DeepExtractor --> CombineReg
    ResNet --> DeepExtractor
    SegModule --> DeepExtractor

    CombineReg --> ModelEntry
    OtherNet --> CombineReg
    BuildModel --> CombineReg

    ModelEntry --> Training
    ModelEntry --> Regression

    Training --> BuildModel
    Regression --> ANOVA
    CSVs --> ANOVA
    CSVs --> Training

    %% Click Events
    click CSVs "https://github.com/fvl2020/2dimage2bmi/blob/main/ALL_feature/Image_train.csv"
    click CSVs "https://github.com/fvl2020/2dimage2bmi/blob/main/ALL_feature/Image_test.csv"
    click Detected "https://github.com/fvl2020/2dimage2bmi/blob/main/Detected.py"
    click HumanParse "https://github.com/fvl2020/2dimage2bmi/blob/main/Human_Parse.py"
    click Skeleton "https://github.com/fvl2020/2dimage2bmi/blob/main/modeling/skeleton_feat.py"
    click BodyExtractor "https://github.com/fvl2020/2dimage2bmi/blob/main/BodyFeatureExtractor.py"
    click BodyFeatureDir "https://github.com/fvl2020/2dimage2bmi/tree/main/bodyfeature/"
    click DeepExtractor "https://github.com/fvl2020/2dimage2bmi/blob/main/DeepFeatureExtractor.py"
    click ResNet "https://github.com/fvl2020/2dimage2bmi/blob/main/modeling/resnet.py"
    click SegModule "https://github.com/fvl2020/2dimage2bmi/blob/main/modeling/seg_module.py"
    click CombineReg "https://github.com/fvl2020/2dimage2bmi/blob/main/CombineAndRegress.py"
    click OtherNet "https://github.com/fvl2020/2dimage2bmi/blob/main/OtherTypeNet.py"
    click BuildModel "https://github.com/fvl2020/2dimage2bmi/blob/main/modeling/build_model.py"
    click ModelEntry "https://github.com/fvl2020/2dimage2bmi/blob/main/model.py"
    click Training "https://github.com/fvl2020/2dimage2bmi/blob/main/Training.py"
    click Regression "https://github.com/fvl2020/2dimage2bmi/blob/main/Regression.py"
    click ANOVA "https://github.com/fvl2020/2dimage2bmi/blob/main/ANOVATest.py"
    click DataPy "https://github.com/fvl2020/2dimage2bmi/blob/main/Data.py"
    click Datasets "https://github.com/fvl2020/2dimage2bmi/blob/main/Datasets_BFDF.py"
    click Util "https://github.com/fvl2020/2dimage2bmi/blob/main/util.py"

    %% Styles
    classDef data fill:#BBDEFB,stroke:#1E88E5,color:#0D47A1;
    classDef pre fill:#C8E6C9,stroke:#388E3C,color:#1B5E20;
    classDef feat fill:#FFE0B2,stroke:#FB8C00,color:#E65100;
    classDef agg fill:#E1BEE7,stroke:#8E24AA,color:#4A148C;
    classDef eval fill:#FFCDD2,stroke:#E53935,color:#B71C1C;
```
