# jorgeromeu/thesis architecture

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

- Interactive diagram: https://gitdiagram.com/jorgeromeu/thesis
- Repository: https://github.com/jorgeromeu/thesis

## Overview

##### Project type and purpose
- This is an open-source research framework (text3D2video) for controllable 4D-guided video generation. It provides a Python library of “pipelines” that integrate text-to-image diffusion models, 3D meshes/animations, and attention-based modules to generate temporally coherent videos.
- Key use cases: script-based experiments (under `scripts/`), interactive exploration (in `notebooks/`), and utility functions for Blender, logging, and artifact management.

##### File structure
- Top-level entrypoints:
- `scripts/` – CLI experiments & runs (e.g. `run_texgen.py`, `run_generative_rendering.py`)
- `blender_scripts/` – standalone Blender helpers for exporting USD animations
- `notebooks/`, `visual_tests/`, `tests/` – interactive and test environments
- Core library: `text3d2video/`
- `pipelines/` – base & specialized pipelines (ControlNet, Text-to-3D generation, style-aligned, generative rendering)
- `attn_processors/` – plugin modules for attention extraction/injection
- `artifacts/` – typed outputs (meshes, textures, videos)
- `utilities/` – broad helper functions (geometry, camera, logging, USD, video, image, FAISS, etc.)
- Config & environment: `env.yaml`, `requirements.txt`, `wandb_util/`

##### Key insights from README
- The framework relies on PyTorch (1.12+), PyTorch3D, FAISS, diffusion libraries, and optionally Blender.
- The user writes or runs scripts that instantiate a pipeline, provide a mesh/animation sequence, configure model checkpoints/parameters, and then generate outputs.

