2
gcw_BOxvkDDf/wifi-densepose-pretrained
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

wifi-densepose-pretrained — Ascend NPU adaptation

Adaptation of ruvnet/wifi-densepose-pretrained ("WiFi-DensePose") to run on Huawei Ascend NPU via torch_npu (no CUDA anywhere).

The original repo ships a csi-encoder-8-64-128 contrastive CSI embedding model (8 -> 64 -> 128) with a rank-8 task LoRA, optional per-room node LoRAs and a human-presence head, serialized as model.safetensors (+ node-*.json, presence-head.json). This project loads those weights in torch, reconstructs the forward pass, and runs it on npu:0.

Model contract

  • Input: a standardized 8-dim CSI feature vector x: [B, 8] (the feat8 contract documented in csi-embed-v2.py). A raw CSI amplitude matrix [T,K] / [B,T,K] is also accepted and reduced to 8 statistical features (mean/std/max/min/median/ptp/energy/activity) — see caveat below.
  • Forward (from model.safetensors + csi-embed-v2.py): h = GELU(BN1(Linear8->64(x))), z = L2norm(BN2(Linear64->128(h))), then z += scaling * ((z @ A) @ B) (task LoRA, rank 8, scaling 2.0), renormalised, then optional per-room node LoRA (node-1/2.json, rank 4, alpha 8, scaling 2).
  • Output: presence = sigmoid(z @ w + b) (human-presence probability) and the 128-dim L2-normalised CSI embedding.

Files

filepurpose
inference.pyCLI + FastAPI (--serve) inference on NPU
model.pytorch WiFiDensePoseModel (loads model.safetensors, node-*.json)
make_sample.pygenerate sample_csi.pt ([1,8]) and sample_amp.npy ([64,64])
requirements.txtpip deps (all already present on the host)
model_weights/cached weights (git-ignored)

Quick start (Ascend NPU)

export ASCEND_RT_VISIBLE_DEVICES=1
source /usr/local/Ascend/ascend-toolkit/set_env.sh

# generate sample inputs
python3 make_sample.py

# CLI inference
python3 inference.py --input sample_csi.pt --node 1 --num_workers 0

# FastAPI service
python3 inference.py --serve --port 8000
#   GET  /            -> HTML upload form
#   POST /predict     -> multipart file (.pt/.npy) or JSON
#        curl -X POST http://0.0.0.0:8000/predict -F "file=@sample_csi.pt"

Device selection uses the spec's try/except: NPU if available (npu:0), CPU fallback.

Weights

Cached at ./model_weights/ruvnet/wifi-densepose-pretrained (downloaded via _shared/download_weights.py, hf-mirror). Note: the uploaded model.safetensors pads its safetensors JSON header with NUL bytes instead of ASCII spaces (non spec-compliant); model.py repairs the header transparently so the standard safetensors loader can read it.

Caveats

  • README.md of the upstream repo could not be fetched (hf-mirror / HF both timed out on this host); the forward was reconstructed from config.json, csi-embed-v2.py, model.safetensors, model.rvf.jsonl, node-*.json and presence-head.json.
  • The encoder weights in model.safetensors differ from csi-embed-v2.safetensors (different training); model.safetensors is treated as the primary model.
  • The exact ordering of task-LoRA vs node-LoRA vs presence-head is inferred (task LoRA on embedding, then optional node LoRA, then presence head) — reasonable but not ground-truth from the upstream repo.
  • Raw amplitude-matrix input ([T,K]/[B,T,K]) is reduced to 8 statistical features with an on-the-fly standardisation; this is an approximation because the original CSI feature-extractor is not part of the repo. Prefer feeding the 8-dim standardized feature vector directly.
  • No CUDA code: grep -rin cuda --include=*.py . is clean.