K-ON111111/ruview
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

ruv/ruview — 昇腾 NPU 适配模型

赛事: 昇腾 Model Agent 模型适配大赛(第二季) 引擎: torch_npu + 自包含 PyTorch 实现(CSI 编码器) 硬件: Ascend 310P / 910B 标签: npu ascend pytorch wifi-sensing edge-ai

📖 模型简介

RuView 是一套 WiFi 感知模型,将 WiFi 信号转化为空间智能(人体检测、呼吸/心率 测量、姿态估计等)。本适配交付其对比学习编码器(csi-encoder-8-64-128): 8 维 CSI 特征 → 64 维隐藏 → 128 维嵌入,带 LoRA 低秩适配与 presence 检测头。 库依赖 onnxruntime,本交付为 torch 版等价实现,可在昇腾 NPU 上运行。

属性值
原始模型https://huggingface.co/ruv/ruview
架构csi-encoder-8-64-128(对比学习编码器 + LoRA + presence head)
任务类型WiFi 感知(CSI 嵌入 + presence 检测)
输入格式8 维 CSI 特征
输出格式128 维嵌入 + presence 概率

🔧 环境依赖

pip install -r requirements.txt -i https://repo.huaweicloud.com/repository/pypi/simple/

🚀 推理步骤

⚠️ 本仓库不包含模型权重(交付件仅 inference.py / readme.md / requirements.txt / assets/), 推理前必须先从原始模型仓单独下载权重。

# 1. 下载模型权重(仓库不含权重,必须单独下载)
git clone https://gitcode.com/hf_mirrors/ruv/ruview.git ./ruview

# 2. 运行 NPU 推理
python3 inference.py --model_path ./ruview \
  --batch 4 --device npu:0 --output inference_result.json

🧪 测试用例

用例 1: CSI 特征 → 嵌入 + presence

python3 inference.py --model_path ./ruview \
  --batch 4 --device npu:0 --output inference_result.json

预期输出:

[Model Agent] ✅ NPU 设备就绪: Ascend310P3
[Model Agent] ✅ 模型加载完成 → npu:0
[Model Agent] ✅ 推理完成: 嵌入 (4, 128), presence (4, 1), 耗时 0.0023s
[Model Agent] ✅ 结果已保存 → inference_result.json

推理结果摘要:

{
  "model": "ruv/ruview",
  "engine": "torch_npu",
  "device": "npu:0",
  "embedding_shape": [4, 128],
  "presence": [0.5, 0.5, 0.5, 0.5],
  "inference_time_s": 0.0023
}

📁 目录结构

.
├── inference.py          # NPU 推理脚本
├── readme.md             # 本文件
├── requirements.txt      # 依赖清单
└── assets/               # 截图素材

📝 适配说明

本模型由 昇腾 Model Agent 自动完成 NPU 适配:

  • 非标准 safetensors 容错解析:ruview 的 model.safetensors 头部含 __metadata__ 字段且 JSON 尾部有 3 字节 padding,标准 safetensors 库 解析失败,inference.py 实现逐步截短定位 JSON 真实结束点的容错解析
  • 权重 reshape:w1/w2 为展平存储(512 = 64×8、8192 = 128×64), 加载时还原为矩阵
  • LoRA 旁路:低秩适配 Δh = scale·((h @ lora_B^T) @ lora_A^T)
  • 已在 Ascend 310P3 上实跑验证通过(CSI 特征 → 128 维嵌入 + presence),输出合法