f
gcw_pCMO8DfP/wifi-densepose-pretrained
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

wifi-densepose-pretrained (Ascend NPU)

NPU-adapted inference for aarongid/wifi-densepose-pretrained — a self-supervised WiFi-sensing (RuView/DensePose-style) model that encodes an 8-dim Channel State Information (CSI) feature vector into a 128-dim L2-normalized embedding. Same sona-lora CSI-encoder-8-64-128 architecture as wifi-view.

The model is executed on an Ascend NPU via torch-npu. No CUDA is used anywhere.

ItemValue
TaskWiFi CSI → 128-dim sensing embedding
NetworkLinear(8,64) → BN+GELU → Linear(64,128) → BN → L2-normalize
Params9,280
Input8-dim CSI feature vector (presence, motion, breathing, HR, ...)
Devicenpu:0 (Ascend), CPU fallback

1. Get the weights

Weights are cached in ./model_weights/wifi-densepose-pretrained (auto-downloaded on first run from the hf-mirror.com mirror if the cache is missing):

mkdir -p model_weights/wifi-densepose-pretrained
HF_ENDPOINT=https://hf-mirror.com python3 -m huggingface_hub.snapshot_download \
  aarongid/wifi-densepose-pretrained --local-dir model_weights/wifi-densepose-pretrained

inference.py loads the local cache first (csi-embed-v2.safetensors) and only downloads when the cache is absent.

Weights are git-ignored; only code and assets/ are published.

2. CLI inference

python3 inference.py --img sample_features.txt

The --img argument accepts an 8-dim CSI feature file: .txt, .csv, .npy, .npz or .json (e.g. {"features": [...]}).

Example output:

{
  "model": "wifi-densepose-pretrained",
  "device": "npu:0",
  "embedding_dim": 128,
  "embedding_norm": 1.0,
  "embedding": [0.0412, -0.0857, ...]
}

3. FastAPI service

Serve the model over HTTP:

python3 inference.py --serve --port 8000

Health check:

curl http://127.0.0.1:8000/health
# {"status":"ok","model":"wifi-densepose-pretrained","device":"npu:0"}

Prediction (upload a feature file):

curl -X POST http://127.0.0.1:8000/predict -F "file=@sample_features.txt"

Returns the same JSON result as the CLI.

4. Notes

  • Model and tensors are moved to npu:0; NPU init is wrapped in try-except with a CPU fallback.
  • No CUDA calls; verified by grep for cuda (case-insensitive) in the project code.
  • This is a CSI-sensing model — it consumes 8 numeric radio features, not images.

5. Directory layout

.
├── inference.py            # dual-mode NPU inference (CLI + FastAPI)
├── sample_features.txt     # sample input (8-dim CSI feature vector)
├── sample_features.json
├── README.md
├── assets/                 # 3 screenshots (NPU workflow / CLI / web)
└── model_weights/          # git-ignored weight cache
    └── wifi-densepose-pretrained/{csi-embed-v2.safetensors, config.json, ...}