How beammanp/see-through-webui works
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_psd.py PSD infer · io_utils.py Common utils · webui.py webui.py · __init__.py Annotators
Components 17
Entry & Packaging
Launch scripts and release packaging for the local Windows app.
- install.bat · One-time dependency install entrypoint for Windows users.
install.bat - run.bat · End-user start script that opens the local app.
run.bat
Browser WebUI
Local browser-facing interface and its packaging layer.
Desktop UI
Alternate Qt-based presentation layer with custom widgets and window chrome.
- Qt launch · Desktop UI startup and app bootstrap.
ui/ui/launch.py - Main window · Primary desktop window and layout orchestration.
ui/ui/mainwindow.py - Widgets · Reusable custom controls, canvas, sliders, labels, and related components.
ui/ui/widget.py - Frameless · 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 · Main layered-image inference flow and quantized variant.
inference/scripts/inference_psd.py - Aux scripts · 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 · Model wrappers for face detection, instance segmentation, tagging, pose, and inpainting prep.
annotators/__init__.py - SAM stack · Segment Anything model implementation and mask generation utilities.
common/modules/sam/__init__.py - Depth models · Depth Anything and Marigold depth-estimation implementations.
common/modules/depth_anything_v2/dpt.py - LayerDiffuse · 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 · Image I/O, torch helpers, CV utilities, sampling, and visualization support.
common/utils/io_utils.py - Assets · JSON lookup data and clustering metadata used by tagging and decomposition.
common/assets/bodytags_v3.json - Live2D · Live2D parsing and visualization helpers used by downstream export workflows.
common/live2d/scrap_model.py
Connections 21
- 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.