# nie-lang/udis2 architecture

> Architecture diagram of the GitHub repository nie-lang/udis2, 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/nie-lang/udis2
- Repository: https://github.com/nie-lang/udis2

## Overview

UDIS++ is an unsupervised, two-stage image-stitching system: it first predicts a projective and mesh warp for overlapping image pairs, then learns masks to blend the warped images into a stitch. Training code, datasets, model/loss code, and geometric transforms are shown for the warp stage; composition training and mask blending are also shown. The README documents the two stages, but the stage-specific READMEs and test implementations were not sampled, so detailed inference and data handoff links are omitted.

Main entry points: [`Warp/Codes/train.py`](https://github.com/nie-lang/udis2/blob/main/Warp/Codes/train.py) (Warp trainer), [`Warp/Codes/network.py`](https://github.com/nie-lang/udis2/blob/main/Warp/Codes/network.py) (Warp network), [`Composition/Codes/train.py`](https://github.com/nie-lang/udis2/blob/main/Composition/Codes/train.py) (Composition trainer), [`Composition/Codes/network.py`](https://github.com/nie-lang/udis2/blob/main/Composition/Codes/network.py) (Mask and stitch model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_warp["Warp stage"]
  node_warptrain["Warp trainer<br/>[train.py]"]
  node_warpmodel["Warp network<br/>[network.py]"]
end

subgraph group_geometry["Warp geometry"]
  node_gridres["Mesh resolution<br/>[grid_res.py]"]
  node_dlt["DLT solver<br/>[torch_DLT.py]"]
  node_homotrans["Homography sampler"]
  node_tpstrans["TPS sampler"]
  node_tpstrans2["TPS sampler variant"]
end

subgraph group_compose["Composition stage"]
  node_comptrain["Composition trainer<br/>[train.py]"]
  node_compmodel["Mask and stitch model<br/>[network.py]"]
end

subgraph group_training["Training data and losses"]
  node_warpdata["Image-pair data<br/>[dataset.py]"]
  node_warploss["Warp losses<br/>[loss.py]"]
  node_compdata["Warped-pair data<br/>[dataset.py]"]
  node_comploss["Composition losses<br/>[loss.py]"]
end

node_researcher(("Researcher"))
node_warpedpairs["Warped image pairs"]
node_stitched["Stitched image"]

node_researcher -->|"trains warp"| node_warptrain
node_warptrain -->|"loads pairs"| node_warpdata
node_warptrain -->|"runs model"| node_warpmodel
node_warptrain -->|"computes losses"| node_warploss
node_warpmodel -->|"uses resolution"| node_gridres
node_warpmodel -->|"solves homography"| node_dlt
node_warpmodel -->|"warps projectively"| node_homotrans
node_warpmodel -->|"warps by TPS"| node_tpstrans
node_warploss -->|"uses resolution"| node_gridres
node_warptrain -.->|"produces warp outputs"| node_warpedpairs
node_warpedpairs -.->|"feeds composition"| node_compdata
node_researcher -->|"trains composition"| node_comptrain
node_comptrain -->|"loads warped pairs"| node_compdata
node_comptrain -->|"runs model"| node_compmodel
node_comptrain -->|"computes losses"| node_comploss
node_compmodel -->|"blends images"| node_stitched

click node_warpdata "https://github.com/nie-lang/udis2/blob/main/Warp/Codes/dataset.py"
click node_warptrain "https://github.com/nie-lang/udis2/blob/main/Warp/Codes/train.py"
click node_warpmodel "https://github.com/nie-lang/udis2/blob/main/Warp/Codes/network.py"
click node_warploss "https://github.com/nie-lang/udis2/blob/main/Warp/Codes/loss.py"
click node_gridres "https://github.com/nie-lang/udis2/blob/main/Warp/Codes/grid_res.py"
click node_dlt "https://github.com/nie-lang/udis2/blob/main/Warp/Codes/utils/torch_DLT.py"
click node_homotrans "https://github.com/nie-lang/udis2/blob/main/Warp/Codes/utils/torch_homo_transform.py"
click node_tpstrans "https://github.com/nie-lang/udis2/blob/main/Warp/Codes/utils/torch_tps_transform.py"
click node_tpstrans2 "https://github.com/nie-lang/udis2/blob/main/Warp/Codes/utils/torch_tps_transform2.py"
click node_compdata "https://github.com/nie-lang/udis2/blob/main/Composition/Codes/dataset.py"
click node_comptrain "https://github.com/nie-lang/udis2/blob/main/Composition/Codes/train.py"
click node_compmodel "https://github.com/nie-lang/udis2/blob/main/Composition/Codes/network.py"
click node_comploss "https://github.com/nie-lang/udis2/blob/main/Composition/Codes/loss.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_warptrain,node_warpmodel toneBlue
class node_gridres,node_dlt,node_homotrans,node_tpstrans,node_tpstrans2 toneAmber
class node_comptrain,node_compmodel toneMint
class node_warpdata,node_warploss,node_compdata,node_comploss toneRose
class node_researcher,node_warpedpairs,node_stitched toneIndigo
```

## Components

### Warp stage

- [Warp trainer](https://github.com/nie-lang/udis2/blob/main/Warp/Codes/train.py): `Warp/Codes/train.py`
- [Warp network](https://github.com/nie-lang/udis2/blob/main/Warp/Codes/network.py): `Warp/Codes/network.py`

### Warp geometry

- [Mesh resolution](https://github.com/nie-lang/udis2/blob/main/Warp/Codes/grid_res.py): `Warp/Codes/grid_res.py`
- [DLT solver](https://github.com/nie-lang/udis2/blob/main/Warp/Codes/utils/torch_DLT.py): `Warp/Codes/utils/torch_DLT.py`
- [Homography sampler](https://github.com/nie-lang/udis2/blob/main/Warp/Codes/utils/torch_homo_transform.py): `Warp/Codes/utils/torch_homo_transform.py`
- [TPS sampler](https://github.com/nie-lang/udis2/blob/main/Warp/Codes/utils/torch_tps_transform.py): `Warp/Codes/utils/torch_tps_transform.py`
- [TPS sampler variant](https://github.com/nie-lang/udis2/blob/main/Warp/Codes/utils/torch_tps_transform2.py): `Warp/Codes/utils/torch_tps_transform2.py`

### Composition stage

- [Composition trainer](https://github.com/nie-lang/udis2/blob/main/Composition/Codes/train.py): `Composition/Codes/train.py`
- [Mask and stitch model](https://github.com/nie-lang/udis2/blob/main/Composition/Codes/network.py): `Composition/Codes/network.py`

### Training data and losses

- [Image-pair data](https://github.com/nie-lang/udis2/blob/main/Warp/Codes/dataset.py): `Warp/Codes/dataset.py`
- [Warp losses](https://github.com/nie-lang/udis2/blob/main/Warp/Codes/loss.py): `Warp/Codes/loss.py`
- [Warped-pair data](https://github.com/nie-lang/udis2/blob/main/Composition/Codes/dataset.py): `Composition/Codes/dataset.py`
- [Composition losses](https://github.com/nie-lang/udis2/blob/main/Composition/Codes/loss.py): `Composition/Codes/loss.py`

### Other components

- **Researcher**
- **Warped image pairs**
- **Stitched image**

## Connections

- Researcher → Warp trainer: trains warp (evidence: `Warp/Codes/train.py`)
- Warp trainer → Image-pair data: loads pairs (evidence: `Warp/Codes/train.py`)
- Warp trainer → Warp network: runs model (evidence: `Warp/Codes/train.py`)
- Warp trainer → Warp losses: computes losses (evidence: `Warp/Codes/train.py`)
- Warp network → Mesh resolution: uses resolution (evidence: `Warp/Codes/network.py`)
- Warp network → DLT solver: solves homography (evidence: `Warp/Codes/network.py`)
- Warp network → Homography sampler: warps projectively (evidence: `Warp/Codes/network.py`)
- Warp network → TPS sampler: warps by TPS (evidence: `Warp/Codes/network.py`)
- Warp losses → Mesh resolution: uses resolution (evidence: `Warp/Codes/loss.py`)
- Warp trainer → Warped image pairs: produces warp outputs
- Warped image pairs → Warped-pair data: feeds composition
- Researcher → Composition trainer: trains composition (evidence: `Composition/Codes/train.py`)
- Composition trainer → Warped-pair data: loads warped pairs (evidence: `Composition/Codes/train.py`)
- Composition trainer → Mask and stitch model: runs model (evidence: `Composition/Codes/train.py`)
- Composition trainer → Composition losses: computes losses (evidence: `Composition/Codes/train.py`)
- Mask and stitch model → Stitched image: blends images (evidence: `Composition/Codes/network.py`)