##### Detail level
- Do not collapse the core library into one monolithic block. Show sub-components: `pipelines`, `attn_processors`, `utilities`, `artifacts`.
- How utilities feed into pipelines (e.g. `geometry_processing`, `camera_utils`).
- Config management (env.yaml/CLI) as a separate component feeding into script entrypoints.
- Experiments scripts grouping (e.g. `scripts/wandb_runs/`) and how they differ from `scripts/wandb_experiments/`.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Entrypoints"
        CLI["CLI Scripts"]:::entry
        Blender["Blender Utilities"]:::entry
        NB["Notebooks"]:::entry
        VT["Visual Tests"]:::entry
    end

    Config["Configuration Layer"]:::config

    subgraph "Core Library"
        subgraph "Pipelines"
            BP["base_pipeline.py"]:::core
            TP["texgen_pipeline.py"]:::core
            CP["controlnet_pipeline.py"]:::core
            SP["style_aligned_pipeline.py"]:::core
            GP["generative_rendering_pipeline.py"]:::core
            PU["pipeline_utils.py"]:::core
        end
        subgraph "Attention Processors"
            AP["attn_processor.py"]:::core
            EI["extraction_injection_attn.py"]:::core
            FA["final_attn_processor.py"]:::core
            SA["style_aligned_attn.py"]:::core
        end
        subgraph "Artifact Classes"
            MA["mesh_artifact.py"]:::core
            TA["texture_artifact.py"]:::core
            AA["anim_artifact.py"]:::core
            VA["video_artifact.py"]:::core
        end
        subgraph "Utilities"
            GEO["geometry_processing.py"]:::core
            CAM["camera_utils.py"]:::core
            CP2["camera_placement.py"]:::core
            USDU["usd_utils.py"]:::core
            VU["video_util.py"]:::core
            VC["video_comparison.py"]:::core
            IU["image_utils.py"]:::core
            LOGU["logging.py"]:::core
            OCF["omegaconf_util.py"]:::core
            H5["h5_util.py"]:::core
            ATNU["attention_utils.py"]:::core
            VIS["attn_vis.py"]:::core
            MESHU["mesh_processing.py"]:::core
            COORD["coord_utils.py"]:::core
            RERUN["rerun_util.py"]:::core
            TESTU["testing_utils.py"]:::core
            IPY["ipython_utils.py"]:::core
            MPL["matplotlib_utils.py"]:::core
        end
        subgraph "Other Modules"
            FE["sd_feature_extraction.py"]:::core
            NI["noise_initialization.py"]:::core
            BP2["backprojection.py"]:::core
            REN["rendering.py"]:::core
            FV["feature_visualization.py"]:::core
            CM["clip_metrics.py"]:::core
            CT["camera_trajectories.py"]:::core
            UTIL["util.py"]:::core
        end
    end

    subgraph "Data & Assets"
        Meshes["Meshes"]:::data
        Sequences["Backflip Sequence"]:::data
    end

    subgraph "External Dependencies"
        Torch["PyTorch / Diffusers"]:::ext
        P3D["PyTorch3D"]:::ext
        FAISS["FAISS"]:::ext
        BlenderExt["Blender"]:::ext
        WNB["Weights & Biases"]:::ext
    end

    subgraph "Outputs & Storage"
        USDOut["USD Animations"]:::data
        VideoOut["Generated Videos"]:::data
        Logs["Logs / W&B Artifacts"]:::data
    end

    CLI -->|reads config| Config
    NB -->|reads config| Config
    VT -->|reads config| Config
    Blender -->|reads config| Config

    Config -->|provides parameters| BP

    CLI -->|load mesh/animation| Meshes
    NB -->|load mesh/animation| Meshes

    BP -->|orchestrates| AP
    AP -->|process attention| BP
    BP -->|calls utilities| GEO
    BP -->|uses utilities| CAM
    BP -->|loads features| FE
    BP -->|runs diffusion| Torch
    BP -->|runs 3D ops| P3D
    FE -->|uses| FAISS
    Blender -->|export USD| USDU
    USDU -->|writes| USDOut

    BP -->|produces| MA
    BP -->|produces| TA
    BP -->|produces| AA
    BP -->|produces| VA

    AA -->|serialize| USDOut
    VA -->|serialize| VideoOut
    LOGU -->|log metrics| WNB
    WNB -->|store| Logs

    classDef entry fill:#D6E8FF,stroke:#333,stroke-width:1px
    classDef core fill:#E2F0D9,stroke:#333,stroke-width:1px
    classDef ext fill:#E8E8E8,stroke:#333,stroke-width:1px
    classDef data fill:#FFE4B3,stroke:#333,stroke-width:1px
    classDef config fill:#F0F0F0,stroke:#333,stroke-width:1px

    click CLI "https://github.com/jorgeromeu/thesis/tree/main/scripts/"
    click Blender "https://github.com/jorgeromeu/thesis/blob/main/blender_scripts/export_blender_animation_usd.py"
    click NB "https://github.com/jorgeromeu/thesis/tree/main/notebooks/"
    click VT "https://github.com/jorgeromeu/thesis/tree/main/visual_tests/"
    click Config "https://github.com/jorgeromeu/thesis/blob/main/env.yaml"

    click BP "https://github.com/jorgeromeu/thesis/blob/main/text3d2video/pipelines/base_pipeline.py"
    click TP "https://github.com/jorgeromeu/thesis/blob/main/text3d2video/pipelines/texgen_pipeline.py"
    click CP "https://github.com/jorgeromeu/thesis/blob/main/text3d2video/pipelines/controlnet_pipeline.py"
    click SP "https://github.com/jorgeromeu/thesis/blob/main/text3d2video/pipelines/style_aligned_pipeline.py"
    click GP "https://github.com/jorgeromeu/thesis/blob/main/text3d2video/pipelines/generative_rendering_pipeline.py"
    click PU "https://github.com/jorgeromeu/thesis/blob/main/text3d2video/pipelines/pipeline_utils.py"

    click AP "https://github.com/jorgeromeu/thesis/blob/main/text3d2video/attn_processors/attn_processor.py"
    click EI "https://github.com/jorgeromeu/thesis/blob/main/text3d2video/attn_processors/extraction_injection_attn.py"
    click FA "https://github.com/jorgeromeu/thesis/blob/main/text3d2video/attn_processors/final_attn_processor.py"
    click SA "https://github.com/jorgeromeu/thesis/blob/main/text3d2video/attn_processors/style_aligned_attn.py"

    click MA "https://github.com/jorgeromeu/thesis/blob/main/text3d2video/artifacts/mesh_artifact.py"
    click TA "https://github.com/jorgeromeu/thesis/blob/main/text3d2video/artifacts/texture_artifact.py"
    click AA "https://github.com/jorgeromeu/thesis/blob/main/text3d2video/artifacts/anim_artifact.py"
    click VA "https://github.com/jorgeromeu/thesis/blob/main/text3d2video/artifacts/video_artifact.py"

    click GEO "https://github.com/jorgeromeu/thesis/blob/main/text3d2video/utilities/geometry_processing.py"
    click CAM "https://github.com/jorgeromeu/thesis/blob/main/text3d2video/utilities/camera_utils.py"
    click CP2 "https://github.com/jorgeromeu/thesis/blob/main/text3d2video/utilities/camera_placement.py"
    click USDU "https://github.com/jorgeromeu/thesis/blob/main/text3d2video/utilities/usd_utils.py"
    click VU "https://github.com/jorgeromeu/thesis/blob/main/text3d2video/utilities/video_util.py"
    click VC "https://github.com/jorgeromeu/thesis/blob/main/text3d2video/utilities/video_comparison.py"
    click IU "https://github.com/jorgeromeu/thesis/blob/main/text3d2video/utilities/image_utils.py"
    click LOGU "https://github.com/jorgeromeu/thesis/blob/main/text3d2video/utilities/logging.py"
    click OCF "https://github.com/jorgeromeu/thesis/blob/main/text3d2video/utilities/omegaconf_util.py"
    click H5 "https://github.com/jorgeromeu/thesis/blob/main/text3d2video/utilities/h5_util.py"
    click ATNU "https://github.com/jorgeromeu/thesis/blob/main/text3d2video/utilities/attention_utils.py"
    click VIS "https://github.com/jorgeromeu/thesis/blob/main/text3d2video/utilities/attn_vis.py"
    click MESHU "https://github.com/jorgeromeu/thesis/blob/main/text3d2video/utilities/mesh_processing.py"
    click COORD "https://github.com/jorgeromeu/thesis/blob/main/text3d2video/utilities/coord_utils.py"
    click RERUN "https://github.com/jorgeromeu/thesis/blob/main/text3d2video/utilities/rerun_util.py"
    click TESTU "https://github.com/jorgeromeu/thesis/blob/main/text3d2video/utilities/testing_utils.py"
    click IPY "https://github.com/jorgeromeu/thesis/blob/main/text3d2video/utilities/ipython_utils.py"
    click MPL "https://github.com/jorgeromeu/thesis/blob/main/text3d2video/utilities/matplotlib_utils.py"

    click FE "https://github.com/jorgeromeu/thesis/blob/main/text3d2video/sd_feature_extraction.py"
    click NI "https://github.com/jorgeromeu/thesis/blob/main/text3d2video/noise_initialization.py"
    click BP2 "https://github.com/jorgeromeu/thesis/blob/main/text3d2video/backprojection.py"
    click REN "https://github.com/jorgeromeu/thesis/blob/main/text3d2video/rendering.py"
    click FV "https://github.com/jorgeromeu/thesis/blob/main/text3d2video/feature_visualization.py"
    click CM "https://github.com/jorgeromeu/thesis/blob/main/text3d2video/clip_metrics.py"
    click CT "https://github.com/jorgeromeu/thesis/blob/main/text3d2video/camera_trajectories.py"
    click UTIL "https://github.com/jorgeromeu/thesis/blob/main/text3d2video/util.py"
```
