fix(canvas): 蒙版编辑改用红色高亮标注,修复视觉模型区域定位失败#174
Merged
Merged
Conversation
Erase/Redraw 蒙版旧做法导出「白底 + 透明孔洞」,编辑区仅存在于 alpha 通道,视觉模型在 RGB 里看到的是整张纯白图,无法定位待编辑区域。 改为导出「源图 + 涂抹区半透明红色高亮」:源图打底,涂抹区经 source-in 归一为均匀半透明红后叠加。后端 run_freezone_mask_edit 的 prompt 同步说明 Image 2 的红色高亮仅为区域标注、不得出现在结果中,并更新对应测试断言。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: wen xin <1464521427@qq.com>
修复 #174 review 的两个问题: P1 旧蒙版生产者被破坏: pipeline-import/MaskEditor 仍导出「白底+透明孔洞」, 但后端 /freezone/redraw 对所有 mask_url 一律套用红色高亮 prompt(不区分格式), 模型会去找 RGB 里不存在的红区 → 定位失败。将 MaskEditor 迁移成与 EraseOverlay/RedrawOverlay 一致的红色高亮格式;同步 schemas.py 的公开 API 文档。 P2 source-in 不产生均匀红: mask alpha 因笔刷叠加深浅不均(0.55/0.80), source-in 的 Porter-Duff "in" 使输出 alpha = 0.6 × mask_alpha(0.33/0.48), 不均匀原样保留。改为先二值化 mask alpha 再写固定 rgba(255,0,0,0.6)。 三个 buildMaskBlob 抽出共用 lib/mask-highlight.ts(纯函数 binarizeMaskToRed 便于单测),各删 ~25 行重复合成代码。 验证: 新单测 6/6(单笔140与叠加203二值化后输出一致) / pnpm build ✓ / pytest -k mask_edit ✓ Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: wen xin <1464521427@qq.com>
Collaborator
Author
|
已修复 review 的两个问题(3efda10): P1 旧蒙版生产者被破坏 — P2 source-in 不产生均匀红 — mask alpha 因笔刷叠加深浅不均(0.55/0.80), 三处 验证:新单测 6/6(单笔 alpha 140 与叠加 alpha 203 二值化后输出一致,证明消除了不均) / |
新增的 frontend/src/lib/mask-highlight.ts 与其单测未登记, test_license_inventory_covers_current_git_index(deps 关卡)失败。 按 frontend/src 聚合注解格式补两行。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: wen xin <1464521427@qq.com>
lywaterman
approved these changes
Jul 23, 2026
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 #173
背景
Erase/Redraw 蒙版旧做法导出「白底 + 透明孔洞」,待编辑区域只存在于 alpha 通道,视觉模型在 RGB 里看到的是整张纯白图,无法定位编辑区(详见 #173)。
改动
前端
EraseOverlay.tsx/RedrawOverlay.tsx的buildMaskBlob:source-in归一为均匀的rgba(255,0,0,0.6)(消除笔刷叠加深浅不均)→ 叠到源图上sourceImgRef缓存已加载源图作为打底后端
src/novelvideo/freezone/jobs.py的run_freezone_mask_edit:测试
tests/test_freezone_image_backend.py:test_mask_edit_job_uses_reference_edit_provider_routing断言,匹配新 prompt(red-highlighted region/must NOT appear in the output)验证
pnpm build(tsc -b && vite build)✓pytest tests/test_freezone_image_backend.py -k mask_edit✓ 1 passed🤖 Generated with Claude Code