# moonwhaler/comfyui-seedvr2-tilingupscaler architecture

> Architecture diagram of the GitHub repository moonwhaler/comfyui-seedvr2-tilingupscaler, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/moonwhaler/comfyui-seedvr2-tilingupscaler
- Repository: https://github.com/moonwhaler/comfyui-seedvr2-tilingupscaler

## Overview

1. This repository is a **ComfyUI custom node package** for single-image upscaling. Its core job is not to implement a model, but to **orchestrate SeedVR2 inference over tiled image regions** so large images can be processed with lower VRAM.

2. The architectural boundary is clear: **SeedVR2 lives outside this repo**. The code here depends on the separate `ComfyUI-SeedVR2_VideoUpscaler` node pack for model execution, model discovery, and optional advanced controls like `extra_args` and `block_swap_config`.

3. The main runtime entrypoint is likely `upscaler.py`, which acts as the **ComfyUI node implementation**. It receives the input image and user parameters, coordinates tiling/upscaling/stitching, and returns the final image to ComfyUI.

4. `seedvr2_adapter.py` is the integration layer between this node and the external SeedVR2 ecosystem. It likely handles **model selection, compatibility across stable vs nightly SeedVR2 builds, and passing through advanced options** without this repo needing to know the model internals.

5. `tiling.py` defines the **spatial partitioning subsystem**. The image is split into overlapping tiles using either linear or chess-like traversal, with tile size and padding controlling the tradeoff between VRAM usage, throughput, and seam quality.

6. The per-tile processing flow is the heart of the system:
   - input image
   - tile extraction with overlap
   - SeedVR2 upscale on each tile
   - resize each tile to its intended final scale
   - merge all tiles back into one output image  
   This is the main data path an architecture diagram should show.

7. `stitching.py` is the **blend/composition subsystem**. It resolves overlaps between adjacent upscaled tiles using multiple strategies: simple averaging, linear alpha blending, bilateral/edge-preserving smoothing, content-aware blending, and multiband Laplacian pyramid blending. This is the main quality-preserving boundary in the design.

8. `image_utils.py` likely contains shared **image conversion and geometric helpers**: resizing, padding, normalization, color/channel handling, and conversions between Pillow, NumPy, and torch-friendly formats. These utilities sit beneath both tiling and stitching.

9. `progress.py` is a small **user-feedback layer** for ComfyUI progress reporting. The README notes the progress bar can show “???” during work, so this module likely wraps progress updates around long-running tile processing and external model calls.

10. The `workflows/` directory contains **ComfyUI JSON workflow examples**, not runtime code. These documents show how this node is composed with standard SeedVR2 nodes, and in the advanced case, with additional ComfyUI ecosystem nodes for pre-downscaling, noise injection, and resolution control.

11. The README also implies an important architectural variant: a **basic mode** that uses only this node, and an **advanced mode** that accepts optional SeedVR2-side inputs (`extra_args`, `block_swap_config`). That makes the node modular: it can operate standalone or participate in a larger SeedVR2 VRAM-management pipeline.

12. Overall, the repo is a **single-purpose orchestration package** built around memory-efficient image upscaling. The key diagram should emphasize the external model dependency, the tile-processing loop, and the final stitching stage as the three major subsystems.

