liuhongwei-2026/wifi-view
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

wifi-view (RuView WiFi CSI encoder) on Ascend NPU

wifi-view —— 由 Vikkyv9/wifi-view 镜像的 RuView WiFi 感知 (WiFi sensing) 对比学习编码器, 把 ESP32 采集的 8 维 CSI (Channel State Information) 特征编码为 128 维 L2 归一化嵌入, 并附带 presence-head(有人存在判定)与 node-1/node-2 房间 LoRA 适配器。

本仓库内容:在昇腾 NPU 上完成 Vikkyv9/wifi-view 的模型适配与服务化推理适配, 含推理脚本、服务化脚本、部署说明、环境依赖清单与截图素材目录。

  • 模型来源: https://huggingface.co/Vikkyv9/wifi-view (镜像 https://ai.gitcode.com/hf_mirrors/Vikkyv9/wifi-view)
  • 架构: Enc(8 → 64 → 128,BatchNorm + GELU → L2 normalize,9,280 参数)
  • 附加组件: presence-head(128 → sigmoid P(present))、node-1/node-2 rank-4 LoRA 房间适配
  • 适配状态: SUCCESS(NPU 实机验证通过)
  • 适配时间: 2026-08-23

1. 验证环境

组件版本
torch2.9.0
torch_npu2.9.0.post1
CANN8.5.1
Python3.11.14
NPUAscend 910

2. 模型适配说明

wifi-view 为“其他”类 WiFi感知嵌入模型,不属 vLLM 模型 registry,因此采用 torch_npu 原生路径自建 OpenAI 风格服务,而非 vLLM-Ascend。

两个真实权重门禁均通过(NPU 上实测):

  • Stage A:csi-embed-v2.safetensors(练好的 8→64→128 encoder)随机输入前向, 输出形状 (1,128) 且 L2 len≈1.0,无 NaN/Inf;
  • Stage B:presence-head 附加头输出 P(present),node-1 LoRA 残差路径正常。

训练标准化统计(FEATURE_MEAN / FEATURE_STD)取自csi-embed-v2.py。 ⚠️ 原仓 model.safetensors 头部 JSON 损坏(trailing chars),不能用 safetensors 载入, 统一使用打好的 csi-embed-v2.safetensors。

3. 目录结构

wifi-view/
├── inference.py        # 推理脚本(必选)
├── serve.py            # 服务化推理(FastAPI, /v1/models, /v1/embeddings, /v1/presence)
├── README.md           # 部署说明文档(必选)
├── requirements.txt    # 环境依赖清单(必选)
├── weights/            # 权重文件(csi-embed-v2.safetensors / presence-head.json / node-*.json)
└── assets/             # 截图素材文件夹(必选)
        ├── agent_workflow.png
        ├── npu_device_call.png
        └── model_result.png

4. 复现步骤

# 1) 安装依赖
pip install -r requirements.txt

# 2) 权重 (已随仓放置于 weights/;也可从 hf 镜像拉取后替换)
#    csi-embed-v2.safetensors   --8->64->128 encoder (~40KB)
#    presence-head.json         -- presence 权值
#    node-1.json / node-2.json  -- 房间 rank-4 LoRA

# 3) 单次推理 (NPU)
python3 inference.py --feature "0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8" --device npu:0
python3 inference.py --input feats.csv --device npu:0
python3 inference.py --feature "..." --node node-1 --device npu:0   # 附 LoRA 房间适配

# 4) 服务化推理
python3 serve.py   # 默认 0.0.0.0:8000, 可用 --port --device 覆盖

服务化调用

curl http://127.0.0.1:8000/v1/models

curl -X POST http://127.0.0.1:8000/v1/embeddings \
  -H 'Content-Type: application/json' \
  -d '{"input":[[0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8]]}'

# 带房间适配
curl -X POST http://127.0.0.1:8000/v1/embeddings \
  -H 'Content-Type: application/json' \
  -d '{"input":[[0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8]],"node":"node-1"}'

# presence
curl -X POST http://127.0.0.1:8000/v1/presence \
  -H 'Content-Type: application/json' \
  -d '{"input":[[0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8]]}'

响应示例:

{"object":"list","model":"Vikkyv9/wifi-view","data":[{"object":"embedding","index":0,
  "embedding":[0.1093,-0.0242,-0.0404,...128-dim...]}]}
{"presence":[0.9998]}

5. 性能(真权重, NPU)

阶段指标数值
编码Encoder (8→128, 单帧)<1ms
presence头前向<1ms

6. 截图素材

见 assets/(agent_workflow.png / npu_device_call.png / model_result.png), 验证完成后替换。


贡献者: 适配者 | 赛道: 模型适配赛道 | 硬件: NPU