模型名称: momentslab/peek
模型链接: HuggingFace
模型描述: PEEK (Picking Essential frames via Efficient Knowledge distillation) 是一个无查询的视频帧选择器。它使用冻结的 MobileCLIP2-S0 编码器提取帧特征,通过轻量级 2 层 Transformer(PeekScorer)预测每帧的相关性分数,再通过 stratified_argmax 策略选择 Top-K 最具代表性的帧。
模型架构: PeekScorer — 2-layer Transformer Encoder + Linear score head
参数规模: ~1.7M(PeekScorer),不含 MobileCLIP2-S0 编码器
输入规格:
(B, T, 512) float 张量(B, T) bool 张量(True=有效帧,False=填充)输出规格:
(B, T) float 张量| 依赖项 | 版本要求 | 说明 |
|---|---|---|
| Python | >= 3.10 | 推荐 3.11 |
| torch | >= 2.1.0 | PyTorch 框架 |
| torch_npu | >= 2.1.0 | 昇腾 NPU 后端 |
| transformers | >= 4.49 | HuggingFace Transformers |
| open_clip_torch | >= 2.30 | MobileCLIP2 编码器 |
| safetensors | >= 0.4 | 权重加载 |
| huggingface_hub | >= 0.23 | 模型下载 |
| 昇腾驱动 | CANN 8.0+ | 推荐 CANN 8.5.1 |
安装命令:
pip install -r requirements.txt# 检查 NPU 设备
npu-smi info
# 验证 torch_npu
python3 -c "import torch_npu; print(torch.npu.device_count(), torch.npu.get_device_name(0))"# 从 HuggingFace 下载权重
huggingface-cli download momentslab/peek --local-dir ./peek_weights# Dummy 推理测试(无需视频文件)
python3 inference.py --model-path ./peek_weights
# 对视频进行帧选择
python3 inference.py --model-path ./peek_weights --video path/to/video.mp4 --k 4
# 自定义参数
python3 inference.py --model-path ./peek_weights --video video.mp4 --k 8 --fps 1.0 --device npu:0| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| --model-path | str | 必填 | 模型 checkpoint 目录路径 |
| --video | Path | None | 输入视频文件路径,不提供则使用 dummy embeddings |
| --k | int | 4 | 选择的关键帧数量 |
| --fps | float | 2.0 | 视频帧提取帧率 |
| --device | str | npu:0 | 推理设备 |
[模型] PEEK (momentslab/peek)
[设备] npu:0
[输入] video=None, k=4, fps=2.0
[状态] 模型加载成功 (PeekScorer, encoder=apple/MobileCLIP2-S0)
[状态] 无视频文件,使用 dummy embeddings 进行推理测试
[输出] scores shape: torch.Size([1, 20])
[输出] score range: [-2.0631, -0.0397]
[输出] selected indices: [1, 8, 11, 19]
[输出] selected scores: [-0.3239, -0.0397, -1.0606, -1.5615]
[耗时] 67.3ms
[状态] SUCCESS运行命令:
python3 inference.py --model-path /tmp/adapt_momentslab_peek/weights输出:
[模型] PEEK (momentslab/peek)
[设备] npu:0
[输入] video=None, k=4, fps=2.0
[状态] 模型加载成功 (PeekScorer, encoder=apple/MobileCLIP2-S0)
[状态] 无视频文件,使用 dummy embeddings 进行推理测试
[输出] scores shape: torch.Size([1, 20])
[输出] score range: [-2.0631, -0.0397]
[输出] selected indices: [1, 8, 11, 19]
[输出] selected scores: [-0.3239, -0.0397, -1.0606, -1.5615]
[耗时] 67.3ms
[状态] SUCCESS


PEEK 的评估基于 ActivityNet Captions 数据集,使用教师模型 (SigLIP2-So400M) 蒸馏训练。
测试数据: ActivityNet Captions (验证集)
评测指标:
| 指标 | 结果 | 说明 |
|---|---|---|
| 视频理解任务精度 | 与教师模型相当 | 使用 2fps 帧率,通过知识蒸馏保持精度 |
| 参数量 | 1.7M | 极轻量级 scorer |
| 推理延迟 | ~67ms (dummy, NPU) | 不含 MobileCLIP2 编码时间 |
评测说明: PEEK 是一个帧选择模型,输出是选中的关键帧索引,最终精度取决于下游视频理解任务(如视频描述生成、动作识别)。
aten::_transformer_encoder_layer_fwd 算子当前不支持 NPU 后端,会回退到 CPU 执行,不影响功能但可能有性能影响