SAM 2.1 + LaMa · WASM ~298 MB Local 0 Bytes Uploaded
About & Code

Standalone App & PWA

Launch Magic Canvas on its dedicated origin to install it as an offline desktop or mobile PWA with direct image/* file handlers.

Open erase.webai.show ↗

Honest cache note: browsers isolate Cache Storage per origin, so erase.webai.show stores its own local weights. Staying on webai.show shares cached weights with the SAM 2.1 and LaMa model pages.

Stage 1 · SAM 2.1 Segmentation (~90 MB fp16 · Apache-2.0)

onnx-community/sam2.1-hiera-tiny-ONNX · Reused Worker

Stage 2 · LaMa Generative Inpainting (208 MB fp32 · Apache-2.0)

Carve/LaMa-ONNX · Reused ORT 1.21.0 Worker

0 bytes uploaded. Load SAM 2.1 + LaMa above, or switch to Brush (+) immediately. Ctrl/Cmd+V paste supported.

Working canvas · 0 bytes uploaded
SAM 2.1 EncodeAwaiting SAM 2.1
Mask & IoUNo mask yet
LaMa InpaintAwaiting LaMa
Edit HistoryOriginal

Loading sample plate…

1. Selection & Mask Tools

2. SAM 2.1 Candidate Masks

Click or box to generate 3 masks

3. Mask Refinement

32 px
4 px

4. Generative Object Removal

5. Export & Clipboard

–

How Magic Canvas Works

Two existing WebAssembly vision workers chained strictly off the main thread — SAM 2.1 Hiera Tiny (onnx-community/sam2.1-hiera-tiny-ONNX, ~90 MB fp16, Apache-2.0) and Carve/LaMa-ONNX (208 MB fp32 Fourier-convolution inpainting, Apache-2.0) — sharing Cache Storage with zero duplicate weights.

Reused Workers & Shared Cache

Both workers are imported directly from ../../models/sam2-segmentation/worker.js and ../../models/lama-image-inpainting/worker.js with zero new CDN pins and shared Cache Storage validation.

Exact Euclidean Mask Dilation

dilateMask() computes an exact two-pass O(W×H) squared Euclidean distance transform so expanding a mask by 0–16 px stays circular and instant at 60 fps.

Pixel-Exact Feathered Composite

compositeInpaintedRegion() copies every unmasked pixel 1:1 from your working canvas while blending LaMa's 512² Fourier fill cleanly across a 2 px interior feather.

Show the code — dilateMask() exact O(W×H) circular mask dilation
Show the code — compositeInpaintedRegion() pixel-exact unmasked preservation
Show the code — formatMagicCanvasJson() upstreamModel provenance bundle
Show the code — StageWorkerClient FIFO queue, bitmap transfer & clean termination
Show the code — CameraCaptureController generation-guarded local camera capture

Capture Local Photo

Privacy first: Your camera is only accessed after you click Enable Camera below. Every frame stays inside your browser tab — zero pixels are ever uploaded, and all camera tracks stop immediately after capture or when closing this dialog.