xujiashuai/cv_hrnetocr_skychange
模型介绍文件和版本Pull Requests讨论分析

cv_hrnetocr_skychange - Ascend NPU 适配

1. 模型简介

HRNet+OCR 天空变化检测模型,基于 HRNet 骨干网络和 OCR(Object-Contextual Representations)模块,用于天空区域分割。该模型是天空替换 pipeline 的核心组件,能够准确识别图像中的天空区域。

  • 原始模型: damo/cv_hrnetocr_skychange
  • 框架: PyTorch
  • 任务: 天空区域分割 (Sky Segmentation)

2. 昇腾 NPU 适配结果

指标值
Cosine Similarity1.000005
MaxAbsErr0.002669
Relative Error0.2783%
平均延迟28.24 ms
峰值显存0.68 GB
推理精度float32
设备Ascend 910B4

3. 环境要求

组件版本
CANN8.5.1
torch_npu2.9.0.post1
PyTorch2.9.0
Python3.11

4. 快速使用

# 设置环境
source setup_env.sh

# 运行推理 (CPU vs NPU 对比)
python3 inference.py --device npu:0

5. 推理输出证据

NPU 推理输出(float32, sky mask 对比):

模型: damo/cv_hrnetocr_skychange
设备: npu:0
------------------------------------------------------------
  Input shape: torch.Size([1, 3, 904, 1600])
[CPU] 加载模型...
[CPU] 推理中...
  CPU mask shape: torch.Size([1, 1, 320, 320])
[NPU] 加载模型到 npu:0...
[NPU] 推理中...
  NPU mask shape: torch.Size([1, 1, 320, 320])

  Cosine Similarity: 1.000005
  MaxAbsErr: 0.002669
  Relative Error: 0.2783%

✓ 推理完成

[Perf] 测延迟...
  平均延迟: 28.24 ms
  峰值显存: 0.68 GB

6. CPU vs NPU 精度对比

指标CPU (float32)NPU (float32)误差
Cosine Similarity基准1.000005< 0.001%
MaxAbsErr-0.002669-
Relative Error-0.2783%< 1% ✓
输出维度[1, 1, 320, 320][1, 1, 320, 320]一致
NaNFalseFalse一致

7. 模型结构

  • Backbone: HRNet (High-Resolution Network)
  • Head: OCR (Object-Contextual Representations)
  • 输入: RGB 图像 (预处理后 640x640)
  • 输出: 天空分割 mask (320x320, 2类概率)
  • Coarse 模型: HRNet+OCR 天空分割
  • Refine 模型: UNet 细化 (NPU 不兼容 max_unpool2d, 已跳过)

8. 验证报告

详见 screenshots/verification.txt。

9. Agent Skill

本适配由 Ascend NPU 适配 Agent Skill 自动完成。

下载使用量0