# phai-lab/viewnext architecture

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

- Interactive diagram: https://gitdiagram.com/phai-lab/viewnext
- Repository: https://github.com/phai-lab/viewnext

## Overview

ViewNeXt is a MiniMax-H3-based novel-view-synthesis application. The main workflow takes a scene specification, posed context images, and a caption through the inference CLI/API; it loads the base model and adapter, conditions generation on camera geometry, and produces target-view images or camera-path video. The repository also contains audio/video pipeline support and shared model/runtime infrastructure. README statements establish the user-facing modes and loading workflow; source-index references and the excerpts support the internal links shown. Unsampled implementation details are not inferred.

Main entry points: [`diffsynth/pipelines/minimax_h3_nvs.py`](https://github.com/phai-lab/viewnext/blob/main/diffsynth/pipelines/minimax_h3_nvs.py) (NVS pipeline), [`diffsynth/models/minimax_h3_dit.py`](https://github.com/phai-lab/viewnext/blob/main/diffsynth/models/minimax_h3_dit.py) (MiniMax-H3 DiT), [`diffsynth/pipelines/minimax_h3_audio_video.py`](https://github.com/phai-lab/viewnext/blob/main/diffsynth/pipelines/minimax_h3_audio_video.py) (Audio/video pipeline), [`inference/model.py`](https://github.com/phai-lab/viewnext/blob/main/inference/model.py) (NVS model API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_inference["Inference workflow"]
  node_cli["Inference CLI<br/>[cli.py]"]
  node_scene["Scene parsing<br/>[scene.py]"]
  node_caption["Caption encoding<br/>[captions.py]"]
  node_api["NVS model API<br/>[model.py]"]
end

subgraph group_nvs["View synthesis"]
  node_nvs_pipeline["NVS pipeline<br/>[minimax_h3_nvs.py]"]
  node_video_layout["Video layouts<br/>[video.py]"]
  node_camera_geometry["Camera geometry<br/>[cameras.py]"]
  node_camera_tokens["Camera tokens<br/>[camera_tokens.py]"]
  node_camera_branch["Relative camera branch<br/>[camera_branch.py]"]
  node_camera_adaln["Camera AdaLN<br/>[camera_adaln.py]"]
  node_prope["Camera PRoPE<br/>[prope.py]"]
  node_frame_queries["Frame query tokens"]
  node_checkpoint["Adapter loading<br/>[checkpoint.py]"]
end

subgraph group_models["H3 model components"]
  node_dit["MiniMax-H3 DiT<br/>[minimax_h3_dit.py]"]
  node_text_encoder["Text encoder"]
  node_video_vae["Video VAE"]
  node_audio_video_pipeline["Audio/video pipeline"]
end

subgraph group_runtime["Shared runtime"]
  node_attention["Attention backend<br/>[attention.py]"]
  node_device["Device support"]
  node_lora["LoRA utilities<br/>[general.py]"]
end

node_user(("Scene user"))
node_result["Generated views"]

node_user -->|"runs commands"| node_cli
node_cli -->|"loads scene"| node_scene
node_cli -->|"encodes caption"| node_caption
node_cli -->|"invokes generation"| node_api
node_api -->|"accepts scene data"| node_scene
node_api -->|"loads mode pipeline"| node_nvs_pipeline
node_api -->|"loads adapter"| node_checkpoint
node_api -->|"returns generated views"| node_result
node_nvs_pipeline -->|"runs denoising"| node_dit
node_nvs_pipeline -->|"uses camera inputs"| node_camera_geometry
node_nvs_pipeline -->|"configures camera tokens"| node_camera_tokens
node_nvs_pipeline -->|"uses camera encoding"| node_camera_adaln
node_nvs_pipeline -->|"uses camera branch"| node_camera_branch
node_nvs_pipeline -->|"uses camera PRoPE"| node_prope
node_nvs_pipeline -->|"uses frame queries"| node_frame_queries
node_nvs_pipeline -->|"uses video layouts"| node_video_layout
node_dit -->|"applies branch"| node_camera_branch
node_dit -->|"applies camera PRoPE"| node_prope
node_dit -->|"runs attention"| node_attention
node_video_layout -->|"uses camera tokens"| node_camera_tokens
node_video_layout -->|"packs frame queries"| node_frame_queries
node_audio_video_pipeline -->|"uses DiT model"| node_dit
node_audio_video_pipeline -->|"decodes video"| node_video_vae
node_audio_video_pipeline -->|"uses text encoder"| node_text_encoder
node_audio_video_pipeline -->|"uses device support"| node_device
node_audio_video_pipeline -->|"uses LoRA support"| node_lora
node_dit -->|"consumes camera inputs"| node_camera_branch
node_user -.->|"provides caption"| node_caption

click node_cli "https://github.com/phai-lab/viewnext/blob/main/inference/cli.py"
click node_scene "https://github.com/phai-lab/viewnext/blob/main/inference/scene.py"
click node_caption "https://github.com/phai-lab/viewnext/blob/main/inference/captions.py"
click node_api "https://github.com/phai-lab/viewnext/blob/main/inference/model.py"
click node_nvs_pipeline "https://github.com/phai-lab/viewnext/blob/main/diffsynth/pipelines/minimax_h3_nvs.py"
click node_video_layout "https://github.com/phai-lab/viewnext/blob/main/diffsynth/nvs/video.py"
click node_camera_geometry "https://github.com/phai-lab/viewnext/blob/main/diffsynth/nvs/cameras.py"
click node_camera_tokens "https://github.com/phai-lab/viewnext/blob/main/diffsynth/nvs/camera_tokens.py"
click node_camera_branch "https://github.com/phai-lab/viewnext/blob/main/diffsynth/nvs/camera_branch.py"
click node_camera_adaln "https://github.com/phai-lab/viewnext/blob/main/diffsynth/nvs/camera_adaln.py"
click node_prope "https://github.com/phai-lab/viewnext/blob/main/diffsynth/nvs/prope.py"
click node_frame_queries "https://github.com/phai-lab/viewnext/blob/main/diffsynth/nvs/frame_query_tokens.py"
click node_checkpoint "https://github.com/phai-lab/viewnext/blob/main/diffsynth/nvs/checkpoint.py"
click node_dit "https://github.com/phai-lab/viewnext/blob/main/diffsynth/models/minimax_h3_dit.py"
click node_text_encoder "https://github.com/phai-lab/viewnext/blob/main/diffsynth/models/minimax_h3_text_encoder.py"
click node_video_vae "https://github.com/phai-lab/viewnext/blob/main/diffsynth/models/minimax_h3_video_vae.py"
click node_audio_video_pipeline "https://github.com/phai-lab/viewnext/blob/main/diffsynth/pipelines/minimax_h3_audio_video.py"
click node_attention "https://github.com/phai-lab/viewnext/blob/main/diffsynth/core/attention/attention.py"
click node_device "https://github.com/phai-lab/viewnext/blob/main/diffsynth/core/device/npu_compatible_device.py"
click node_lora "https://github.com/phai-lab/viewnext/blob/main/diffsynth/utils/lora/general.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_cli,node_scene,node_caption,node_api,node_user,node_result toneBlue
class node_nvs_pipeline,node_video_layout,node_camera_geometry,node_camera_tokens,node_camera_branch,node_camera_adaln,node_prope,node_frame_queries,node_checkpoint toneAmber
class node_dit,node_text_encoder,node_video_vae,node_audio_video_pipeline toneMint
class node_attention,node_device,node_lora toneRose
```

## Components

### Inference workflow

- [Inference CLI](https://github.com/phai-lab/viewnext/blob/main/inference/cli.py): `inference/cli.py`
- [Scene parsing](https://github.com/phai-lab/viewnext/blob/main/inference/scene.py): `inference/scene.py`
- [Caption encoding](https://github.com/phai-lab/viewnext/blob/main/inference/captions.py): `inference/captions.py`
- [NVS model API](https://github.com/phai-lab/viewnext/blob/main/inference/model.py): `inference/model.py`

### View synthesis

- [NVS pipeline](https://github.com/phai-lab/viewnext/blob/main/diffsynth/pipelines/minimax_h3_nvs.py): `diffsynth/pipelines/minimax_h3_nvs.py`
- [Video layouts](https://github.com/phai-lab/viewnext/blob/main/diffsynth/nvs/video.py): `diffsynth/nvs/video.py`
- [Camera geometry](https://github.com/phai-lab/viewnext/blob/main/diffsynth/nvs/cameras.py): `diffsynth/nvs/cameras.py`
- [Camera tokens](https://github.com/phai-lab/viewnext/blob/main/diffsynth/nvs/camera_tokens.py): `diffsynth/nvs/camera_tokens.py`
- [Relative camera branch](https://github.com/phai-lab/viewnext/blob/main/diffsynth/nvs/camera_branch.py): `diffsynth/nvs/camera_branch.py`
- [Camera AdaLN](https://github.com/phai-lab/viewnext/blob/main/diffsynth/nvs/camera_adaln.py): `diffsynth/nvs/camera_adaln.py`
- [Camera PRoPE](https://github.com/phai-lab/viewnext/blob/main/diffsynth/nvs/prope.py): `diffsynth/nvs/prope.py`
- [Frame query tokens](https://github.com/phai-lab/viewnext/blob/main/diffsynth/nvs/frame_query_tokens.py): `diffsynth/nvs/frame_query_tokens.py`
- [Adapter loading](https://github.com/phai-lab/viewnext/blob/main/diffsynth/nvs/checkpoint.py): `diffsynth/nvs/checkpoint.py`

### H3 model components

- [MiniMax-H3 DiT](https://github.com/phai-lab/viewnext/blob/main/diffsynth/models/minimax_h3_dit.py): `diffsynth/models/minimax_h3_dit.py`
- [Text encoder](https://github.com/phai-lab/viewnext/blob/main/diffsynth/models/minimax_h3_text_encoder.py): `diffsynth/models/minimax_h3_text_encoder.py`
- [Video VAE](https://github.com/phai-lab/viewnext/blob/main/diffsynth/models/minimax_h3_video_vae.py): `diffsynth/models/minimax_h3_video_vae.py`
- [Audio/video pipeline](https://github.com/phai-lab/viewnext/blob/main/diffsynth/pipelines/minimax_h3_audio_video.py): `diffsynth/pipelines/minimax_h3_audio_video.py`

### Shared runtime

- [Attention backend](https://github.com/phai-lab/viewnext/blob/main/diffsynth/core/attention/attention.py): `diffsynth/core/attention/attention.py`
- [Device support](https://github.com/phai-lab/viewnext/blob/main/diffsynth/core/device/npu_compatible_device.py): `diffsynth/core/device/npu_compatible_device.py`
- [LoRA utilities](https://github.com/phai-lab/viewnext/blob/main/diffsynth/utils/lora/general.py): `diffsynth/utils/lora/general.py`

### Other components

- **Scene user**
- **Generated views**

## Connections

- Scene user → Inference CLI: runs commands (evidence: `README.md`)
- Inference CLI → Scene parsing: loads scene (evidence: `inference/cli.py`)
- Inference CLI → Caption encoding: encodes caption (evidence: `inference/cli.py`)
- Inference CLI → NVS model API: invokes generation (evidence: `inference/cli.py`)
- NVS model API → Scene parsing: accepts scene data (evidence: `inference/model.py`)
- NVS model API → NVS pipeline: loads mode pipeline (evidence: `inference/model.py`)
- NVS model API → Adapter loading: loads adapter (evidence: `inference/model.py`)
- NVS model API → Generated views: returns generated views (evidence: `inference/model.py`)
- NVS pipeline → MiniMax-H3 DiT: runs denoising (evidence: `diffsynth/pipelines/minimax_h3_nvs.py`)
- NVS pipeline → Camera geometry: uses camera inputs (evidence: `diffsynth/pipelines/minimax_h3_nvs.py`)
- NVS pipeline → Camera tokens: configures camera tokens (evidence: `diffsynth/pipelines/minimax_h3_nvs.py`)
- NVS pipeline → Camera AdaLN: uses camera encoding (evidence: `diffsynth/pipelines/minimax_h3_nvs.py`)
- NVS pipeline → Relative camera branch: uses camera branch (evidence: `diffsynth/pipelines/minimax_h3_nvs.py`)
- NVS pipeline → Camera PRoPE: uses camera PRoPE (evidence: `diffsynth/pipelines/minimax_h3_nvs.py`)
- NVS pipeline → Frame query tokens: uses frame queries (evidence: `diffsynth/pipelines/minimax_h3_nvs.py`)
- NVS pipeline → Video layouts: uses video layouts (evidence: `diffsynth/pipelines/minimax_h3_nvs.py`)
- MiniMax-H3 DiT → Relative camera branch: applies branch (evidence: `diffsynth/models/minimax_h3_dit.py`)
- MiniMax-H3 DiT → Camera PRoPE: applies camera PRoPE (evidence: `diffsynth/models/minimax_h3_dit.py`)
- MiniMax-H3 DiT → Attention backend: runs attention (evidence: `diffsynth/models/minimax_h3_dit.py`)
- Video layouts → Camera tokens: uses camera tokens (evidence: `diffsynth/nvs/video.py`)
- Video layouts → Frame query tokens: packs frame queries (evidence: `diffsynth/nvs/video.py`)
- Audio/video pipeline → MiniMax-H3 DiT: uses DiT model (evidence: `diffsynth/pipelines/minimax_h3_audio_video.py`)
- Audio/video pipeline → Video VAE: decodes video (evidence: `diffsynth/pipelines/minimax_h3_audio_video.py`)
- Audio/video pipeline → Text encoder: uses text encoder (evidence: `diffsynth/pipelines/minimax_h3_audio_video.py`)
- Audio/video pipeline → Device support: uses device support (evidence: `diffsynth/pipelines/minimax_h3_audio_video.py`)
- Audio/video pipeline → LoRA utilities: uses LoRA support (evidence: `diffsynth/pipelines/minimax_h3_audio_video.py`)
- MiniMax-H3 DiT → Relative camera branch: consumes camera inputs (evidence: `diffsynth/models/minimax_h3_dit.py`)
- Scene user → Caption encoding: provides caption (evidence: `README.md`)
