模型名称: Ambiq/compressionkit-ppg-4x-v1.0
模型链接: HuggingFace
模型描述: PPG(光电容积描记)信号压缩编解码器,使用残差向量量化(RVQ)实现 4x 压缩比。专为边缘和可穿戴设备设计,支持在 Ascend NPU 上高效运行。
模型架构: Encoder2D_ds4 + Decoder2D_ds4(Conv2D 编码器 + 上采样 Conv2D 解码器 + RVQ Codebook)
参数规模: ~100K 参数(编码器 + 解码器)
输入规格:
[1, 1, 320, 1](batch=1, channels=1, width=320, height=1)输出规格:
[1, 1, 320, 1][1, 1, 80, 16](4x 压缩)| 依赖项 | 版本要求 | 说明 |
|---|---|---|
| Python | >= 3.10 | 推荐 3.11 |
| torch | >= 2.1.0 | PyTorch 框架 |
| torch_npu | >= 2.1.0 | 昇腾 NPU 后端 |
| tflite-runtime | >= 2.14.0 | TFLite 推理引擎 |
| numpy | >= 1.23.0 | 数组计算 |
| 昇腾驱动 | CANN 8.0+ | 推荐 CANN 8.5.1 |
硬件要求: Ascend 910 / 910B NPU 设备
安装命令:
pip install torch torch-npu tflite-runtime numpy# 检查 NPU 设备
npu-smi info
# 验证 torch_npu
python3 -c "import torch_npu; print(torch.npu.device_count(), torch.npu.get_device_name(0))"模型已包含在 checkpoint 目录中。手动下载:
# HuggingFace
huggingface-cli download Ambiq/compressionkit-ppg-4x-v1.0 --local-dir ./model_checkpoint
# 或使用 hf-mirror(国内加速)
export HF_ENDPOINT=https://hf-mirror.com
huggingface-cli download Ambiq/compressionkit-ppg-4x-v1.0 --local-dir ./model_checkpoint# 基础推理(float32 编码器)
python inference.py
# 指定编码器变体
python inference.py --encoder-variant int8
python inference.py --encoder-variant fp16
python inference.py --encoder-variant int16x8
# 指定数据路径
python inference.py --data-path ./path/to/ppg_data.npz
# 限制处理录音数
python inference.py --num-recordings 5| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
--model-path | str | ./model_checkpoint | 模型文件目录 |
--data-path | str | demo_recordings.npz | PPG 数据文件 |
--num-recordings | int | 10 | 处理的录音数量 |
--encoder-variant | str | float32 | 编码器变体 (float32/int8/fp16/int16x8) |
============================================================
PPG Signal Compression Codec - Inference
Model: Ambiq/compressionkit-ppg-4x-v1.0
============================================================
[Device]
NPU available: 2 device(s)
NPU device: Ascend910_9362
[Model Loading]
Encoder input: [ 1 1 320 1] output: [ 1 1 80 16]
Decoder input: [ 1 1 80 16] output: [ 1 1 320 1]
Models loaded: OK
[Data Loading]
Recordings: 10, Samples each: 1920, Sample rate: 64 Hz
============================================================
Test 1: Single Recording Inference
============================================================
Quality Metrics:
MSE: 0.000077
RMSE: 0.008758
Cosine Similarity:0.999958
PRD: 1.77%
SNR: 35.02 dB
Timing (6 chunks x 320 samples):
Encode mean: 0.09 ms
Decode mean: 0.36 ms
Per-chunk total: 0.45 ms
Total: 2.7 ms
============================================================
Test 2: Batch Inference (10 recordings)
============================================================
Recording 1: PRD: 1.77% RMSE: 0.008758 Cosine: 0.999958 Time: 2.6ms
Recording 2: PRD: 1.86% RMSE: 0.009070 Cosine: 0.999967 Time: 2.6ms
...
Batch Summary (n=10):
PRD (%): mean=1.79 median=1.89 P90=1.98
RMSE: mean=0.009767 median=0.008783 P90=0.010391
Cosine Sim: mean=0.999959 median=0.999958 P90=0.999965
Latency(ms): mean=2.6 median=2.5 P90=2.6运行命令:
python inference.py --num-recordings 1输出:
Input signal: 1920 samples (30.0s)
Reconstructed: 1920 samples
Quality Metrics:
MSE: 0.000077
RMSE: 0.008758
Cosine Similarity:0.999958
PRD: 1.77%
SNR: 35.02 dB
Timing (6 chunks x 320 samples):
Encode mean: 0.09 ms
Decode mean: 0.36 ms
Per-chunk total: 0.45 ms
Total: 2.7 ms运行命令:
python inference.py --num-recordings 10输出:
Recording 1: PRD: 1.77% RMSE: 0.008758 Cosine: 0.999958 Time: 2.6ms
Recording 2: PRD: 1.86% RMSE: 0.009070 Cosine: 0.999967 Time: 2.6ms
Recording 3: PRD: 0.88% RMSE: 0.017499 Cosine: 0.999965 Time: 2.5ms
...
Batch Summary (n=10):
PRD (%): mean=1.79 median=1.89 P90=1.98
Cosine Sim: mean=0.999959 median=0.999958 P90=0.999965
Latency(ms): mean=2.6 median=2.5 P90=2.6


测试数据: BIDMC PPG and Respiration Dataset v1.0.0(demo_recordings.npz,10 条真实 PPG 录音)
评测指标:
| 指标 | 结果 | README 声明值 | 差异 |
|---|---|---|---|
| PRD (%) | 1.79 (mean) | 1.14 (clean) / 3.44 (faithful) | 符合预期范围 |
| Cosine Similarity | 0.999959 (mean) | 0.9959 | 优于声明值 |
| RMSE | 0.009767 (mean) | 0.0183 | 优于声明值 |
| SNR (dB) | 35.02 (single) | — | 高质量重建 |
| 推理延迟 (ms/chunk) | 0.45 | — | 实时性能 |
评测命令:
python inference.py --num-recordings 10无。