license: cc-by-nc-sa-4.0
datasets:
- lmms-lab/LLaVA-Video-178K
language:
- en
metrics:
- accuracy
base_model:
- lmms-lab/LLaVA-Video-7B-Qwen2
pipeline_tag: video-text-to-text
library_name: transformers
tags:
- 动作识别
- 视频理解
- 多模态问答
- 多模态
- 视觉语言模型
- LLaVAction框架
- 多模态大语言模型
model-index:
- name: LLaVAction-7B
results:
- task:
type: 多模态理解
dataset:
name: EgoSchema
type: 自我中心视频数据集
metrics:
- type: 准确率
value: 59
name: accuracy
verified: true
- task:
type: 多模态理解
dataset:
name: MVBench
type: 多模态视频基准测试
metrics:
- type: 准确率
value: 61.1
name: accuracy
verified: true
- task:
type: 多模态理解
dataset:
name: NextQA
type: 视频问答数据集
metrics:
- type: 准确率
value: 82.8
name: accuracy
verified: true
- task:
type: 多模态理解
dataset:
name: PercepTest
type: 感知测试集
metrics:
- type: 准确率
value: 70.2
name: accuracy
verified: true
- task:
type: 多模态理解
dataset:
name: LongVideoBench
type: 长视频基准测试
metrics:
- type: 准确率
value: 58.6
name: accuracy
verified: true
- task:
type: 多模态理解
dataset:
name: VideoMME
type: 视频多模态评估
metrics:
- type: 准确率
value: 63.9
name: accuracy
verified: true
- task:
type: 多模态理解
dataset:
name: VideoMME (带字幕)
type: 视频多模态评估
metrics:
- type: 准确率
value: 71.4
name: accuracy
verified: true
LLaVAction-7B
模型概述
LLaVAction-7B模型基于Qwen2语言模型架构,上下文窗口达32K tokens,在EPIC-KITCHENS-100-MQA数据集上训练完成。该模型最多支持处理64帧视频输入。
使用说明
适用场景
本模型在EPIC-KITCHENS-100-MQA[待发布数据集]和LLaVA-Video-178K数据集上训练,显著提升了从第一人称视角视频理解人类动作的能力。
生成示例
我们提供基础调用示例,更多细节请参考GitHub仓库。
!pip install llavaction
from llavaction.model.builder import load_pretrained_model
from llavaction.mm_utils import get_model_name_from_path, process_images, tokenizer_image_token
from llavaction.constants import IMAGE_TOKEN_INDEX, DEFAULT_IMAGE_TOKEN, DEFAULT_IM_START_TOKEN, DEFAULT_IM_END_TOKEN, IGNORE_INDEX
from llavaction.conversation import conv_templates, SeparatorStyle
from PIL import Image
import requests
import copy
import torch
import sys
import warnings
from decord import VideoReader, cpu
import numpy as np
warnings.filterwarnings("ignore")
video_path = "XXXX"
perspective_prompt = "当前视频为第一人称视角,你即是画面中的主角。你的双手正在与物体交互,请描述你正在执行什么动作?"
task_prompt = "请详细描述视频画面内容。"
def load_video(video_path, max_frames_num,fps=1,force_sample=False):
if max_frames_num == 0:
return np.zeros((1, 336, 336, 3))
vr = VideoReader(video_path, ctx=cpu(0),num_threads=1)
total_frame_num = len(vr)
video_time = total_frame_num / vr.get_avg_fps()
fps = round(vr.get_avg_fps()/fps)
frame_idx = [i for i in range(0, len(vr), fps)]
if len(frame_idx) > max_frames_num or force_sample:
sample_fps = max_frames_num
uniform_sampled_frames = np.linspace(0, total_frame_num - 1, sample_fps, dtype=int)
frame_idx = uniform_sampled_frames.tolist()
frame_time = [i/vr.get_avg_fps() for i in frame_idx]
spare_frames = vr.get_batch(frame_idx).asnumpy()
return spare_frames,frame_time,video_time
pretrained = "MLAdaptiveIntelligence/LLaVAction-7B"
model_name = "llava_qwen"
device = "cuda"
device_map = "auto"
tokenizer, model, image_processor, max_length = load_pretrained_model(pretrained, None, model_name, torch_dtype="bfloat16", device_map=device_map)
model.eval()
max_frames_num = 64
video,frame_time,video_time = load_video(video_path, max_frames_num, 1, force_sample=True)
video = image_processor.preprocess(video, return_tensors="pt")["pixel_values"].cuda().to(torch.bfloat16)
video = [video]
conv_template = "qwen_1_5"
time_instruction = f"视频总时长{video_time:.2f}秒,从中均匀采样{len(video[0])}帧。"
question = DEFAULT_IMAGE_TOKEN + f"\n{time_instruction}\n{perspective_prompt} {task_prompt}"
conv = copy.deepcopy(conv_templates[conv_template])
conv.append_message(conv.roles[0], question)
conv.append_message(conv.roles[1], None)
prompt_question = conv.get_prompt()
input_ids = tokenizer_image_token(prompt_question, tokenizer, IMAGE_TOKEN_INDEX, return_tensors="pt").unsqueeze(0).to(device)
cont = model.generate(
input_ids,
images=video,
modalities= ["video"],
do_sample=False,
temperature=0,
max_new_tokens=4096,
)
text_outputs = tokenizer.batch_decode(cont, skip_special_tokens=True)[0].strip()
print(text_outputs)
训练细节
详见叶等人2025年论文:arxiv.org/abs/2503.18712
模型架构
- 基础架构: SO400M + Qwen2
- 初始化模型: lmms-lab/LLaVA-Video-7B-Qwen2
- 训练数据: LLaVA-178K与EPIC-KITCHENS-100-MQA混合数据集,2个epoch,全参数训练
- 计算精度: bfloat16
硬件环境
GPU配置: 32块Nvidia GH-200(完整模型训练)
训练框架: HuggingFace Trainer
神经网络库: PyTorch
引用文献
arXiv: arxiv.org/abs/2503.18712
@article{YeQi2025llavaction,
title={LLaVAction:面向动作识别的多模态大语言模型评估与训练},
author={叶绍凯 and 齐浩哲 and 亚历山大·马西斯 and 麦肯齐·W·马西斯},
journal={arXiv预印本},
year={2025}
}