Repository navigation
feat(image-studio): background removal on the CPU - #457
Merged
Merged
Conversation
Image Studio gets a "Remove background" tool. The cut-out lands in the
history with the original as its source, so the before/after slider
compares them; a Mask toggle shows the matte and an edge threshold
hardens soft edges.
It needs no extension and no GPU: BiRefNet-lite (MIT, ONNX, pinned
revision, checked by size and SHA-256) runs with onnxruntime on the CPU.
Both are fetched on first use behind a one-time setup card with
progress (~249 MB): onnxruntime 1.23.2 is pip-installed into the
backend's own environment on demand rather than added to
requirements.txt, which would force every user through a full Python
reinstall; 1.23.2 is the last release with Intel Mac wheels.
Backend: an image_ops registry modelled on mesh_ops, under /image:
GET /image/ops, GET /image/op/{op}/status, POST /image/op/{op}/prepare
(SSE, LLM download format) and POST /image/op/{op} (409 until
prepared). Outputs go to <workspace>/Images/ and never overwrite.
EditPanel's param fields move to a shared ParamFields component, used
by both panels.
Closes #421
A GET could start the one-time install from any page (an image tag is enough); the renderer already uses POST.
…e/after slider The canvas shows the cut-out itself; the original stays one click away in the history strip.
4 tasks
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.
Closes #421
What it does
Image Studio gets a Remove background tool. The cut-out is added to the history and shown on the checkerboard; the original stays one click away in the history strip. A Mask toggle shows the matte, and an edge threshold hardens soft edges. Re-running always starts from the original, not from a previous cut-out.
It needs no extension and no GPU:
onnx-community/BiRefNet_lite-ONNX, pinned to a revision and checked by size and SHA-256 after download.requirements.txt(a requirements change forces every existing user through a full Python reinstall). 1.23.2 is the last release with Intel Mac wheels.Backend
An
image_opsregistry modelled onmesh_ops, under/image:GET /image/opsGET /image/op/{op}/status→{ ready, missing, download_bytes, preparing }POST /image/op/{op}/prepare→ SSE progress (same format as the LLM downloads); idempotent, a second call joins the running onePOST /image/op/{op}{ path, params }→{ path, mask_path }; 409not_readyuntil prepared; inference runs off the event loopOutputs go to
<workspace>/Images/and never overwrite. onnxruntime is never imported at module load.Frontend
ImageOpsToolbar+ setup card, client inimageOpsApi.ts, pure helpers inimageOps.tsEditPanel's param fields moved to a sharedParamFieldscomponent (no visual change)consumeSseaccepts a request init so the setup stream is a POSTTesting
npm testpasses (Python 512, JS 352 + 237, 0 failures); lint clean;tscunchanged fromdev