# beammanp/see-through-webui architecture

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

- Interactive diagram: https://gitdiagram.com/beammanp/see-through-webui
- Repository: https://github.com/beammanp/see-through-webui

## Overview

1. **What this repo is**
   - This is a **local, Windows-only anime image layer decomposition tool** packaged as a WebUI.
   - The user flow is simple: install dependencies once, then launch a local app that opens in the browser and turns a single illustration into a multi-layer output.

2. **Primary runtime boundary**
   - The system runs **entirely on the user’s machine**.
   - It depends on **NVIDIA GPUs** and a cached set of model weights; no cloud backend is part of the normal architecture.
   - Model artifacts are downloaded into a local cache during installation, which is a key operational boundary.

3. **Launch and packaging layer**
   - `install.bat` and `run.bat` are the real entrypoints for end users.
   - `tools/webui.py` is the main launcher for the browser-based interface.
   - `webui/` contains release/build packaging code and dependency declarations for distributing the app.

4. **User interface layer**
   - The visible app is the **browser-based WebUI**.
   - There is also a substantial `ui/` package that implements a **desktop-style Qt interface** with custom widgets, frameless-window support, theming, and UI tests.
   - Architecturally, `ui/` is a separate presentation layer from the browser WebUI, likely a legacy or alternate front end rather than the main documented path.

5. **Inference orchestration**
   - The `inference/` package is the central pipeline controller.
   - Scripts such as `inference_psd.py`, `inference_psd_quantized.py`, `infer_sam.py`, `infer_lama.py`, `heuristic_partseg.py`, and `parse_live2d.py` suggest the pipeline assembles multiple model stages into a final layered result.
   - This is where input images are routed through segmentation, tagging, inpainting, and export logic.

6. **Annotator subsystem**
   - `annotators/` contains the model wrappers used to extract structure from the input image before decomposition.
   - Important subcomponents include:
     - `anime_face_detector/` for face detection and related pose/config variants
     - `animeinsseg/` for anime instance segmentation
     - `bizarre_tagger/` and `wdv3_tagger.py` for tag inference
     - `lang_sam/` for language-guided segmentation
     - `lama_inpainter/` for background/object removal and fill-in
     - `gradcam.py` and `pos_estimator.py` for saliency/pose-style auxiliary signals
   - These modules are the preprocessing intelligence that feeds the final layer-splitting pipeline.

7. **Shared model implementations**
   - `common/modules/` vendors several heavier ML model families so the repo does not depend only on external packages at runtime.
   - Notable groups are:
     - `sam/` for Segment Anything Model inference and mask generation
     - `depth_anything_v2/` for monocular depth estimation
     - `marigold/` for diffusion-based depth estimation
     - `layerdiffuse/` for diffusion-based layer/3D-related components
     - `semanticsam.py` and `extend_sam.py` as integration layers around SAM-like behavior
   - These modules form a reusable model layer beneath both annotators and inference scripts.

8. **Data and utility layer**
   - `common/utils/` provides the supporting infrastructure: image I/O, torch helpers, CV utilities, visualization, sampling, and package/runtime helpers.
   - `common/assets/` stores JSON configuration and taxonomy data such as body tags and layer/tag clustering metadata.
   - These assets act as lookup tables and configuration inputs for tagging and decomposition behavior.

9. **Output and downstream integration**
   - The pipeline is designed to produce **layered outputs** suitable for editing or animation workflows.
   - The presence of `parse_live2d.py` indicates support for Live2D-related parsing/export workflows in addition to the main image decomposition output.
   - The main product boundary is therefore “single image in, structured layered asset set out.”

10. **Repository shape and dependency posture**
   - The repo is a **model-heavy application** rather than a thin UI wrapper: the bulk of the codebase is dedicated to ML inference components and their integration.
   - Dependencies are split by capability in multiple requirements files, reflecting optional or hardware-specific paths such as annotated inference, bits-and-bytes quantization, MMDetection/MMPose, and SAM2-style support.
   - In architecture terms, the key external dependencies are PyTorch-based vision models plus local model caches, all orchestrated by the WebUI and inference pipeline.

