本项目将 ModelScope 上的 prithivMLmods/Watermark-Detection-SigLIP2 水印检测模型适配到昇腾 NPU (Ascend910) 上运行。
SiglipForImageClassificationmodel.safetensors (~355MB)snapshot_download 本地下载 + local_files_only=True 加载| 项目 | 版本/型号 |
|---|---|
| NPU | Ascend910 |
| CANN | 8.5.1 |
| torch | 2.x |
| torch_npu | 对应 CANN 8.5.1 |
| transformers | 4.50.0 |
pip install -r requirements.txt
python inference.py推理结果 (NPU):
Predicted label: No Watermark
Logits: [[0.6695, -0.2639]]
Probabilities:
No Watermark: 0.7178
Watermark: 0.2822日志保存在 logs/inference.log。
对单张测试输入进行 CPU 与 NPU 一致性验证:
| 指标 | 数值 |
|---|---|
| max_abs_error | 0.000286 |
| mean_abs_error | 0.000273 |
| relative_error | 0.0585% |
| cosine_similarity | 1.000000 |
| threshold | 1.0% |
| 结果 | PASS |
在 Ascend910 单卡 NPU 上的性能表现:
| 指标 | 数值 |
|---|---|
| avg_latency | 6.372 ms |
| min_latency | 6.149 ms |
| max_latency | 6.520 ms |
| p50_latency | 6.370 ms |
| p90_latency | 6.502 ms |
| p95_latency | 6.511 ms |
| throughput | 156.93 images/sec |
测试配置:warmup 2 次,正式测试 10 次,输入尺寸 224x224。
本项目包含单输入 smoke consistency 验证,非官方完整验证集评测。详细指标见第 4 节。
见 screenshots/self_verification.txt 与 screenshots/self_verification.png。
| 文件 | 内容 |
|---|---|
logs/env_check.log | NPU 环境检查结果 |
logs/inference.log | NPU 推理输出 |
logs/accuracy.log | CPU-NPU 精度一致性检查 |
logs/benchmark.log | NPU 性能基准测试 |
snapshot_download 本地缓存加载,运行时需确保本地缓存存在或联网下载。Device do not support double dtype now 的 warning,不影响结果正确性。#NPU #Ascend #Ascend910 #ModelScope #WatermarkDetection #SigLIP