Open
【11月贡献大赛-Bug修复】fix(image-processor-config-auditor): 拦截负 image_std 归一化标准差(Fixes #4171) #7338
【11月贡献大赛-Bug修复】fix(image-processor-config-auditor): 拦截负 image_std 归一化标准差(Fixes #4171) #7338
Open
W8FXN182FAdd on 2 hours ago
W8FXN182F
W8FXN182F
2 hours ago

一句话

preprocessor_config.json 审计器只拦截 image_std 恰为 0 的情况,负标准差(如 [-0.5, 0.5, 0.5])仍被判为 READY;本 PR 将负 image_std 作为独立 BLOCK finding 拦截,并保留原有零标准差规则。

复现(命令 + 修复前输出)

import sys
sys.path.insert(0, "skills/verification/ascend-image-processor-config-auditor/scripts")
import audit_image_processor_config as auditor

config = {
    "image_processor_type": "CLIPImageProcessor",
    "do_normalize": True,
    "image_mean": [0.5, 0.5, 0.5],
    "image_std": [-0.5, 0.5, 0.5],
}
print(auditor.audit(config, {"num_channels": 3}))

修复前输出(决策 READY、无 finding):

{'decision': 'READY', 'findings': []}

对比:把 image_std 中的 -0.5 换成 0.0 时原逻辑能返回 BLOCK,说明负值绕过了 ZERO_NORMALIZATION_STD 检查。负标准差会反转对应通道的归一化方向,与预处理契约不一致。

方案

在 scripts/audit_image_processor_config.py 的归一化向量校验处:

  • 保留 ZERO_NORMALIZATION_STD(含 0 即 BLOCK);
  • 新增 NEGATIVE_NORMALIZATION_STD(BLOCK),拦截 image_std 中任一负值。

代码改动仅此 1 个脚本;另新增回归测试 tests/test_negative_std.py,并按赛制合规补齐 readme.md(原目录仅含 SKILL.md,缺 readme.md)。

证据(unittest 原始输出)

修复前基线(tests/test_audit_image_processor_config.py):Ran 27 tests in 0.123s ... OK

修复后:

  • 新增 tests/test_negative_std.py:Ran 4 tests in 0.066s ... OK
    (负值 BLOCK、正值向量 READY、零值仍 BLOCK、CLI 退出码 2)
  • 原有 tests/test_audit_image_processor_config.py:Ran 27 tests in 0.123s ... OK

复现对象验证:

  • 负 image_std -> {'decision': 'BLOCK', 'findings': [{'level': 'BLOCK', 'code': 'NEGATIVE_NORMALIZATION_STD', ...}]}
  • 正 image_std -> {'decision': 'READY', 'findings': []}

说明:本修复为纯 Python 标准库确定性复现,无 NPU 环境,未声称真机验证。

likedislike
Merge blocked
ascend-robotascend-robotCollaborators
2 hours ago Added label: ascend-cla/no
ascend-robot
ascend-robotCollaborators
2 hours ago Comments:

Thanks for your pull-request.
The full list of commands accepted by me can be found at here.
You can get sig-info at here.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.


PR Approval Progress

⚠️ This PR does not yet meet the following requirements:lgtm (requires ≥ 2 person(s) per module)、approve (requires ≥ 1 person(s) per module)

Module Approval Details

module lgtm status approve status
sig-model-agent ❌ (0/2)(You can also ask: starmountain, 花新宇, cookieyyds, 陈少宏, 胡晓曼) ❌ (0/1)(You can also ask: 王岩, 张玉橙, 陈少宏, 胡晓曼, 顾梦沁)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

W8FXN182F, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
W8FXN182F
W8FXN182F
2 hours ago Comments:

/check-cla

likedislike
ascend-robot
ascend-robotCollaborators
2 hours ago Comments:

CLA检查未通过,详情可参考这里

likedislike
W8FXN182FW8FXN182F
2 hours ago Force-pushed 1 commits:8a17c0a6-fix(ascend-image-processor-config-auditor): 拦截负 image_std 归一化标准差(Fixes #4171)
W8FXN182F
W8FXN182F
2 hours ago Comments:

/check-cla

likedislike
ascend-robotascend-robotCollaborators
2 hours ago Removed label: ascend-cla/no
ascend-robotascend-robotCollaborators
2 hours ago Added label: ascend-cla/yes
ascend-robot
ascend-robotCollaborators
2 hours ago Comments:

CLA检查已通过,详情可参考这里

likedislike