Skip to content

Opt-in neural cut-out: remove_background {neural} and reel cutout --neural (u2netp) - #86

Merged
IsraelWebDev merged 2 commits into
mainfrom
feat/neural-cutout
Nov 30, 2026
Merged

IsraelWebDev merged 2 commits into
mainfrom
feat/neural-cutout

Conversation

@IsraelWebDev

Copy link
Copy Markdown
Owner

What

An opt-in neural cut-out, beside the colour-based one (which stays the default):

  • remove_background {"neural": true} in image_edit / poster pre ops.
  • funkbox reel cutout photo.jpg -o out.png --neural.
  • New model u2netp in reel/models.json (pinned URL, SHA-256, size, licence), installed with funkbox reel setup-models --only u2netp. 4.5 MB, runs on the CPU.

It needs no plain background, so it handles a product on a table or a busy wall. build_product_png takes neural=True; the quality score still runs and reports method: "neural".

Why

From the repo scout (claude/repo-scout-feature-plan-2026-11-29.md, item 1; idea from rembg, no rembg code or package used, and not its default bria-rmbg model).

No new dependency, nothing downloads by itself

onnxruntime is already in requirements-reel.txt (depth, LaMa, MobileSAM). Only setup-models downloads, as for the other models. Without the model the op stops with "needs the u2netp model: run funkbox reel setup-models --only u2netp"; the CLI exits 2 with the same message.

Licence: please check before merge

  • Model card edgetools/u2netp declares Apache-2.0 and says the weights come from xuebinqin/U-2-Net (Apache-2.0).
  • The file is the one rembg publishes (danielgatis/rembg release v0.0.0, MIT). I downloaded it: 4,574,861 bytes, SHA-256 309c8469...ddd8, MD5 8e83ca70e441ab06c318d82300c84806 (matches the value rembg lists).
  • I could NOT read the U-2-Net repo's own LICENSE page or any statement about the pretrained weights from the primary source. The note in models.json says "upstream weight provenance not re-verified", the same caveat the LaMa and MobileSAM entries already carry.

Limits

The model sees a 320 px picture, so edges are soft on large photos. A saliency model picks "the main subject"; with several objects it may keep or drop the wrong one. Colour cut-out remains better for clean studio shots.

Tests

tests/stills/test_neural_cutout.py uses a fake model session (preprocess shape, alpha stretch and resize, flat map, edit op, bool check, unknown keys, missing-model message, CLI flag and exit code, manifest has hash/licence/no bria). One test runs the real model and is skipped without it; it passed locally (real model, bright square on a dark scene). test_r7_cli_mcp updated for the new manifest key. The full suite is left to CI.

Not included

No change to the hosted repo.


Generated by Claude Code

…eural (u2netp)

Adds the u2netp salient-object model (Apache-2.0, 4.5 MB) to the model manifest with a pinned URL and SHA-256, and a CPU onnxruntime cut-out that needs no plain background. The colour cut-out stays the default; nothing downloads except setup-models. No new dependency (onnxruntime is already in requirements-reel).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017qYKdYke3ySSZS76W9Tp34
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017qYKdYke3ySSZS76W9Tp34
@IsraelWebDev
IsraelWebDev marked this pull request as ready for review November 30, 2026 09:32
@IsraelWebDev
IsraelWebDev merged commit 348bfb0 into main Nov 30, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants