PICORN Remove Background
Background remover in the Browser/Client side.
Try the live demo · Run locally · Smart refine
PICORN removes image backgrounds without sending the image to a server. The model, inference runtime, alpha correction and PNG export all run in the browser.
The V12 ONNX model is 1.2 MB (1,209,207 bytes) and has 524,198 inference parameters. It keeps the V10 hybrid edge stage and the white-graphic refinement, and adds a zoomed second pass, confident-alpha snapping and foreground colour estimation. Inference uses WebGPU when supported, with a WASM fallback. See the V12 notes.
V12 swaps the from-scratch encoder for an ImageNet-pretrained MobileNetV4-Small-050 and keeps the V11 decoder. Weights are stored as FP16 and cast to FP32 at load, so the file is smaller than V11 while all arithmetic stays FP32. On the original 6,489-image holdout at 512 px:
| Metric | V11 | V12 |
|---|---|---|
| Intersection over Union | 0.617 | 0.773 |
| Mean absolute alpha error | 0.073 | 0.036 |
| Boundary F1 | 0.395 | 0.596 |
| Model file | 1,417,525 B | 1,209,207 B |
| CPU, 512 px, 4 threads | 77.0 ms | 76.7 ms |
- Drop in a PNG, JPG or WebP. Nothing is uploaded.
- Choose 320, 384 or 512 px inference profiles for different devices.
- Inspect the edge on a checkerboard, solid color or gradient.
- Paint green to restore a missing region or red to remove a leftover region.
- Download the cutout, a composite or the alpha matte as PNG.
- Run the same static build on GitHub Pages, a CDN or your own machine.
PICORN does not put a large general-purpose vision backbone in the browser. Its ONNX graph combines a compact semantic encoder with dynamic foreground and background prototypes, multi-scale texture signals and a shallow full-resolution detail path. It predicts a soft alpha matte, not just a binary object mask.
The result is one model file with 990 ONNX nodes and 146 initializers. There is no Python service behind the demo.
V10 separates two jobs that do not need the same tool:
- The compact neural model decides what the foreground object is and produces a soft alpha matte.
- Eight four-neighbour WebGPU passes propagate only uncertain alpha values between pixels with similar RGB values.
- A quarter-resolution fast guided filter places the soft transition back on the full-resolution image edge.
- Confident alpha anchors, the foreground/background class boundary and thin structures without a nearby safe core are protected.
The refiner has no learned weights and does not change the 1,417,388-byte ONNX artifact. Chromium uses WGSL compute shaders; other browsers run the same deterministic CPU reference implementation.
On the complete 6,489-image validation set:
| Metric | V9 model | V10 hybrid | Change |
|---|---|---|---|
| Intersection over Union | 0.59294 | 0.59412 | +0.00118 |
| Mean absolute error | 0.07449 | 0.07423 | -0.00026 |
| Mean squared error | 0.05174 | 0.05135 | -0.00040 |
| Boundary F1 | 0.38432 | 0.39194 | +0.00762 |
The improvement is positive on DIS5K, DUTS-TE and P3M-10K individually. A real
Chrome WebGPU run matched the CPU reference within 1.2e-7; at 512 px the warm
edge stage averaged 11.25 ms on the validation workstation. See the
V10 research and benchmark notes for the paper trail,
ablation results and limitations.
V9 improves the matte without adding layers, parameters or browser code. It is the same compact graph, fine-tuned once more at a low learning rate.
On the full 6,489-image validation set (DIS5K, DUTS-TE and P3M):
| Metric | V8 | V9 |
|---|---|---|
| Intersection over Union | 0.59233 | 0.59294 |
| Mean absolute error | 0.07515 | 0.07449 |
| Boundary F1 | 0.38206 | 0.38432 |
The model update is deliberately small. V9 improves the aggregate score, edges and alpha error while keeping the 1,417,388-byte artifact unchanged. See the V9 research notes for the per-dataset results and rejected experiments.
The brush is more than a round paint stamp:
- The current alpha matte supplies confident foreground and background anchors.
- A green or red stroke becomes a local trimap hint.
- Color, gradient and Shannon-entropy differences decide how far that hint may travel through the connected region.
- Small mask islands and enclosed holes can be corrected as complete components.
- A guided filter pulls the new soft alpha back onto the visible image edge.
Only the narrow painted core is a hard instruction. The grown selection stays a soft proposal, and the correction is limited to a local band. This prevents one small hint from replacing most of an otherwise good mask.
You need Node.js 22 or newer.
git clone https://github.com/cueqzapper/PICORN-Background-Remover.git
cd PICORN-Background-Remover
npm install
npm run devOpen http://127.0.0.1:4185/.
For a production build:
npm test
npm run check
npm run build
npm run preview| Browser | Preferred path | Fallback |
|---|---|---|
| Chrome / Edge | WebGPU | WASM |
| Firefox | WASM | — |
| Safari | WebGPU where available | WASM |
The page becomes interactive before the runtime is warm. On first use, the browser downloads and caches the model and the relevant ONNX Runtime files. Later runs reuse the browser cache. Modern Chromium browsers use the smaller JSPI WebGPU runtime; older WebGPU implementations retain a compatible fallback.
public/models/ PICORN ONNX model
public/demo/ CC0 demo images
src/browser-runtime.js ONNX loading, preprocessing and hybrid routing
src/hybrid-refine-webgpu.js WebGPU edge graph and guided alpha passes
src/hybrid-refine.js Deterministic CPU reference and fallback
src/interactive-matting.js Trimap, geodesic growth and guided refinement
src/main.js Demo interaction, rendering and PNG export
tests/ Runtime and smart-refine regression tests
The model deliberately trades broad model capacity for size and client-side speed. Extremely crowded scenes, transparent glass, motion blur and subjects whose color matches the background can still need a refine stroke. The Quality profile improves thin structures, but it also does more work.
- Browser source code: MIT
- Included PICORN ONNX weights: separate model terms
- Included demo images: CC0 1.0
- ONNX Runtime Web is installed from npm and retains its MIT notice.
If you want to use the weights in a commercial product or hosted service, contact PICORN for a commercial model license.
