模块更新于 2026-11-20· 浏览 0· 下载 0
AKS 自适应关键帧采样
相关性覆盖双原则:用轻量视觉-语言模型(默认 BLIP,可换 CLIP 等)计算每帧与问题的匹配分数保证"相关性";再借鉴 Ripley's K 函数,递归分宽度量所选帧在时间轴上的"覆盖",防扎堆、防遗漏
结构图

相关性覆盖双原则:用轻量视觉-语言模型(默认 BLIP,可换 CLIP 等)计算每帧与问题的匹配分数保证"相关性";再借鉴 Ripley's K 函数,递归分宽度量所选帧在时间轴上的"覆盖",防扎堆、防遗漏
论文信息
- 论文:Adaptive Keyframe Sampling for Long Video Understanding
- 出处:CVPR 2025
核心痛点
视频多模态大模型靠把视觉 token 塞进 LLM 上下文来"看"视频,但长视频 token 量远超模型容量,只能采样一小部分帧;现有方法大多沿用均匀采样(如 LLaVA-Video 默认设置),选帧不看问题内容,关键信息漏采后模型只能瞎猜。
模块亮点
- 相关性覆盖双原则:用轻量视觉-语言模型(默认 BLIP,可换 CLIP 等)计算每帧与问题的匹配分数保证"相关性";再借鉴 Ripley's K 函数,递归分宽度量所选帧在时间轴上的"覆盖",防扎堆、防遗漏
- 自适应递归分割:逐层把时间轴对半二分,若某段内 top 帧平均分与整体平均分差距超阈值,就取该段最高分帧;否则继续切分均分配额,在"只挑高分"与"均匀铺开"间权衡
- 零训练涨点:不调 MLLM 参数、只换输入帧,Qwen2-VL 上 LongVideoBench / VideoMME 分别提升 5.0% / 2.3%;消融中 ADA 拿到 62.7 / 65.3,均超均匀采样的 58.9 / 64.4
适用场景
领域为长视频理解 / 视频多模态大模型;原文在 LongVideoBench、VideoMME 上插入 Qwen2-VL、LLaVA-OV、LLaVA-Video 验证,并扩展到视频指代、视频描述;也可迁移到视频字幕生成、时序定位等选帧场景。
插入位置建议
- 放在 MLLM 视觉编码器之前,替换均匀采样,关键帧直接作为视觉 token 输入
- 打分器按需替换:默认 BLIP,也可换 CLIP 等视觉-语言模型
- 换 prompt 即可迁移任务:视频指代、视频描述只需改指令文本,AKS 按问题自适应选帧
适用任务
- 长视频理解
- 视频多模态大模型
完整代码
aks.py
import heapq
import json
import numpy as np
import argparse
import os
def parse_arguments():
parser = argparse.ArgumentParser(description='Extract Video Feature')
parser.add_argument('--dataset_name', type=str, default='longvideobench', help='support longvideobench and videomme')
parser.add_argument('--extract_feature_model', type=str, default='blip', help='blip/clip/sevila')
parser.add_argument('--score_path', type=str, default='./outscores/longvideobench/blip/scores.json')
parser.add_argument('--frame_path', type=str, default='./outscores/longvideobench/blip/frames.json')
parser.add_argument('--max_num_frames', type=int, default=64)
parser.add_argument('--ratio', type=int, default=1)
parser.add_argument('--t1', type=int, default=0.8)
parser.add_argument('--t2', type=int, default=-100)
parser.add_argument('--all_depth', type=int, default=5)
parser.add_argument('--output_file', type=str, default='./selected_frames')
return parser.parse_args()
def meanstd(len_scores, dic_scores, n, fns,t1,t2,all_depth):
split_scores = []
split_fn = []
no_split_scores = []
no_split_fn = []
i= 0
for dic_score, fn in zip(dic_scores, fns):
# normalized_data = (score - np.min(score)) / (np.max(score) - np.min(score))
score = dic_score['score']
depth = dic_score['depth']
mean = np.mean(score)
std = np.std(score)
top_n = heapq.nlargest(n, range(len(score)), score.__getitem__)
top_score = [score[t] for t in top_n]
# print(f"split {i}: ",len(score))
i += 1
mean_diff = np.mean(top_score) - mean
if mean_diff > t1 and std > t2:
no_split_scores.append(dic_score)
no_split_fn.append(fn)
elif depth < all_depth:
# elif len(score)>(len_scores/n)*2 and len(score) >= 8:
score1 = score[:len(score)//2]
score2 = score[len(score)//2:]
fn1 = fn[:len(score)//2]
fn2 = fn[len(score)//2:]
split_scores.append(dict(score=score1,depth=depth+1))
split_scores.append(dict(score=score2,depth=depth+1))
split_fn.append(fn1)
split_fn.append(fn2)
else:
no_split_scores.append(dic_score)
no_split_fn.append(fn)
if len(split_scores) > 0:
all_split_score, all_split_fn = meanstd(len_scores, split_scores, n, split_fn,t1,t2,all_depth)
else:
all_split_score = []
all_split_fn = []
all_split_score = no_split_scores + all_split_score
all_split_fn = no_split_fn + all_split_fn
return all_split_score, all_split_fn
def main(args):
max_num_frames = args.max_num_frames
ratio = args.ratio
t1 = args.t1
t2 = args.t2
all_depth = args.all_depth
outs = []
segs = []
with open(args.score_path) as f:
itm_outs = json.load(f)
with open(args.frame_path) as f:
fn_outs = json.load(f)
if not os.path.exists(os.path.join(args.output_file,args.dataset_name)):
os.mkdir(os.path.join(args.output_file,args.dataset_name))
out_score_path = os.path.join(args.output_file,args.dataset_name,args.extract_feature_model)
if not os.path.exists(out_score_path):
os.mkdir(out_score_path)
for itm_out,fn_out in zip(itm_outs,fn_outs):
nums = int(len(itm_out)/ratio)
new_score = [itm_out[num*ratio] for num in range(nums)]
new_fnum = [fn_out[num*ratio] for num in range(nums)]
score = new_score
fn = new_fnum
num = max_num_frames
if len(score) >= num:
normalized_data = (score - np.min(score)) / (np.max(score) - np.min(score))
a, b = meanstd(len(score), [dict(score=normalized_data,depth=0)], num, [fn], t1, t2, all_depth)
segs.append(len(a))
out = []
if len(score) >= num:
for s,f in zip(a,b):
f_num = int(num / 2**(s['depth']))
topk = heapq.nlargest(f_num, range(len(s['score'])), s['score'].__getitem__)
f_nums = [f[t] for t in topk]
out.extend(f_nums)
out.sort()
outs.append(out)
else:
outs.append(fn)
score_path = os.path.join(out_score_path,'selected_frames.json')
with open(score_path,'w') as f:
json.dump(outs,f)
if __name__ == '__main__':
args = parse_arguments()
main(args)环境与依赖
Python 3.9+
继续浏览
下一篇ARConv 自适应矩形卷积核形状可学习:把卷积核的高和宽当作可学习参数,每个位置都能长出 5×3 这样的自适应矩形核,随物体大小伸缩,计算开销还不随核增大而上升相关资源
模块2026-11-21
MME 遗忘指标元评估
先用受控暴露的模型池检查指标区分能力,再用量化与匹配预算再学习检验判断稳定性。调和平均将忠实度和两类鲁棒性汇总,同时保留分项结果。
多模态大模型机器遗忘模型评估
多模态MIT
模块2026-11-21
MT-NPO 模态分层遗忘
将负偏好核移入词元求和,用有界后缀证据分配词元压力;模态层分别关注残余可访问程度与保留效用退化。论文反传时固定分配权重,现有代码仅作前向结构参考,接入前要核对停止梯度。
多模态大模型机器遗忘负偏好优化
多模态MIT
模块2026-11-20
BAT 通用双向适配器
双向交叉提示:不预设主/辅模态,一个共享参数的通用适配器同时服务两条模态分支,把 A 模态特征经"降维-线性投影-升维"生成特征提示喂给 B 模态,反向同理,主导权随环境切换
目标跟踪多模态BAT
多模态MIT