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.
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
⇄
OriginalErased
Loading sample plate…
1. Selection & Mask Tools
2. SAM 2.1 Candidate Masks
Click or box to generate 3 masks
3. Mask Refinement
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 dilationShow the code — compositeInpaintedRegion() pixel-exact unmasked preservationShow the code — formatMagicCanvasJson() upstreamModel provenance bundleShow the code — StageWorkerClient FIFO queue, bitmap transfer & clean terminationShow the code — CameraCaptureController generation-guarded local camera capture