# krishte/nerf architecture

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

- Interactive diagram: https://gitdiagram.com/krishte/nerf
- Repository: https://github.com/krishte/nerf

## Overview

##### Project type and purpose
- This is a research-oriented deep learning project implementing Neural Radiance Fields (NeRF) in PyTorch.

##### File structure
- Top-level scripts:
- train.py – orchestrates training, loss computation, logging, checkpoint saving
- render.py – loads a trained model and generates renderings/video
- data_loader.py – reads input images, camera poses, prepares ray samples
- models.py – defines the NeRF MLP architectures (coarse and fine networks)
- Directories:
- checkpoints/ – serialized model weights at various training steps
- runs/ – TensorBoard logs for training experiments
- video_renders/ – output media (videos, depth maps, loss graphs)
- Configuration is implicit in command-line arguments to train.py and render.py; no heavy build scripts or microservices.

##### README for additional insights
- Core NeRF components: positional encoding, volumetric ray marching, hierarchical sampling.
- Training & rendering pipelines are separate entrypoints.
- Metrics: PSNR evaluation, TensorBoard logging.

##### Final advice
- Both the static structure (modules, files) and dynamic runtime flow (data paths).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Data Ingestion
    subgraph "Data Ingestion"
        DI1[/Images & Camera Poses/]:::data
        DL["DataLoader"]:::compute
    end

    %% Model Definition
    subgraph "Model"
        PE["Positional Encoding"]:::compute
        CM["Coarse NeRF MLP"]:::compute
        FM["Fine NeRF MLP"]:::compute
    end

    %% Volumetric Rendering
    subgraph "Volumetric Renderer"
        RM["Ray Marcher"]:::compute
        HS["Hierarchical Sampler"]:::compute
    end

    %% Training Loop
    subgraph "Training Loop"
        L["Loss Computation (Photometric + PSNR)"]:::control
        O["Optimizer & Backpropagation"]:::control
    end

    %% Storage & Logging
    CMgr[(Checkpoints)]:::data
    TB[(TensorBoard Logs)]:::data

    %% Rendering Pipeline
    subgraph "Rendering Pipeline"
        ML["Model Loader"]:::compute
        RV["Volume Renderer"]:::compute
        VW[/Video & Depth Maps Writer/]:::data
    end

    %% Data Flow Connections
    DI1 --> DL
    DL --> RM
    RM --> PE
    PE --> CM
    CM --> HS
    HS --> FM
    FM --> RM
    RM -->|"colors & density"| L
    L --> O
    O --> CMgr
    O --> TB

    %% Rendering Pipeline Flow
    CMgr --> ML
    ML --> RM
    RM --> VW

    %% Click Events
    click DL "https://github.com/krishte/nerf/blob/main/data_loader.py"
    click PE "https://github.com/krishte/nerf/blob/main/models.py"
    click CM "https://github.com/krishte/nerf/blob/main/models.py"
    click FM "https://github.com/krishte/nerf/blob/main/models.py"
    click RM "https://github.com/krishte/nerf/blob/main/render.py"
    click HS "https://github.com/krishte/nerf/blob/main/render.py"
    click L "https://github.com/krishte/nerf/blob/main/train.py"
    click O "https://github.com/krishte/nerf/blob/main/train.py"
    click CMgr "https://github.com/krishte/nerf/tree/main/checkpoints/"
    click TB "https://github.com/krishte/nerf/tree/main/runs/"
    click ML "https://github.com/krishte/nerf/blob/main/render.py"
    click VW "https://github.com/krishte/nerf/tree/main/video_renders/"

    %% Styles
    classDef data fill:#ADD8E6,stroke:#000;
    classDef compute fill:#90EE90,stroke:#000;
    classDef control fill:#FFA500,stroke:#000;
```
