# ziyang-xie/worldgen architecture

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

- Interactive diagram: https://gitdiagram.com/ziyang-xie/worldgen
- Repository: https://github.com/ziyang-xie/worldgen

## Overview

WorldGen turns a text prompt or source image into a panorama, estimates its depth, and converts the panorama into an explorable 3D scene as Gaussian splats or a mesh. Optional branches add foreground-aware background inpainting and the experimental Sharp Gaussian predictor. The graph includes the documented Viser exploration workflow and the main panorama/geometry support layers; relationships for unsampled implementation details are omitted rather than inferred.

Main entry points: [`src/worldgen/worldgen.py`](https://github.com/ziyang-xie/worldgen/blob/main/src/worldgen/worldgen.py) (WorldGen API), [`src/worldgen/pano_gen.py`](https://github.com/ziyang-xie/worldgen/blob/main/src/worldgen/pano_gen.py) (Panorama generation), [`src/worldgen/utils/general_utils.py`](https://github.com/ziyang-xie/worldgen/blob/main/src/worldgen/utils/general_utils.py) (Panorama geometry utilities), [`demo.py`](https://github.com/ziyang-xie/worldgen/blob/main/demo.py) (Viser demo)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Scene workflow"]
  node_worldgen["WorldGen API<br/>[worldgen.py]"]
  node_seg["Foreground segmentation<br/>[pano_seg.py]"]
  node_inpaint["Background inpainting<br/>[pano_inpaint.py]"]
  node_lama["LaMa model<br/>[inpaint_model.py]"]
end

subgraph group_panorama["Panorama generation"]
  node_pano_gen["Panorama generation<br/>[pano_gen.py]"]
  node_flux_gen["FLUX panorama pipeline"]
  node_flux_fill["FLUX fill pipeline"]
end

subgraph group_geometry["Depth and geometry"]
  node_depth["Panorama depth<br/>[pano_depth.py]"]
  node_sharp["Sharp splat prediction<br/>[pano_sharp.py]"]
  node_splat["Gaussian splat utilities<br/>[splat_utils.py]"]
end

subgraph group_support["Shared support"]
  node_general["Panorama geometry utilities<br/>[general_utils.py]"]
  node_equirect["Equirectangular transforms<br/>[equirectangular.py]"]
  node_lora["LoRA utilities<br/>[lora_utils.py]"]
end

subgraph group_explore["Scene exploration"]
  node_demo["Viser demo<br/>[demo.py]"]
  node_viser["Viser viewer"]
end

node_user(("User"))

node_user -->|"requests scene"| node_worldgen
node_worldgen -->|"generates panorama"| node_pano_gen
node_pano_gen -->|"runs text pipeline"| node_flux_gen
node_pano_gen -->|"runs image pipeline"| node_flux_fill
node_pano_gen -->|"loads LoRA"| node_lora
node_worldgen -->|"estimates depth"| node_depth
node_worldgen -->|"segments foreground"| node_seg
node_worldgen -->|"inpaints background"| node_inpaint
node_inpaint -->|"uses model"| node_lama
node_worldgen -->|"predicts splats"| node_sharp
node_worldgen -->|"builds scene"| node_splat
node_worldgen -->|"converts geometry"| node_general
node_depth -->|"uses utilities"| node_general
node_seg -->|"projects panorama"| node_general
node_inpaint -->|"uses utilities"| node_general
node_sharp -->|"transforms views"| node_equirect
node_sharp -->|"creates splat"| node_splat
node_demo -->|"requests scene"| node_worldgen
node_demo -->|"displays splat"| node_splat
node_demo -->|"serves exploration"| node_viser

click node_worldgen "https://github.com/ziyang-xie/worldgen/blob/main/src/worldgen/worldgen.py"
click node_pano_gen "https://github.com/ziyang-xie/worldgen/blob/main/src/worldgen/pano_gen.py"
click node_flux_gen "https://github.com/ziyang-xie/worldgen/blob/main/src/worldgen/models/flux_pano_gen_pipeline.py"
click node_flux_fill "https://github.com/ziyang-xie/worldgen/blob/main/src/worldgen/models/flux_pano_fill_pipeline.py"
click node_depth "https://github.com/ziyang-xie/worldgen/blob/main/src/worldgen/pano_depth.py"
click node_seg "https://github.com/ziyang-xie/worldgen/blob/main/src/worldgen/pano_seg.py"
click node_inpaint "https://github.com/ziyang-xie/worldgen/blob/main/src/worldgen/pano_inpaint.py"
click node_lama "https://github.com/ziyang-xie/worldgen/blob/main/src/worldgen/models/inpaint_model.py"
click node_sharp "https://github.com/ziyang-xie/worldgen/blob/main/src/worldgen/pano_sharp.py"
click node_splat "https://github.com/ziyang-xie/worldgen/blob/main/src/worldgen/utils/splat_utils.py"
click node_general "https://github.com/ziyang-xie/worldgen/blob/main/src/worldgen/utils/general_utils.py"
click node_equirect "https://github.com/ziyang-xie/worldgen/blob/main/src/worldgen/utils/equirectangular.py"
click node_lora "https://github.com/ziyang-xie/worldgen/blob/main/src/worldgen/utils/lora_utils.py"
click node_demo "https://github.com/ziyang-xie/worldgen/blob/main/demo.py"

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_worldgen,node_seg,node_inpaint,node_lama,node_user toneBlue
class node_pano_gen,node_flux_gen,node_flux_fill toneAmber
class node_depth,node_sharp,node_splat toneMint
class node_general,node_equirect,node_lora toneRose
class node_demo,node_viser toneIndigo
```

## Components

### Scene workflow

- [WorldGen API](https://github.com/ziyang-xie/worldgen/blob/main/src/worldgen/worldgen.py): `src/worldgen/worldgen.py`
- [Foreground segmentation](https://github.com/ziyang-xie/worldgen/blob/main/src/worldgen/pano_seg.py): `src/worldgen/pano_seg.py`
- [Background inpainting](https://github.com/ziyang-xie/worldgen/blob/main/src/worldgen/pano_inpaint.py): `src/worldgen/pano_inpaint.py`
- [LaMa model](https://github.com/ziyang-xie/worldgen/blob/main/src/worldgen/models/inpaint_model.py): `src/worldgen/models/inpaint_model.py`

### Panorama generation

- [Panorama generation](https://github.com/ziyang-xie/worldgen/blob/main/src/worldgen/pano_gen.py): `src/worldgen/pano_gen.py`
- [FLUX panorama pipeline](https://github.com/ziyang-xie/worldgen/blob/main/src/worldgen/models/flux_pano_gen_pipeline.py): `src/worldgen/models/flux_pano_gen_pipeline.py`
- [FLUX fill pipeline](https://github.com/ziyang-xie/worldgen/blob/main/src/worldgen/models/flux_pano_fill_pipeline.py): `src/worldgen/models/flux_pano_fill_pipeline.py`

### Depth and geometry

- [Panorama depth](https://github.com/ziyang-xie/worldgen/blob/main/src/worldgen/pano_depth.py): `src/worldgen/pano_depth.py`
- [Sharp splat prediction](https://github.com/ziyang-xie/worldgen/blob/main/src/worldgen/pano_sharp.py): `src/worldgen/pano_sharp.py`
- [Gaussian splat utilities](https://github.com/ziyang-xie/worldgen/blob/main/src/worldgen/utils/splat_utils.py): `src/worldgen/utils/splat_utils.py`

### Shared support

- [Panorama geometry utilities](https://github.com/ziyang-xie/worldgen/blob/main/src/worldgen/utils/general_utils.py): `src/worldgen/utils/general_utils.py`
- [Equirectangular transforms](https://github.com/ziyang-xie/worldgen/blob/main/src/worldgen/utils/equirectangular.py): `src/worldgen/utils/equirectangular.py`
- [LoRA utilities](https://github.com/ziyang-xie/worldgen/blob/main/src/worldgen/utils/lora_utils.py): `src/worldgen/utils/lora_utils.py`

### Scene exploration

- [Viser demo](https://github.com/ziyang-xie/worldgen/blob/main/demo.py): `demo.py`
- **Viser viewer**

### Other components

- **User**

## Connections

- User → WorldGen API: requests scene (evidence: `README.md`)
- WorldGen API → Panorama generation: generates panorama (evidence: `src/worldgen/worldgen.py`)
- Panorama generation → FLUX panorama pipeline: runs text pipeline (evidence: `src/worldgen/pano_gen.py`)
- Panorama generation → FLUX fill pipeline: runs image pipeline (evidence: `src/worldgen/pano_gen.py`)
- Panorama generation → LoRA utilities: loads LoRA (evidence: `src/worldgen/pano_gen.py`)
- WorldGen API → Panorama depth: estimates depth (evidence: `src/worldgen/worldgen.py`)
- WorldGen API → Foreground segmentation: segments foreground (evidence: `src/worldgen/worldgen.py`)
- WorldGen API → Background inpainting: inpaints background (evidence: `src/worldgen/worldgen.py`)
- Background inpainting → LaMa model: uses model (evidence: `src/worldgen/pano_inpaint.py`)
- WorldGen API → Sharp splat prediction: predicts splats (evidence: `src/worldgen/worldgen.py`)
- WorldGen API → Gaussian splat utilities: builds scene (evidence: `src/worldgen/worldgen.py`)
- WorldGen API → Panorama geometry utilities: converts geometry (evidence: `src/worldgen/worldgen.py`)
- Panorama depth → Panorama geometry utilities: uses utilities (evidence: `src/worldgen/pano_depth.py`)
- Foreground segmentation → Panorama geometry utilities: projects panorama (evidence: `src/worldgen/pano_seg.py`)
- Background inpainting → Panorama geometry utilities: uses utilities (evidence: `src/worldgen/pano_inpaint.py`)
- Sharp splat prediction → Equirectangular transforms: transforms views (evidence: `src/worldgen/pano_sharp.py`)
- Sharp splat prediction → Gaussian splat utilities: creates splat (evidence: `src/worldgen/pano_sharp.py`)
- Viser demo → WorldGen API: requests scene (evidence: `demo.py`)
- Viser demo → Gaussian splat utilities: displays splat (evidence: `demo.py`)
- Viser demo → Viser viewer: serves exploration (evidence: `README.md`)
