# lzzcd001/gshell architecture

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

- Interactive diagram: https://gitdiagram.com/lzzcd001/gshell
- Repository: https://github.com/lzzcd001/gshell

## Overview

##### Project Overview & Components Identification
- Project Type & Purpose:
– It covers two main functionalities: Reconstruction (i.e., converting multi-view images and other datasets into 3D mesh representations) and Generation (using diffusion-based generative models to produce new mesh designs).

- Main Components (as gleaned from the file tree and README):
– Data Management & Preprocessing:
- Directories like “data/tets”, “dataset”, “metadata”, and configuration files (in “configs”) indicate modules that prepare input tet-grid data, execute dataset normalization, and split train/test data.
– Diffusion & Generative Pipeline (GMeshDiffusion module):
- “GMeshDiffusion” directory contains diffusion configuration files, trainer scripts (trainer.py, trainer_ddp.py), model definitions (in diffusion/models/*), and evaluation/inference scripts.
- This component is responsible for running diffusion models that generate or modify mesh representations.
– Geometry Module:
- The “geometry” folder contains scripts for embedding, managing flexicubes and tet representations, and MLP modules tailored for geometry processing.
– Rendering & Visualization:
- The “render” folder, along with its nested “optixutils” and “renderutils” folders, implements mesh rendering, light/material handling, and CUDA/C++ interfacing for efficient rendering and (optionally) denoising.
– Additional Utilities:
- There are additional helper modules such as “denoiser” and “scripts” for running both inference (evaluation) and training under different conditions.
– External Dependencies & Configurations:
- The README lists essential requirements (e.g., PyTorch, CUDA, and specific packages like Pytorch3D) while the configs directory holds various JSON configurations for different model and dataset conditions (DeepFashion, NeRF, Polycam datasets).

- Data & Preprocessing Layer:
– Represent how raw data (mesh files, tet grids, camera poses, segmentation maps) flow from the “data” and “dataset” directories.
– Show preprocessing steps such as normalization, re-centering, and grid-generation (using scripts like “generate_tets.py” and “tet_to_cubic_grid_dataset.py”).
– Include configuration files from “configs” (e.g., deepfashion_mc.json, nerf_chair.json) that inform both reconstruction and generation pipelines.

- Diffusion/Generative Pipeline:
– Illustrate the “GMeshDiffusion” core sub-system.
– Map out internal submodules such as:
- Model definitions and network layers (under diffusion/models)
- Trainer modules (trainer.py and trainer_ddp.py) for both single-GPU and DDP (distributed) training
- Loss functions, likelihood computations, and sampling strategies (files in diffusion folder: losses.py, likelihood.py, sde_lib.py, etc.).

- Geometry Operations:
– Highlight the “geometry” module which transforms raw mesh and tet data into representations usable by diffusion models and renderers.
– Components like “gshell_tets.py” and “flexicubes_table.py” should be shown as a bridge between data preprocessing and model training (and also mesh conversion for rendering).

- Rendering & Denoising:
– Lay out the “render” component showing how rendered outputs (with realistic lighting, materials, and shading) are generated.
– Distinguish subcomponents:
- “render/light.py”, “render/material.py”, “render/mesh.py” for high-level rendering
- “render/optixutils” (with subdirectories for C/C++ and CUDA implementations) for low-level, performance-critical operations.
– Include a separate “denoiser” module, indicating its optional role in cleaning rendered outputs or generated images prior to evaluation.

- Training & Inference Scripts:
– Mark the main entry points (e.g., main_diffusion.py, main_diffusion_ddp.py) and training script files (such as train_gshelltet_deepfashion.py, train_gshelltet_polycam.py) as orchestration nodes that invoke the above modules based on the configuration.
– Also indicate evaluation paths in “scripts” and “eval_gmeshdiffusion_generated_samples.py” for performing inference and mesh extraction.

- External Systems & Dependencies:
– Clearly denote external libraries and frameworks (PyTorch, CUDA, Pytorch3D, kaolin, NVlabs’ libraries like nvdiffrast and tiny-cuda-nn).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Data & Preprocessing Layer"
        DP["Data Preparation: Tet Grid Generation"]:::data
        CF["Configuration Loader"]:::data
        MD["Metadata Operations"]:::data
    end

    subgraph "Diffusion & Generative Pipeline"
        DC["Diffusion Core"]:::diffusion
        TM["Trainer Modules"]:::diffusion
        DM["Diffusion Models"]:::diffusion
    end

    subgraph "Geometry Processing"
        GP["Geometry Operations"]:::geometry
    end

    subgraph "Rendering & Visualization"
        RP["Rendering Pipeline"]:::rendering
        OU["Optix Utilities"]:::rendering
        RU["Render Utilities"]:::rendering
        DN["Denoiser"]:::rendering
    end

    subgraph "Training & Inference Module"
        TI["Training and Inference Scripts"]:::train
    end

    EX1(("PyTorch,CUDA,Pytorch3D,etc.")):::external

    CF -->|"config_feeds"| DC
    CF -->|"config_feeds"| TM
    DP -->|"raw_data"| GP
    GP -->|"geometry_data"| TM
    DC -->|"controls"| TM
    TM -->|"uses_models"| DM
    GP -->|"geometry_to_render"| RP
    RP -->|"optionally_denoised_by"| DN
    TM -->|"initiate_training"| TI
    EX1 -->|"external_libs_to"| TM
    EX1 -->|"external_libs_to"| RP

    click DP "https://github.com/lzzcd001/gshell/tree/main/data/tets"
    click CF "https://github.com/lzzcd001/gshell/tree/main/configs/"
    click MD "https://github.com/lzzcd001/gshell/tree/main/GMeshDiffusion/metadata/"
    click DC "https://github.com/lzzcd001/gshell/blob/main/GMeshDiffusion/main_diffusion.py"
    click TM "https://github.com/lzzcd001/gshell/blob/main/GMeshDiffusion/lib/diffusion/trainer.py"
    click DM "https://github.com/lzzcd001/gshell/blob/main/GMeshDiffusion/lib/diffusion/models/unet3d_occgrid.py"
    click GP "https://github.com/lzzcd001/gshell/blob/main/geometry/gshell_tets.py"
    click RP "https://github.com/lzzcd001/gshell/blob/main/render/mesh.py"
    click OU "https://github.com/lzzcd001/gshell/tree/main/render/optixutils/"
    click RU "https://github.com/lzzcd001/gshell/tree/main/render/renderutils/"
    click DN "https://github.com/lzzcd001/gshell/blob/main/denoiser/denoiser.py"
    click TI "https://github.com/lzzcd001/gshell/blob/main/GMeshDiffusion/scripts/train_gshelltet_deepfashion.py"

    classDef data fill:#AED581,stroke:#33691E,stroke-width:2px;
    classDef diffusion fill:#81D4FA,stroke:#01579B,stroke-width:2px;
    classDef geometry fill:#FFCC80,stroke:#E65100,stroke-width:2px;
    classDef rendering fill:#CE93D8,stroke:#4A148C,stroke-width:2px;
    classDef train fill:#FFE082,stroke:#FF6F00,stroke-width:2px;
    classDef external fill:#FCE38A,stroke:#333,stroke-width:2px;
```
