VideoVista-Train数据集发布:自动生成视频指令微调数据全攻略
你是否还在为视频理解模型缺乏高质量标注数据而烦恼?手动标注视频动作、事件和音频信息耗时费力,且难以大规模扩展?VideoVista-Train数据集生成工具链为你提供一站式解决方案,通过自动化流程将原始视频转换为结构化指令微调数据,让你的多模态模型训练效率提升10倍!本文将详解从视频帧提取到GPT标注的全流程,附带完整工具使用指南和代码示例。
数据集核心价值与技术架构
VideoVista-Train数据集专注于解决视频理解领域三大痛点:标注成本高、模态信息割裂、时间维度标注困难。通过结合计算机视觉与自然语言处理技术,实现视频帧、音频、文本的多模态信息融合,自动生成符合LLaVA格式的指令微调数据。
数据集技术架构包含五大核心模块,形成完整数据处理流水线:
- 视频解析模块:提取帧图像与音频轨道
- 视觉特征提取:目标检测与动作时序分割
- 音频转写模块:语音识别与文本对齐
- GPT智能标注:多模态信息融合生成结构化标注
- 数据合并与格式化:生成最终指令微调数据集
核心处理流程如图所示:
全流程工具链详解
1. 视频帧与音频提取
视频解析是数据生成的第一步,通过moviepy_frames_get.py工具可按秒提取视频关键帧,确保时间维度标注精度。工具核心函数extract_frames支持自定义输出路径和帧率控制:
# 帧提取示例代码
from VideoVista.data_generation.code.tools.frames.moviepy_frames_get import extract_frames
extract_frames(
input_video="raw_videos/sports.mp4",
output_folder="processed_data/frames/sports/"
)
音频提取使用WhisperX模型实现高精度语音转写与时间戳对齐,生成带秒级标注的音频文本:
python VideoVista/data_generation/code/tools/audio/whisperx_get_audio.py \
--input_video "raw_videos/interview.mp4" \
--output_json "processed_data/audio/interview.json"
2. 视觉特征与目标检测
目标检测模块采用SAM(Segment Anything Model)实现高精度物体掩码生成,automatic_label_sam_videos.py工具提供端到端目标标注功能:
# 目标检测核心代码片段
from VideoVista.data_generation.code.tools/boxes/automatic_label_sam_videos import load_model, get_grounding_output
model = load_model(
model_config_path="configs/sam_vit_h.yaml",
model_checkpoint_path="checkpoints/sam_vit_h.pth",
device="cuda"
)
masks, boxes, labels = get_grounding_output(
model, image, caption="person . dog . ball",
box_threshold=0.3, text_threshold=0.25
)
生成的目标标注将保存为JSON格式,包含每个物体的边界框坐标、类别和置信度,为后续动作标注提供视觉基础。
3. GPT智能标注系统
GPT标注模块是数据集生成的核心,通过多模态信息融合实现高精度动作、事件和物体关系标注。以动作标注工具action_annotate.py为例,其核心函数gpt_forward实现以下功能:
# GPT动作标注流程
def gpt_forward(frame_dir_name):
# 1. 加载视频帧与音频文本
# 2. 帧图像base64编码
# 3. 构建GPT-4V提示词
# 4. 调用API生成标注
# 5. 结果保存为JSON
# 关键提示词构造
messages = [
{"role": "system", "content": "You are an AI visual assistant specialized in analyzing videos."},
{"role": "user", "content": [
{"type": "image_url", "image_url": {"url": f"data:image/jpeg;base64,{base64_image}"}},
{"type": "text", "text": f"Video Title: {title_text}\nAudio Transcripts: {audio_text}"}
]}
]
工具支持批量处理模式,通过多线程加速标注过程,典型调用命令如下:
python VideoVista/data_generation/code/tools/gpt/annotate/action_annotate.py \
--frames "processed_data/frames/" \
--audios "processed_data/audio/" \
--save "annotations/actions/" \
--error "logs/annotation_errors.json"
标注结果示例(符合LLaVA对话格式):
{
"video_name": "sports_001",
"conversations": [
{
"from": "human",
"value": "<image> Describe the actions in the video with time segments."
},
{
"from": "gpt",
"value": "[{\"Time\": [0, 3], \"Subject\": \"Woman athletes wearing red clothes\", \"Action\": \"Running on the track\"}, {\"Time\": [3, 5], \"Subject\": \"Spectators in stands\", \"Action\": \"Waving hands and cheering\"}]"
}
]
}
4. 多模态数据合并
数据合并模块将视觉、音频和文本标注统一到时间轴上,merge_videos.py工具提供视频片段拼接与多模态信息对齐功能:
from VideoVista.data_generation/code/tools/merge/merge_videos import concatenate_videos
# 合并多个视频片段
concatenate_videos(
video_paths=["clip1.mp4", "clip2.mp4", "clip3.mp4"],
output_path="merged_video.mp4"
)
最终通过merge_post_process.py工具生成标准JSONL格式数据集,直接用于LLaVA类模型微调:
python VideoVista/data_generation/code/tools/gpt/merge_post_process/post_process_merge.py \
--action_annotations "annotations/actions/" \
--event_annotations "annotations/events/" \
--audio_annotations "processed_data/audio/" \
--output_file "final_dataset.jsonl"
实战案例:从视频到数据集的完整流程
以体育比赛视频为例,展示完整数据生成流程:
- 视频解析:提取每秒1帧图像和音频轨道
python VideoVista/data_generation/code/tools/frames/moviepy_frames_get.py \
--input_video "raw_videos/football_match.mp4" \
--output_folder "dataset/frames/football_001"
python VideoVista/data_generation/code/tools/audio/whisperx_get_audio.py \
--input_video "raw_videos/football_match.mp4" \
--output_json "dataset/audio/football_001.json"
- 目标与动作标注:
# 目标检测
python VideoVista/data_generation/code/tools/boxes/automatic_label_sam_videos.py \
--frame_folder "dataset/frames/football_001" \
--output_json "dataset/objects/football_001.json"
# GPT动作标注
python VideoVista/data_generation/code/tools/gpt/annotate/action_annotate.py \
--frames "dataset/frames/football_001" \
--audios "dataset/audio/football_001.json" \
--save "dataset/actions/football_001.json"
- 数据合并:
python VideoVista/data_generation/code/tools/merge/merge_videos.py \
--video_id "football_001" \
--action_annotations "dataset/actions/football_001.json" \
--object_annotations "dataset/objects/football_001.json" \
--audio_annotations "dataset/audio/football_001.json" \
--output_file "final_dataset.jsonl"
生成的数据集可直接用于LLaVA模型微调,典型训练命令:
python Uni_MoE/Uni_MoE_8e/train/train.py \
--model_name_or_path lmsys/vicuna-7b-v1.5 \
--data_path final_dataset.jsonl \
--output_dir video_llava_7b \
--num_train_epochs 3
工具链扩展与自定义指南
VideoVista工具链支持模块化扩展,你可以通过以下方式定制数据生成流程:
- 新增标注类型:在
VideoVista/data_generation/code/tools/gpt/annotate/目录下添加新的标注工具,如情感分析标注器 - 优化目标检测模型:修改
automatic_label_sam_videos.py中的模型加载函数,集成自定义检测模型 - 自定义数据格式:修改
merge_post_process.py中的格式化函数,生成符合特定模型要求的数据格式
官方提供的配置文件位于VideoVista/data_generation/code/tools/clip/clip_video_splitting.py,可根据需求调整视频分割阈值和特征提取参数。
总结与未来展望
VideoVista-Train数据集生成工具链通过自动化流程解决了视频理解模型的数据瓶颈,其核心优势包括:
- 全流程自动化:从原始视频到标注数据的端到端处理
- 多模态融合:整合视觉、音频和文本信息
- 高精度时间标注:支持秒级动作和事件定位
- 兼容LLaVA格式:可直接用于主流多模态模型训练
随着工具链的不断完善,未来将支持更多标注类型(如情感分析、空间关系推理)和更高分辨率视频处理。欢迎通过项目贡献指南参与工具改进,共同推进视频理解技术的发展。
立即使用VideoVista-Train数据集工具链,让你的视频理解模型训练数据生成效率提升10倍!点赞收藏本文,关注项目更新获取最新功能预告。
创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考




