fix(matte): 键控杀伤半径按底噪推导 - #369
Merged
minorcell merged 1 commit intoAug 18, 2026
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Summary
键控清理的杀伤半径由固定常数 38 改为按四角实测的底色噪声推导(下限 6、上限 24、系数 4×σ)。
_flat_bg_penalty是乘性惩罚、作用于全图,不区分主体内外:与底色距离小于半径的像素直接归零,半径到半径+14 之间线性变半透明。半径 38 远超真空隙需要的宽度,于是把与底色接近的主体内部像素一起削掉——浅色角色正好落在这个窗口里,深色角色距离 300 以上永远不沾。要清掉的是被主体围住的那块底色本身,它与四角同源、差异只来自压缩噪声,量级由四角离散度直接给出。固定常数没有这个信息。
Closes #365
实测:五个真实角色母版
主体判据用 u2netp 的真实掩码(
_predict_mask输出 > 0.7),不是按颜色距离反推——否则就是拿被测量的性质去定义被测对象。受损 = 主体区里被全杀或被削成半透明的像素占比。半透明那一档更隐蔽:角色没被挖空但整体发虚,落在过渡带里不产生任何异常。
清理能力没有回退
合成用例覆盖被主体围住的底色空隙(这是本函数存在的理由——u2netp 对闭合区域失灵,四足腿间的背景会被当成主体内部整块留下):
噪声底自动把半径放宽到 12.1,仍然清得掉。
不包含
Test plan
uv run ruff check .→ All checks passeduv run lint-imports→ 2 kept, 0 brokenuv run python -m scripts.export_openapi && git diff --exit-code -- ../openapi.json→ 无漂移uv run pytest -q→ 737 passed, 14 skipped