# Portrait matting components

MODNet photographic portrait model (official ONNX download linked by upstream): Apache License 2.0. Upstream explicitly licenses code, models and demos, except its GIFs. README, license, original inference example and ONNX download instructions are retained unchanged. No upstream GIF is distributed. Upstream revision: 28165a451e4610c9d77cfdf925a94610bb2810fb.

ONNX Runtime Web 1.20.1: MIT License. Official npm WASM-only ES module, matching single-thread-used SIMD WASM and loader are retained unchanged. ORT-LICENSE and ORT-ThirdPartyNotices.txt retain upstream declarations. Model bytes, runtime bytes and official sources are recorded in sources.json.

Default fine mode predicts continuous portrait alpha with MODNet. Qinghe integration preserves aspect ratio, normalizes RGB to [-1, 1], and uses NCHW tensors. The shorter side is targeted at 512 pixels with the longer side bounded at 768; both dimensions are divisible by 32. Browser inference uses WebAssembly CPU, one thread, no proxy worker or WebGPU. All model/runtime requests are same-origin; photo pixels stay in the browser. Approximate first fine-mode download including MediaPipe face detection is 48 MB. Thin hair, translucent objects, low light and difficult backgrounds can still produce errors. No model fine-tuning or new training data is claimed.

Qinghe postprocessing uses source-guided continuous alpha refinement and conservative local foreground/background color unmixing. Unmixing changes uncertain edge pixels only when nearby samples explain their color as a foreground/background mixture. Optional stubborn blue/green fringe correction adjusts chroma in a narrow contour band using deeper foreground references, preserving luminance and alpha; it can be disabled. Deep interiors are not recolored. Color correction cannot supply a previously recolored screenshot's lost original alpha/background. Colored accessories and collar edges should be checked. It is not a guarantee of perfect cutout or registration acceptance.

Face detection and optional lightweight segmentation remain the separately licensed MediaPipe components in ../portrait/. No HivisionIDPhotos, BRIA or AGPL component/model is distributed.
