将 128 个相关性分数分解为 db4 小波系数,仅保留指定层细节并重建变化曲线。按峰值检测语义边界,计算各片段重要性并分配 12 帧预算,使用相关性与多样性 MMR 选择帧,最终对原始特征执行索引提取。
[(128), (128,8)] · budget=12;默认 db4 与自动 DWT level;eval[(12,8), (12)] · 按时间排序的 12 帧特征及索引0 个参数(可训练 0;sum(p.numel()),包含非训练 Parameter,不计 buffer) · 长视频离线帧选择forward() 数据流顺序拆解 · 点击任意子模块方块可同步查看对应源码切片将 128 个相关性分数分解为 db4 小波系数,仅保留指定层细节并重建变化曲线。按峰值检测语义边界,计算各片段重要性并分配 12 帧预算,使用相关性与多样性 MMR 选择帧,最终对原始特征执行索引提取。
121 scores = relevance.detach().to(device='cpu', dtype=torch.float64)137 detail = self._detail(scores)139 peaks = self.detect_peaks(detail, distance)145 segments = list(zip(boundaries[:-1], boundaries[1:]))146 importance = [self._importance(segment, scores) for segment in segments]153 weights = torch.softmax(torch.tensor(importance, dtype=torch.float64) / max(self.config.temperature, 1e-8), dim=0)155 allocated = raw.floor().long()158 scores = 2.0 * scores - 1.0167 index = self._mmr(candidates, local, scores, normalized_features)180 return torch.tensor(selected, dtype=torch.long, device=relevance.device)183 indices = self.select_indices(relevance, features)184 return features.index_select(0, indices.to(features.device)), indices
宿主先计算每帧相关性与帧特征。本组件无训练权重,直接返回预算内选中特征及其原始帧位置。
from WFSWaveletFrameSelector import WFSWaveletFrameSelector model = WFSWaveletFrameSelector(budget=12) selected_features, indices = model(relevance, features)
Method 动机参考:在固定帧预算下兼顾语义变化、相关性与帧间多样性,供宿主视频理解模型使用。
| 消融变体 | 结构配置 | 验证目的 |
|---|---|---|
| 均匀采样 | 固定等距 12 帧 | 比较语义覆盖 |
| 相关性 Top-k | 只取最高分帧 | 比较重复程度 |
| 边界 + MMR | 完整选择流程 | 比较任务表现;待运行对照 |