# runa91/bite_release architecture

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

- Interactive diagram: https://gitdiagram.com/runa91/bite_release
- Repository: https://github.com/runa91/bite_release

## Overview

##### File structure
- Top‐level “scripts” directory holds entry-point scripts for training (`train.py`, `train_withref.py`), inference (`full_inference_including_ttopt.py`), and demo (`gradio_demo.py`).
- “src” contains modular packages:
- bps_2d (body part segmentation snippets)
- combined_model (image → 3D prediction and refinement losses)
- graph_networks (graph CNN architectures and mesh utilities)
- smal_pytorch (differentiable renderer and SMAL animal model)
- stacked_hourglass (2D keypoint detection model, dataset loaders, loss, train/predict code)
- test_time_optimization (bite inference model plus TT-opt utilities)
- configs (YAML/JSON files for paths, hyperparameters, loss weights)
- metrics (evaluation metrics)
- Environment and dependency files: `requirements.txt`, `packages.txt`, plus standard Git config.

##### README for insights
- Confirms a two-stage training pipeline: first BARC+ (2D→3D breed‐aware regressor), then a refinement network (full BITE).
- Data preparation instructions show where “checkpoint,” “data,” and “datasets” live at runtime.
- Usage sections outline separate flows for training, inference, and a Gradio demo.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Data and Storage
    Data[("Data & Storage")]:::data

    %% Configuration
    Config["Configuration"]:::config

    %% Orchestration Scripts
    Scripts["Entry-Point Scripts"]:::orch

    %% Pipeline Stages
    Preprocessing["Preprocessing\n(Data Loading & Sampling)"]:::core
    Keypoint["2D Keypoint Detection\n(Stacked Hourglass)"]:::core
    Regression["3D Shape Regression\n(BARC+)"]:::core
    GraphCNN["Graph-Based CNN Components"]:::core
    Refinement["Refinement Module"]:::core
    Renderer["Differentiable Renderer & SMAL"]:::util
    TTOpt["Test-Time Optimization"]:::util

    %% Auxiliary Modules
    Priors["Shape Priors"]:::util
    Metrics["Evaluation Metrics"]:::util

    %% Pipeline Flow
    Data --> Preprocessing
    Preprocessing --> Keypoint
    Keypoint --> Regression
    Regression --> GraphCNN
    GraphCNN --> Refinement
    Refinement --> Renderer
    Renderer --> TTOpt

    %% Configuration Injection (dashed)
    Config -.-> Preprocessing
    Config -.-> Keypoint
    Config -.-> Regression
    Config -.-> Refinement
    Config -.-> Renderer
    Config -.-> TTOpt

    %% Orchestration Arrows
    Scripts -->|orchestrates| Preprocessing
    Scripts --> Keypoint
    Scripts --> Regression
    Scripts --> Refinement
    Scripts --> Renderer
    Scripts --> TTOpt
    Scripts --> Data

    %% Shape Priors Feed
    Priors --> Regression
    Priors --> Refinement

    %% Metrics usage
    Metrics --> Refinement
    Metrics --> TTOpt

    %% Legend
    subgraph Legend
        direction LR
        D["Data & Storage"]:::data
        C["Configuration"]:::config
        M["Core ML Modules"]:::core
        U["Utilities"]:::util
        O["Orchestration"]:::orch
        style Legend fill:none,stroke:none
    end

    %% Click Events
    click Config "https://github.com/runa91/bite_release/tree/master/src/configs/"
    click Preprocessing "https://github.com/runa91/bite_release/tree/master/src/stacked_hourglass/datasets/"
    click Keypoint "https://github.com/runa91/bite_release/blob/master/src/stacked_hourglass/model.py"
    click Keypoint "https://github.com/runa91/bite_release/blob/master/src/stacked_hourglass/predictor.py"
    click Keypoint "https://github.com/runa91/bite_release/blob/master/src/stacked_hourglass/loss.py"
    click Preprocessing "https://github.com/runa91/bite_release/blob/master/src/stacked_hourglass/datasets/utils_dataset_selection.py"
    click Preprocessing "https://github.com/runa91/bite_release/blob/master/src/bps_2d/bps_for_segmentation.py"
    click Regression "https://github.com/runa91/bite_release/blob/master/src/combined_model/model_shape_v7.py"
    click Regression "https://github.com/runa91/bite_release/blob/master/src/combined_model/model_shape_v7_withref_withgraphcnn.py"
    click Regression "https://github.com/runa91/bite_release/blob/master/src/combined_model/train_main_image_to_3d_withbreedrel.py"
    click Regression "https://github.com/runa91/bite_release/blob/master/src/combined_model/train_main_image_to_3d_wbr_withref.py"
    click Regression "https://github.com/runa91/bite_release/blob/master/src/combined_model/loss_image_to_3d_withbreedrel.py"
    click Regression "https://github.com/runa91/bite_release/tree/master/src/combined_model/loss_utils/"
    click GraphCNN "https://github.com/runa91/bite_release/blob/master/src/graph_networks/graphcmr/graph_cnn.py"
    click GraphCNN "https://github.com/runa91/bite_release/blob/master/src/graph_networks/graphcmr/utils_mesh.py"
    click GraphCNN "https://github.com/runa91/bite_release/blob/master/src/graph_networks/graphcmr/get_downsampled_mesh_npz.py"
    click Priors "https://github.com/runa91/bite_release/blob/master/src/priors/normalizing_flow_prior/normalizing_flow_prior.py"
    click Priors "https://github.com/runa91/bite_release/blob/master/src/priors/shape_prior.py"
    click Renderer "https://github.com/runa91/bite_release/blob/master/src/smal_pytorch/renderer/differentiable_renderer.py"
    click Renderer "https://github.com/runa91/bite_release/blob/master/src/smal_pytorch/smal_model/batch_lbs.py"
    click Renderer "https://github.com/runa91/bite_release/blob/master/src/smal_pytorch/smal_basics.py"
    click TTOpt "https://github.com/runa91/bite_release/blob/master/src/test_time_optimization/bite_inference_model_for_ttopt.py"
    click TTOpt "https://github.com/runa91/bite_release/blob/master/src/test_time_optimization/utils/utils_ttopt.py"
    click Metrics "https://github.com/runa91/bite_release/blob/master/src/metrics/metrics.py"
    click Scripts "https://github.com/runa91/bite_release/blob/master/scripts/train.py"
    click Scripts "https://github.com/runa91/bite_release/blob/master/scripts/train_withref.py"
    click Scripts "https://github.com/runa91/bite_release/blob/master/scripts/full_inference_including_ttopt.py"
    click Scripts "https://github.com/runa91/bite_release/blob/master/scripts/gradio_demo.py"

    %% Styles
    classDef data fill:#cce5ff,stroke:#3399ff,color:#000;
    classDef config fill:#e6e6e6,stroke:#999999,color:#000,stroke-dasharray: 5 5;
    classDef orch fill:#f2f2f2,stroke:#666666,color:#000;
    classDef core fill:#d4edda,stroke:#28a745,color:#000;
    classDef util fill:#fff3cd,stroke:#ffce54,color:#000;
```
