Open
【11月贡献大赛-缺陷修复】图像预处理审计允许负 image_std 得到 READY #4171
2301_80657784Add on  22 hours ago
2301_80657784
2301_80657784
22 hours ago Create

问题现象

预处理器配置中的 image_std 是归一化标准差。当前审计器只拦截恰好为 0 的值;包含负数的 image_std 仍可能被判定为 READY。负标准差会反转对应通道的归一化方向,容易造成模型输入与预期预处理契约不一致。

环境信息

  • 仓库:Ascend/model-agent
  • 复现基线:bdb2fc194189f1b48affe4be61a2bcd41529e13b
  • Python:3.12.0
  • 依赖:Python 标准库
  • 硬件:不需要 NPU;直接调用配置审计逻辑

最小复现步骤

import sys
from pathlib import Path

scripts = Path(
    "skills/verification/ascend-image-processor-config-auditor/scripts"
)
sys.path.insert(0, str(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}))

当前返回 decision=READY、findings=[]。同一配置将 image_std 中的 0.5 改成 0.0 时则返回 BLOCK。

根因分析

audit() 只判断 image_std 是否包含 0,没有拒绝负值;负数绕过了 ZERO_NORMALIZATION_STD 检查。

期望修复方向

保留零标准差规则,并将负的 image_std 作为独立 BLOCK finding。增加回归用例验证负值被拦截,同时保持正数向量通过。

查重记录

已检索 ascend-image-processor-config-auditor 和 image_std negative,最近 8 页 Issue/PR 均无命中。当前文件的既有测试覆盖零标准差与向量形状,但没有负标准差用例;搜索分页在 8 页处截断。

likedislike
2301_806577842301_80657784
22 hours ago Added label: bug
2301_806577842301_80657784
22 hours ago Associated pull request