feat: add Ultra quality mode with BiRefNet-matting for people photos

Adds a new "Ultra" quality tier for People subject type that uses
BiRefNet-matting (ONNX, 928MB) for true alpha matting instead of
binary segmentation. Produces per-pixel transparency for hair wisps
and fine edges that standard models miss.

- Custom rembg session class loads BiRefNet-matting ONNX from GitHub releases
- Zero new Python dependencies (reuses existing onnxruntime)
- Model pre-downloaded in Docker build alongside existing models
- Ultra option only visible when subject is People
- Falls back to Best when switching to Products/General
This commit is contained in:
Siddharth Kumar Sah
2026-04-12 18:09:59 +08:00
parent 6c58f12262
commit 93dd37017c
4 changed files with 119 additions and 8 deletions
+27
View File
@@ -108,6 +108,33 @@ test.describe("Remove Background tool", () => {
await expect(page.locator("section[aria-label='Image area'] img").first()).toBeVisible();
});
test("Ultra quality visible for People, hidden for Products", async ({ loggedInPage: page }) => {
await page.goto("/remove-background");
// People is default - Ultra should be visible
await expect(page.getByRole("button", { name: "Ultra" })).toBeVisible();
// Switch to Products - Ultra should disappear
await page.getByText("Products").click();
await expect(page.getByRole("button", { name: "Ultra" })).not.toBeVisible();
// Switch back to People - Ultra returns
await page.getByText("People").click();
await expect(page.getByRole("button", { name: "Ultra" })).toBeVisible();
});
test("Ultra quality processes JPG portrait", async ({ loggedInPage: page }) => {
await page.goto("/remove-background");
await uploadFile(page, fixturePath("test-portrait.jpg"));
// Select Ultra quality
await page.getByRole("button", { name: "Ultra" }).click();
await removeBgAndWait(page);
await expect(page.locator("section[aria-label='Image area'] img").first()).toBeVisible();
await expect(page.locator("text=Background removal failed")).not.toBeVisible();
});
test("HEIC portrait - processes without error", async ({ loggedInPage: page }) => {
await page.goto("/remove-background");
await uploadFile(page, fixturePath("test-portrait.heic"));