# jeremyhaow/s2nerf architecture

> Architecture diagram of the GitHub repository jeremyhaow/s2nerf, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jeremyhaow/s2nerf
- Repository: https://github.com/jeremyhaow/s2nerf

## Overview

This repository is a NeRF training and rendering application with custom CUDA-backed encoders and ray marching. The main workflow loads a scene dataset, constructs a NeRF model and trainer, trains, then evaluates, renders video, and exports a mesh. The README provides no capability detail, so this map reflects the sampled entry point and source references; unsampled subsystem behavior and connections are not inferred.

Main entry points: [`nerf/network.py`](https://github.com/jeremyhaow/s2nerf/blob/main/nerf/network.py) (NeRF network), [`main_nerf.py`](https://github.com/jeremyhaow/s2nerf/blob/main/main_nerf.py) (Experiment entry), [`encoding.py`](https://github.com/jeremyhaow/s2nerf/blob/main/encoding.py) (Encoding selection), [`nerf/provider.py`](https://github.com/jeremyhaow/s2nerf/blob/main/nerf/provider.py) (Scene dataset)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["NeRF application"]
  node_entry["Experiment entry<br/>[main_nerf.py]"]
  node_dataset["Scene dataset<br/>[provider.py]"]
  node_camera["Ray generation<br/>[utils.py]"]
  node_model["NeRF network<br/>[network.py]"]
  node_training["Training and evaluation<br/>[trainer.py]"]
  node_loss["Loss functions<br/>[loss.py]"]
  node_activation["Gradient activations<br/>[activation.py]"]
end

subgraph group_encoding["Feature encoders"]
  node_encoding_api["Encoding selection<br/>[encoding.py]"]
  node_grid["Grid encoding<br/>[grid.py]"]
  node_frequency["Frequency encoding<br/>[freq.py]"]
  node_spherical["Spherical harmonics"]
end

subgraph group_render["Ray rendering"]
  node_renderer["Volume renderer<br/>[renderer.py]"]
  node_marching["Ray marching operations<br/>[raymarching.py]"]
end

subgraph group_cuda["CUDA backends"]
  node_grid_cuda["Grid CUDA kernels<br/>[gridencoder.h]"]
  node_frequency_cuda["Frequency CUDA backend<br/>[freqencoder.h]"]
  node_spherical_cuda["SH CUDA backend<br/>[shencoder.h]"]
  node_marching_cuda["Ray-marching CUDA kernels<br/>[raymarching.h]"]
end

node_user(("CLI user"))

node_user -->|"configures and runs"| node_entry
node_entry -->|"constructs loaders"| node_dataset
node_entry -->|"constructs"| node_model
node_entry -->|"starts training"| node_training
node_dataset -->|"uses ray utilities"| node_camera
node_training -->|"renders predictions"| node_model
node_model -->|"uses"| node_activation
node_model -->|"uses encodings"| node_encoding_api
node_model -->|"uses renderer"| node_renderer
node_encoding_api -->|"selects"| node_grid
node_encoding_api -->|"selects"| node_spherical
node_grid -->|"dispatches kernels"| node_grid_cuda
node_frequency -->|"dispatches kernels"| node_frequency_cuda
node_spherical -->|"dispatches kernels"| node_spherical_cuda
node_renderer -->|"uses ray operations"| node_marching
node_marching -->|"dispatches kernels"| node_marching_cuda

click node_entry "https://github.com/jeremyhaow/s2nerf/blob/main/main_nerf.py"
click node_dataset "https://github.com/jeremyhaow/s2nerf/blob/main/nerf/provider.py"
click node_camera "https://github.com/jeremyhaow/s2nerf/blob/main/nerf/utils.py"
click node_model "https://github.com/jeremyhaow/s2nerf/blob/main/nerf/network.py"
click node_training "https://github.com/jeremyhaow/s2nerf/blob/main/nerf/trainer.py"
click node_loss "https://github.com/jeremyhaow/s2nerf/blob/main/loss.py"
click node_activation "https://github.com/jeremyhaow/s2nerf/blob/main/activation.py"
click node_encoding_api "https://github.com/jeremyhaow/s2nerf/blob/main/encoding.py"
click node_grid "https://github.com/jeremyhaow/s2nerf/blob/main/gridencoder/grid.py"
click node_grid_cuda "https://github.com/jeremyhaow/s2nerf/blob/main/gridencoder/src/gridencoder.h"
click node_frequency "https://github.com/jeremyhaow/s2nerf/blob/main/freqencoder/freq.py"
click node_frequency_cuda "https://github.com/jeremyhaow/s2nerf/blob/main/freqencoder/src/freqencoder.h"
click node_spherical "https://github.com/jeremyhaow/s2nerf/blob/main/shencoder/sphere_harmonics.py"
click node_spherical_cuda "https://github.com/jeremyhaow/s2nerf/blob/main/shencoder/src/shencoder.h"
click node_renderer "https://github.com/jeremyhaow/s2nerf/blob/main/nerf/renderer.py"
click node_marching "https://github.com/jeremyhaow/s2nerf/blob/main/raymarching/raymarching.py"
click node_marching_cuda "https://github.com/jeremyhaow/s2nerf/blob/main/raymarching/src/raymarching.h"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_entry,node_dataset,node_camera,node_model,node_training,node_loss,node_activation,node_user toneBlue
class node_encoding_api,node_grid,node_frequency,node_spherical toneAmber
class node_renderer,node_marching toneMint
class node_grid_cuda,node_frequency_cuda,node_spherical_cuda,node_marching_cuda toneRose
```

## Components

### NeRF application

- [Experiment entry](https://github.com/jeremyhaow/s2nerf/blob/main/main_nerf.py): `main_nerf.py`
- [Scene dataset](https://github.com/jeremyhaow/s2nerf/blob/main/nerf/provider.py): `nerf/provider.py`
- [Ray generation](https://github.com/jeremyhaow/s2nerf/blob/main/nerf/utils.py): `nerf/utils.py`
- [NeRF network](https://github.com/jeremyhaow/s2nerf/blob/main/nerf/network.py): `nerf/network.py`
- [Training and evaluation](https://github.com/jeremyhaow/s2nerf/blob/main/nerf/trainer.py): `nerf/trainer.py`
- [Loss functions](https://github.com/jeremyhaow/s2nerf/blob/main/loss.py): `loss.py`
- [Gradient activations](https://github.com/jeremyhaow/s2nerf/blob/main/activation.py): `activation.py`

### Feature encoders

- [Encoding selection](https://github.com/jeremyhaow/s2nerf/blob/main/encoding.py): `encoding.py`
- [Grid encoding](https://github.com/jeremyhaow/s2nerf/blob/main/gridencoder/grid.py): `gridencoder/grid.py`
- [Frequency encoding](https://github.com/jeremyhaow/s2nerf/blob/main/freqencoder/freq.py): `freqencoder/freq.py`
- [Spherical harmonics](https://github.com/jeremyhaow/s2nerf/blob/main/shencoder/sphere_harmonics.py): `shencoder/sphere_harmonics.py`

### Ray rendering

- [Volume renderer](https://github.com/jeremyhaow/s2nerf/blob/main/nerf/renderer.py): `nerf/renderer.py`
- [Ray marching operations](https://github.com/jeremyhaow/s2nerf/blob/main/raymarching/raymarching.py): `raymarching/raymarching.py`

### CUDA backends

- [Grid CUDA kernels](https://github.com/jeremyhaow/s2nerf/blob/main/gridencoder/src/gridencoder.h): `gridencoder/src/gridencoder.h`
- [Frequency CUDA backend](https://github.com/jeremyhaow/s2nerf/blob/main/freqencoder/src/freqencoder.h): `freqencoder/src/freqencoder.h`
- [SH CUDA backend](https://github.com/jeremyhaow/s2nerf/blob/main/shencoder/src/shencoder.h): `shencoder/src/shencoder.h`
- [Ray-marching CUDA kernels](https://github.com/jeremyhaow/s2nerf/blob/main/raymarching/src/raymarching.h): `raymarching/src/raymarching.h`

### Other components

- **CLI user**

## Connections

- CLI user → Experiment entry: configures and runs (evidence: `main_nerf.py`)
- Experiment entry → Scene dataset: constructs loaders (evidence: `main_nerf.py`)
- Experiment entry → NeRF network: constructs (evidence: `main_nerf.py`)
- Experiment entry → Training and evaluation: starts training (evidence: `main_nerf.py`)
- Scene dataset → Ray generation: uses ray utilities (evidence: `nerf/provider.py`)
- Training and evaluation → NeRF network: renders predictions (evidence: `nerf/trainer.py`)
- NeRF network → Gradient activations: uses (evidence: `nerf/network.py`)
- NeRF network → Encoding selection: uses encodings (evidence: `nerf/network.py`)
- NeRF network → Volume renderer: uses renderer (evidence: `nerf/network.py`)
- Encoding selection → Grid encoding: selects (evidence: `encoding.py`)
- Encoding selection → Spherical harmonics: selects (evidence: `encoding.py`)
- Grid encoding → Grid CUDA kernels: dispatches kernels (evidence: `gridencoder/grid.py`)
- Frequency encoding → Frequency CUDA backend: dispatches kernels (evidence: `freqencoder/freq.py`)
- Spherical harmonics → SH CUDA backend: dispatches kernels (evidence: `shencoder/sphere_harmonics.py`)
- Volume renderer → Ray marching operations: uses ray operations (evidence: `nerf/renderer.py`)
- Ray marching operations → Ray-marching CUDA kernels: dispatches kernels (evidence: `raymarching/raymarching.py`)