Main entry points: [`upscaler.py`](https://github.com/moonwhaler/comfyui-seedvr2-tilingupscaler/blob/main/upscaler.py) (Upscaler), [`workflows/seedvr2-tiled-upscale_advanced_comfyui_workflow.json`](https://github.com/moonwhaler/comfyui-seedvr2-tilingupscaler/blob/main/workflows/seedvr2-tiled-upscale_advanced_comfyui_workflow.json) (Advanced workflow), [`seedvr2_adapter.py`](https://github.com/moonwhaler/comfyui-seedvr2-tilingupscaler/blob/main/seedvr2_adapter.py) (SeedVR2 adapter), [`examples`](https://github.com/moonwhaler/comfyui-seedvr2-tilingupscaler/tree/main/examples) (Examples)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime core"]
  node_comfyui_host["ComfyUI<br/>host/runtime"]
  node_upscaler_node["Upscaler<br/>node entrypoint<br/>[upscaler.py]"]
  node_seedvr2_adapter["SeedVR2 adapter<br/>integration<br/>[seedvr2_adapter.py]"]
  node_tiling["Tiling<br/>spatial partitioning<br/>[tiling.py]"]
  node_stitching["Stitching<br/>blend/composition<br/>[stitching.py]"]
  node_image_utils["Image utils<br/>shared helpers<br/>[image_utils.py]"]
  node_progress["Progress<br/>ui feedback<br/>[progress.py]"]
  node_package_init["Package init<br/>comfyui package<br/>[__init__.py]"]
end

subgraph group_external["External dependency"]
  node_seedvr2_pack["SeedVR2 pack<br/>external node pack"]
  node_seedvr2_model["SeedVR2 model<br/>external model/runtime"]
end

subgraph group_examples["Examples"]
  node_workflows_simple["Simple workflow<br/>example workflow"]
  node_workflows_advanced["Advanced workflow<br/>example workflow"]
  node_examples_dir["Examples<br/>example assets"]
end

node_package_init -->|"registers"| node_upscaler_node
node_comfyui_host -->|"invokes"| node_upscaler_node
node_upscaler_node -->|"splits"| node_tiling
node_upscaler_node -->|"delegates"| node_seedvr2_adapter
node_upscaler_node -->|"merges"| node_stitching
node_upscaler_node -->|"reports"| node_progress
node_tiling -->|"uses"| node_image_utils
node_stitching -->|"uses"| node_image_utils
node_seedvr2_adapter -->|"calls"| node_seedvr2_pack
node_seedvr2_pack -->|"loads"| node_seedvr2_model
node_workflows_simple -.->|"demonstrates"| node_upscaler_node
node_workflows_advanced -.->|"demonstrates"| node_upscaler_node
node_workflows_advanced -.->|"passes options"| node_seedvr2_adapter
node_examples_dir -.->|"contains"| node_workflows_simple
node_examples_dir -.->|"contains"| node_workflows_advanced

click node_upscaler_node "https://github.com/moonwhaler/comfyui-seedvr2-tilingupscaler/blob/main/upscaler.py"
click node_seedvr2_adapter "https://github.com/moonwhaler/comfyui-seedvr2-tilingupscaler/blob/main/seedvr2_adapter.py"
click node_tiling "https://github.com/moonwhaler/comfyui-seedvr2-tilingupscaler/blob/main/tiling.py"
click node_stitching "https://github.com/moonwhaler/comfyui-seedvr2-tilingupscaler/blob/main/stitching.py"
click node_image_utils "https://github.com/moonwhaler/comfyui-seedvr2-tilingupscaler/blob/main/image_utils.py"
click node_progress "https://github.com/moonwhaler/comfyui-seedvr2-tilingupscaler/blob/main/progress.py"
click node_package_init "https://github.com/moonwhaler/comfyui-seedvr2-tilingupscaler/blob/main/__init__.py"
click node_workflows_simple "https://github.com/moonwhaler/comfyui-seedvr2-tilingupscaler/blob/main/workflows/seedvr2-tiled-upscale_simple_comfyui_workflow.json"
click node_workflows_advanced "https://github.com/moonwhaler/comfyui-seedvr2-tilingupscaler/blob/main/workflows/seedvr2-tiled-upscale_advanced_comfyui_workflow.json"
click node_examples_dir "https://github.com/moonwhaler/comfyui-seedvr2-tilingupscaler/tree/main/examples"

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_comfyui_host,node_upscaler_node,node_seedvr2_adapter,node_tiling,node_stitching,node_image_utils,node_progress,node_package_init toneBlue
class node_seedvr2_pack,node_seedvr2_model toneAmber
class node_workflows_simple,node_workflows_advanced,node_examples_dir toneMint
```

## Components

### Runtime core

The ComfyUI node and its tiled upscaling pipeline

- **ComfyUI**: host/runtime · The surrounding ComfyUI environment that loads and runs the custom node
- [Upscaler](https://github.com/moonwhaler/comfyui-seedvr2-tilingupscaler/blob/main/upscaler.py): node entrypoint · Main custom node implementation that orchestrates tiled single-image upscaling · `upscaler.py`
- [SeedVR2 adapter](https://github.com/moonwhaler/comfyui-seedvr2-tilingupscaler/blob/main/seedvr2_adapter.py): integration · Bridges this package to external SeedVR2 variants and advanced runtime options · `seedvr2_adapter.py`
- [Tiling](https://github.com/moonwhaler/comfyui-seedvr2-tilingupscaler/blob/main/tiling.py): spatial partitioning · Splits the input image into overlapping tiles and controls traversal and padding · `tiling.py`
- [Stitching](https://github.com/moonwhaler/comfyui-seedvr2-tilingupscaler/blob/main/stitching.py): blend/composition · Merges upscaled tiles and resolves seams with blending strategies · `stitching.py`
- [Image utils](https://github.com/moonwhaler/comfyui-seedvr2-tilingupscaler/blob/main/image_utils.py): shared helpers · Common image conversion, resizing, padding, and geometry helpers · `image_utils.py`
- [Progress](https://github.com/moonwhaler/comfyui-seedvr2-tilingupscaler/blob/main/progress.py): ui feedback · Progress reporting for long tile-processing and inference runs · `progress.py`
- [Package init](https://github.com/moonwhaler/comfyui-seedvr2-tilingupscaler/blob/main/__init__.py): comfyui package · Package registration and import surface for the custom node · `__init__.py`

### External dependency

SeedVR2 execution and model management live in a separate node pack

- **SeedVR2 pack**: external node pack · Separate ComfyUI node package that provides SeedVR2 model execution and model discovery
- **SeedVR2 model**: external model/runtime · The actual upscaling model and inference runtime used outside this repository

### Examples

ComfyUI workflow examples showing how the node is used

- [Simple workflow](https://github.com/moonwhaler/comfyui-seedvr2-tilingupscaler/blob/main/workflows/seedvr2-tiled-upscale_simple_comfyui_workflow.json): example workflow · Basic ComfyUI workflow showing tiled upscaling with this node · `workflows/seedvr2-tiled-upscale_simple_comfyui_workflow.json`
- [Advanced workflow](https://github.com/moonwhaler/comfyui-seedvr2-tilingupscaler/blob/main/workflows/seedvr2-tiled-upscale_advanced_comfyui_workflow.json): example workflow · Workflow variant that includes extra controls and broader SeedVR2 integration · `workflows/seedvr2-tiled-upscale_advanced_comfyui_workflow.json`
- [Examples](https://github.com/moonwhaler/comfyui-seedvr2-tilingupscaler/tree/main/examples): example assets · Additional example material referenced by the repository · `examples`

## Connections

- Package init → Upscaler: registers · Exposes the custom node to ComfyUI
- ComfyUI → Upscaler: invokes · ComfyUI executes the node during a workflow run
- Upscaler → Tiling: splits · Partitions the input image into tiles before inference
- Upscaler → SeedVR2 adapter: delegates · Hands tile inference requests to the SeedVR2 integration layer
- Upscaler → Stitching: merges · Combines per-tile outputs into the final image
- Upscaler → Progress: reports · Updates user-facing progress during long runs
- Tiling → Image utils: uses · Relies on shared image geometry and conversion helpers
- Stitching → Image utils: uses · Uses common resize and pixel-space helpers for composition
- SeedVR2 adapter → SeedVR2 pack: calls · Integrates with the external SeedVR2 node pack for model execution
- SeedVR2 pack → SeedVR2 model: loads · The external pack discovers and runs the underlying SeedVR2 model
- Simple workflow → Upscaler: demonstrates · Shows the basic standalone usage pattern
- Advanced workflow → Upscaler: demonstrates · Shows the advanced usage pattern with extra controls
- Advanced workflow → SeedVR2 adapter: passes options · Illustrates optional advanced SeedVR2 arguments flowing through the adapter
- Examples → Simple workflow: contains · Example assets group the workflow samples
- Examples → Advanced workflow: contains · Example assets group the workflow samples