Main entry points: [`inference/scripts/inference_psd.py`](https://github.com/beammanp/see-through-webui/blob/main/inference/scripts/inference_psd.py) (PSD infer), [`common/utils/io_utils.py`](https://github.com/beammanp/see-through-webui/blob/main/common/utils/io_utils.py) (Common utils), [`tools/webui.py`](https://github.com/beammanp/see-through-webui/blob/main/tools/webui.py) (webui.py), [`annotators/__init__.py`](https://github.com/beammanp/see-through-webui/blob/main/annotators/__init__.py) (Annotators)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_g_entry["Entry & Packaging"]
  node_n_install["install.bat<br/>launcher script<br/>[install.bat]"]
  node_n_run["run.bat<br/>launcher script<br/>[run.bat]"]
end

subgraph group_g_webui["Browser WebUI"]
  node_n_webui_py["webui.py<br/>webui launcher<br/>[webui.py]"]
  node_n_webui_pkg["WebUI pkg<br/>release packaging<br/>[setup.py]"]
end

subgraph group_g_ui["Desktop UI"]
  node_n_qt_launch["Qt launch<br/>desktop launcher<br/>[launch.py]"]
  node_n_qt_main["Main window<br/>qt shell<br/>[mainwindow.py]"]
  node_n_qt_widgets["Widgets<br/>[widget.py]"]
  node_n_qt_frame["Frameless<br/>window chrome<br/>[__init__.py]"]
end

subgraph group_g_inference["Inference Pipeline"]
  node_n_infer_psd["PSD infer<br/>pipeline driver<br/>[inference_psd.py]"]
  node_n_infer_aux["Aux scripts<br/>pipeline stages<br/>[infer_sam.py]"]
end

subgraph group_g_models["Model Layer"]
  node_n_annotators["Annotators<br/>vision preprocessors<br/>[__init__.py]"]
  node_n_sam["SAM stack<br/>mask models<br/>[__init__.py]"]
  node_n_depth["Depth models<br/>[dpt.py]"]
  node_n_layerdiff["LayerDiffuse<br/>diffusion modules<br/>[layerdiff3d.py]"]
end

subgraph group_g_shared["Shared Support"]
  node_n_common_utils["Common utils<br/>runtime helpers<br/>[io_utils.py]"]
  node_n_common_assets[("Assets<br/>taxonomies<br/>[bodytags_v3.json]")]
  node_n_live2d["Live2D<br/>parse/visualize<br/>[scrap_model.py]"]
end

node_n_install -->|"installs for"| node_n_webui_py
node_n_run -->|"starts"| node_n_webui_py
node_n_webui_py -->|"uses"| node_n_webui_pkg
node_n_webui_py -->|"orchestrates"| node_n_infer_psd
node_n_qt_launch -->|"opens"| node_n_qt_main
node_n_qt_main -->|"composes"| node_n_qt_widgets
node_n_qt_main -->|"uses"| node_n_qt_frame
node_n_infer_psd -->|"calls"| node_n_annotators
node_n_infer_psd -->|"segments with"| node_n_sam
node_n_infer_psd -->|"estimates depth"| node_n_depth
node_n_infer_psd -->|"supports"| node_n_layerdiff
node_n_infer_psd -->|"uses"| node_n_common_utils
node_n_infer_psd -->|"loads"| node_n_common_assets
node_n_infer_aux -->|"invokes"| node_n_annotators
node_n_infer_aux -->|"invokes"| node_n_sam
node_n_infer_aux -->|"parses"| node_n_live2d
node_n_annotators -->|"depends on"| node_n_common_utils
node_n_annotators -->|"uses"| node_n_common_assets
node_n_sam -->|"depends on"| node_n_common_utils
node_n_depth -->|"depends on"| node_n_common_utils
node_n_layerdiff -->|"depends on"| node_n_common_utils

click node_n_install "https://github.com/beammanp/see-through-webui/blob/main/install.bat"
click node_n_run "https://github.com/beammanp/see-through-webui/blob/main/run.bat"
click node_n_webui_py "https://github.com/beammanp/see-through-webui/blob/main/tools/webui.py"
click node_n_webui_pkg "https://github.com/beammanp/see-through-webui/blob/main/webui/setup.py"
click node_n_qt_launch "https://github.com/beammanp/see-through-webui/blob/main/ui/ui/launch.py"
click node_n_qt_main "https://github.com/beammanp/see-through-webui/blob/main/ui/ui/mainwindow.py"
click node_n_qt_widgets "https://github.com/beammanp/see-through-webui/blob/main/ui/ui/widget.py"
click node_n_qt_frame "https://github.com/beammanp/see-through-webui/blob/main/ui/ui/framelesswindow/__init__.py"
click node_n_infer_psd "https://github.com/beammanp/see-through-webui/blob/main/inference/scripts/inference_psd.py"
click node_n_infer_aux "https://github.com/beammanp/see-through-webui/blob/main/inference/scripts/infer_sam.py"
click node_n_annotators "https://github.com/beammanp/see-through-webui/blob/main/annotators/__init__.py"
click node_n_sam "https://github.com/beammanp/see-through-webui/blob/main/common/modules/sam/__init__.py"
click node_n_depth "https://github.com/beammanp/see-through-webui/blob/main/common/modules/depth_anything_v2/dpt.py"
click node_n_layerdiff "https://github.com/beammanp/see-through-webui/blob/main/common/modules/layerdiffuse/layerdiff3d.py"
click node_n_common_utils "https://github.com/beammanp/see-through-webui/blob/main/common/utils/io_utils.py"
click node_n_common_assets "https://github.com/beammanp/see-through-webui/blob/main/common/assets/bodytags_v3.json"
click node_n_live2d "https://github.com/beammanp/see-through-webui/blob/main/common/live2d/scrap_model.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_n_install,node_n_run toneBlue
class node_n_webui_py,node_n_webui_pkg toneAmber
class node_n_qt_launch,node_n_qt_main,node_n_qt_widgets,node_n_qt_frame toneMint
class node_n_infer_psd,node_n_infer_aux toneRose
class node_n_annotators,node_n_sam,node_n_depth,node_n_layerdiff toneIndigo
class node_n_common_utils,node_n_common_assets,node_n_live2d toneTeal
```

## Components

### Entry & Packaging

Launch scripts and release packaging for the local Windows app.

- [install.bat](https://github.com/beammanp/see-through-webui/blob/main/install.bat): launcher script · One-time dependency install entrypoint for Windows users. · `install.bat`
- [run.bat](https://github.com/beammanp/see-through-webui/blob/main/run.bat): launcher script · End-user start script that opens the local app. · `run.bat`

### Browser WebUI

Local browser-facing interface and its packaging layer.

- [webui.py](https://github.com/beammanp/see-through-webui/blob/main/tools/webui.py): webui launcher · Main Python entrypoint that launches the browser-based interface. · `tools/webui.py`
- [WebUI pkg](https://github.com/beammanp/see-through-webui/blob/main/webui/setup.py): release packaging · Release/build and dependency declarations for the WebUI distribution. · `webui/setup.py`

### Desktop UI

Alternate Qt-based presentation layer with custom widgets and window chrome.

- [Qt launch](https://github.com/beammanp/see-through-webui/blob/main/ui/ui/launch.py): desktop launcher · Desktop UI startup and app bootstrap. · `ui/ui/launch.py`
- [Main window](https://github.com/beammanp/see-through-webui/blob/main/ui/ui/mainwindow.py): qt shell · Primary desktop window and layout orchestration. · `ui/ui/mainwindow.py`
- [Widgets](https://github.com/beammanp/see-through-webui/blob/main/ui/ui/widget.py): qt widgets · Reusable custom controls, canvas, sliders, labels, and related components. · `ui/ui/widget.py`
- [Frameless](https://github.com/beammanp/see-through-webui/blob/main/ui/ui/framelesswindow/__init__.py): window chrome · Platform-specific frameless-window and window-effect support. · `ui/ui/framelesswindow/__init__.py`

### Inference Pipeline

Orchestration scripts that turn a single image into layered outputs.

- [PSD infer](https://github.com/beammanp/see-through-webui/blob/main/inference/scripts/inference_psd.py): pipeline driver · Main layered-image inference flow and quantized variant. · `inference/scripts/inference_psd.py`
- [Aux scripts](https://github.com/beammanp/see-through-webui/blob/main/inference/scripts/infer_sam.py): pipeline stages · Supporting inference steps for SAM, LaMa, heuristic segmentation, and Live2D parsing. · `inference/scripts/infer_sam.py`

### Model Layer

Reusable vendored model implementations and wrappers used by inference and annotators.

- [Annotators](https://github.com/beammanp/see-through-webui/blob/main/annotators/__init__.py): vision preprocessors · Model wrappers for face detection, instance segmentation, tagging, pose, and inpainting prep. · `annotators/__init__.py`
- [SAM stack](https://github.com/beammanp/see-through-webui/blob/main/common/modules/sam/__init__.py): mask models · Segment Anything model implementation and mask generation utilities. · `common/modules/sam/__init__.py`
- [Depth models](https://github.com/beammanp/see-through-webui/blob/main/common/modules/depth_anything_v2/dpt.py): depth models · Depth Anything and Marigold depth-estimation implementations. · `common/modules/depth_anything_v2/dpt.py`
- [LayerDiffuse](https://github.com/beammanp/see-through-webui/blob/main/common/modules/layerdiffuse/layerdiff3d.py): diffusion modules · Diffusion-based layer/3D-related components used by the pipeline. · `common/modules/layerdiffuse/layerdiff3d.py`

### Shared Support

Common utilities, assets, and Live2D-related helpers.

- [Common utils](https://github.com/beammanp/see-through-webui/blob/main/common/utils/io_utils.py): runtime helpers · Image I/O, torch helpers, CV utilities, sampling, and visualization support. · `common/utils/io_utils.py`
- [Assets](https://github.com/beammanp/see-through-webui/blob/main/common/assets/bodytags_v3.json): taxonomies · JSON lookup data and clustering metadata used by tagging and decomposition. · `common/assets/bodytags_v3.json`
- [Live2D](https://github.com/beammanp/see-through-webui/blob/main/common/live2d/scrap_model.py): parse/visualize · Live2D parsing and visualization helpers used by downstream export workflows. · `common/live2d/scrap_model.py`

## Connections

- install.bat → webui.py: installs for · Dependencies are prepared before the WebUI launcher runs.
- run.bat → webui.py: starts · Windows start script launches the local browser app.
- webui.py → WebUI pkg: uses · Launcher depends on the packaged WebUI release/runtime setup.
- webui.py → PSD infer: orchestrates · The WebUI drives the main inference pipeline.
- Qt launch → Main window: opens · Desktop launcher constructs the primary window.
- Main window → Widgets: composes · Main window is built from custom widget components.
- Main window → Frameless: uses · Window chrome and platform-specific frameless support.
- PSD infer → Annotators: calls · Main pipeline uses annotators for image understanding.
- PSD infer → SAM stack: segments with · Mask generation and object separation rely on SAM utilities.
- PSD infer → Depth models: estimates depth · Depth signals inform decomposition and layering.
- PSD infer → LayerDiffuse: supports · Optional diffusion-based layer and 3D-related flows.
- PSD infer → Common utils: uses · Shared helpers provide image, torch, and CV support.
- PSD infer → Assets: loads · Taxonomies and clustering data guide tagging and segmentation.
- Aux scripts → Annotators: invokes · Auxiliary inference scripts reuse annotator models.
- Aux scripts → SAM stack: invokes · SAM-based scripts route through shared mask tooling.
- Aux scripts → Live2D: parses · Live2D parsing/export support is handled here.
- Annotators → Common utils: depends on · Annotators use shared I/O, CV, and torch helpers.
- Annotators → Assets: uses · Tagging and category behavior is driven by asset tables.
- SAM stack → Common utils: depends on · SAM model code uses shared transforms and visualization helpers.
- Depth models → Common utils: depends on · Depth pipelines use shared image and torch utilities.
- LayerDiffuse → Common utils: depends on · Diffusion modules rely on shared runtime helpers.
