Repository navigation
Remove Background: cut out or change a photo's background, on the device - #90
Merged
Merged
Conversation
New Remove Background tool. The background goes as soon as a photo is chosen; then pick what goes behind it (nothing, white, a colour, your own photo or a blur), the size, and touch up any spot with Erase / Restore. - BiRefNet-lite (MIT) runs in a worker with ONNX Runtime Web: on the GPU through WebGPU where available, on the CPU otherwise. It sees the photo at 512 px, which keeps it within browser memory (the 1024 px export needs ~7 GB). Weights are stored as 16-bit floats (103 MB download, cached once) and cast back on load, so the CPU build can run it too. - Phones that report little memory, or where the big model fails, use U2-Net small (Apache-2.0, 4.6 MB). A GPU that fails falls back to the same model on the CPU first. - The mask is fitted to the full-size photo with a fast colour guided filter, and edge colours are cleaned with blur-fusion foreground estimation, so hair keeps its strands and no halo of the old background shows. Output keeps the photo's own resolution; smaller sizes or a custom width are one click away. - Model files and the WebGPU runtime are served in parts from our own origin, like the speech model; the CSP is unchanged. - Strings in all 16 languages, credits in README and the licence files, unit tests for the filters and an e2e test that runs the real model.
Deploying fizzdoc with
|
| Latest commit: |
c9a7e26
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://e13a3d64.fizzdoc.pages.dev |
| Branch Preview URL: | https://feat-remove-background.fizzdoc.pages.dev |
The bundled WebGPU build points at its 27 MB binary with new URL(), so Vite copied it into dist/assets, and Cloudflare Pages refuses files over 25 MiB. The extern-wasm build loads its small loader from /bg/ort/ and gets the binary from the parts we already serve.
Cloudflare Pages refuses such files at deploy time; this catches them in the build and in CI, with a hint to split the file into parts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
New tool at /remove-background/.
For the person using it
How it works
scripts/background-model.py): 103 MB download instead of 192 MB, and the CPU build can still run it. Downloaded once into Cache Storage./bg/ort/, split under 25 MiB) are served from our own origin; CSP unchanged..gitattributesmarks model files binary.Checks
Strings in all 16 languages; credits added to README, THIRD_PARTY_NOTICES.md and third-party-licenses.txt. Tool count 64 → 65.