InternVideo2.5 是一个基于 InternVL2.5 构建的视频多模态大语言模型(MLLM),通过长且丰富的上下文(LRC)建模进行了增强,能够感知细粒度细节并捕捉长时态结构。
下载量 1,914
发布时间 : 1/23/2025
模型介绍
内容详情
替代品
模型简介
InternVideo2.5 是一个视频多模态大语言模型,通过直接偏好优化(TPO)进行密集视觉任务标注,以及通过自适应分层令牌压缩(HiCo)实现紧凑的时空表示,显著提升了现有 MLLM 的能力。
模型特点
长且丰富的上下文(LRC)建模
通过 LRC 建模增强,能够感知细粒度细节并捕捉长时态结构。
自适应分层令牌压缩(HiCo)
实现紧凑的时空表示,提升模型效率。
直接偏好优化(TPO)
通过密集视觉任务标注优化模型性能。
模型能力
视频理解
多模态推理
长视频分析
细粒度细节感知
使用案例
视频分析
视频内容描述
详细描述视频内容,包括场景、人物和动作。
高准确率的视频内容理解
长视频结构分析
捕捉长视频中的时态结构和关键事件。
59.6 的准确率(LongVideoBench)
多模态任务
多模态推理
结合视频和文本信息进行复杂推理。
74.0 的准确率(MVBench)
语言:
- 英文 库名称: transformers 许可证: apache-2.0 评估指标:
- 准确率 标签:
- 多模态 管道标签: 视频文本到文本 模型索引:
- 名称: InternVL2.5_HiCo_R16
结果:
- 任务:
类型: 多模态
数据集:
名称: MLVU
类型: mlvu
指标:
- 类型: 准确率 值: 71.5 名称: 准确率 已验证: 是
- 任务:
类型: 多模态
数据集:
名称: MVBench
类型: mvbench
指标:
- 类型: 准确率 值: 74.0 名称: 准确率 已验证: 是
- 任务:
类型: 多模态
数据集:
名称: Perception Test
类型: percepTest
指标:
- 类型: 准确率 值: 71.4 名称: 准确率 已验证: 是
- 任务:
类型: 多模态
数据集:
名称: LongVideoBench
类型: longvideobench
指标:
- 类型: 准确率 值: 59.6 名称: 准确率 已验证: 是
- 任务:
类型: 多模态
数据集:
名称: VideoMME (无字幕)
类型: videomme
指标:
- 类型: 准确率 值: 64.9 名称: 准确率 已验证: 是
- 任务:
类型: 多模态
数据集:
名称: MLVU
类型: mlvu
指标:
📕InternVL2.5_HiCo_R16⚡
InternVideo2.5 是一个基于 InternVL2.5 构建的视频多模态大语言模型(MLLM),通过长且丰富的上下文(LRC)建模进行了增强。它显著提升了现有 MLLM 的能力,使其能够感知细粒度细节并捕捉长时态结构。我们通过使用直接偏好优化(TPO)进行密集视觉任务标注,以及通过自适应分层令牌压缩(HiCo)实现紧凑的时空表示来实现这一目标。该模型是 InternVideo2.5 消融实验的一个变体,仅基于 HiCo 技术构建(R16 表示每帧 16 个令牌)。
📈 性能
模型 | MVBench | LongVideoBench | VideoMME(无字幕) |
---|---|---|---|
InternVL2.5_HiCo_R16 | 74.0 | 59.6 | 64.9 |
🚀 如何使用该模型
首先,您需要安装 flash attention2 和一些其他模块。我们提供了一个简单的安装示例:
pip install transformers==4.40.1
pip install av
pip install imageio
pip install decord
pip install opencv-python
pip install flash-attn --no-build-isolation
然后您可以使用我们的模型:
import numpy as np
import torch
import torchvision.transforms as T
from decord import VideoReader, cpu
from PIL import Image
from torchvision.transforms.functional import InterpolationMode
from transformers import AutoModel, AutoTokenizer
# 模型设置
model_path = 'OpenGVLab/InternVL_2_5_HiCo_R16'
tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
model = AutoModel.from_pretrained(model_path, trust_remote_code=True).half().cuda()
IMAGENET_MEAN = (0.485, 0.456, 0.406)
IMAGENET_STD = (0.229, 0.224, 0.225)
def build_transform(input_size):
MEAN, STD = IMAGENET_MEAN, IMAGENET_STD
transform = T.Compose([T.Lambda(lambda img: img.convert("RGB") if img.mode != "RGB" else img), T.Resize((input_size, input_size), interpolation=InterpolationMode.BICUBIC), T.ToTensor(), T.Normalize(mean=MEAN, std=STD)])
return transform
def find_closest_aspect_ratio(aspect_ratio, target_ratios, width, height, image_size):
best_ratio_diff = float("inf")
best_ratio = (1, 1)
area = width * height
for ratio in target_ratios:
target_aspect_ratio = ratio[0] / ratio[1]
ratio_diff = abs(aspect_ratio - target_aspect_ratio)
if ratio_diff < best_ratio_diff:
best_ratio_diff = ratio_diff
best_ratio = ratio
elif ratio_diff == best_ratio_diff:
if area > 0.5 * image_size * image_size * ratio[0] * ratio[1]:
best_ratio = ratio
return best_ratio
def dynamic_preprocess(image, min_num=1, max_num=6, image_size=448, use_thumbnail=False):
orig_width, orig_height = image.size
aspect_ratio = orig_width / orig_height
# 计算现有图像的宽高比
target_ratios = set((i, j) for n in range(min_num, max_num + 1) for i in range(1, n + 1) for j in range(1, n + 1) if i * j <= max_num and i * j >= min_num)
target_ratios = sorted(target_ratios, key=lambda x: x[0] * x[1])
# 找到最接近的目标宽高比
target_aspect_ratio = find_closest_aspect_ratio(aspect_ratio, target_ratios, orig_width, orig_height, image_size)
# 计算目标宽度和高度
target_width = image_size * target_aspect_ratio[0]
target_height = image_size * target_aspect_ratio[1]
blocks = target_aspect_ratio[0] * target_aspect_ratio[1]
# 调整图像大小
resized_img = image.resize((target_width, target_height))
processed_images = []
for i in range(blocks):
box = ((i % (target_width // image_size)) * image_size, (i // (target_width // image_size)) * image_size, ((i % (target_width // image_size)) + 1) * image_size, ((i // (target_width // image_size)) + 1) * image_size)
# 分割图像
split_img = resized_img.crop(box)
processed_images.append(split_img)
assert len(processed_images) == blocks
if use_thumbnail and len(processed_images) != 1:
thumbnail_img = image.resize((image_size, image_size))
processed_images.append(thumbnail_img)
return processed_images
def load_image(image, input_size=448, max_num=6):
transform = build_transform(input_size=input_size)
images = dynamic_preprocess(image, image_size=input_size, use_thumbnail=True, max_num=max_num)
pixel_values = [transform(image) for image in images]
pixel_values = torch.stack(pixel_values)
return pixel_values
def get_index(bound, fps, max_frame, first_idx=0, num_segments=32):
if bound:
start, end = bound[0], bound[1]
else:
start, end = -100000, 100000
start_idx = max(first_idx, round(start * fps))
end_idx = min(round(end * fps), max_frame)
seg_size = float(end_idx - start_idx) / num_segments
frame_indices = np.array([int(start_idx + (seg_size / 2) + np.round(seg_size * idx)) for idx in range(num_segments)])
return frame_indices
def get_num_frames_by_duration(duration):
local_num_frames = 4
num_segments = int(duration // local_num_frames)
if num_segments == 0:
num_frames = local_num_frames
else:
num_frames = local_num_frames * num_segments
num_frames = min(512, num_frames)
num_frames = max(128, num_frames)
return num_frames
def load_video(video_path, bound=None, input_size=448, max_num=1, num_segments=32, get_frame_by_duration = False):
vr = VideoReader(video_path, ctx=cpu(0), num_threads=1)
max_frame = len(vr) - 1
fps = float(vr.get_avg_fps())
pixel_values_list, num_patches_list = [], []
transform = build_transform(input_size=input_size)
if get_frame_by_duration:
duration = max_frame / fps
num_segments = get_num_frames_by_duration(duration)
frame_indices = get_index(bound, fps, max_frame, first_idx=0, num_segments=num_segments)
for frame_index in frame_indices:
img = Image.fromarray(vr[frame_index].asnumpy()).convert("RGB")
img = dynamic_preprocess(img, image_size=input_size, use_thumbnail=True, max_num=max_num)
pixel_values = [transform(tile) for tile in img]
pixel_values = torch.stack(pixel_values)
num_patches_list.append(pixel_values.shape[0])
pixel_values_list.append(pixel_values)
pixel_values = torch.cat(pixel_values_list)
return pixel_values, num_patches_list
# 评估设置
max_num_frames = 512
generation_config = dict(
do_sample=False,
temperature=0.0,
max_new_tokens=1024,
top_p=0.1,
num_beams=1
)
video_path = "your_video.mp4"
num_segments=128
with torch.no_grad():
pixel_values, num_patches_list = load_video(video_path, num_segments=num_segments, max_num=1, get_frame_by_duration=False)
pixel_values = pixel_values.to(torch.bfloat16).to(model.device)
video_prefix = "".join([f"Frame{i+1}: <image>\n" for i in range(len(num_patches_list))])
# 单轮对话
question1 = "详细描述这个视频。"
question = video_prefix + question1
output1, chat_history = model.chat(tokenizer, pixel_values, question, generation_config, num_patches_list=num_patches_list, history=None, return_history=True)
print(output1)
# 多轮对话
question2 = "视频中出现了多少人?"
output2, chat_history = model.chat(tokenizer, pixel_values, question, generation_config, num_patches_list=num_patches_list, history=chat_history, return_history=True)
print(output2)
✏️ 引用
@article{wang2025internvideo,
title={InternVideo2.5: 通过长且丰富的上下文建模赋能视频 MLLM},
author={王毅 and 李鑫豪 and 严子昂 and 何一楠 and 余佳硕 and 曾翔宇 and 王晨婷 and 马常莲 and 黄海安 and 高剑飞 and 窦敏 and 陈凯 and 王温海 and 乔宇 and 王雅丽 and 王立民},
journal={arXiv 预印本 arXiv:2501.12386},
year={2025}
}
@article{li2024videochatflash,
title={VideoChat-Flash: 长上下文视频建模的分层压缩},
author={李鑫豪 and 王毅 and 余佳硕 and 曾翔宇 and 朱宇涵 and 黄海安 and 高剑飞 and 李坤昌 and 何一楠 and 王晨婷 and 其他},
journal={arXiv 预印本 arXiv:2501.00574},
year={2024}
}
Llava Video 7B Qwen2
Apache-2.0
LLaVA-视频模型是基于Qwen2语言模型的7B参数多模态模型,专注于视频理解任务,支持64帧视频输入。
视频生成文本
Transformers

英语
L
lmms-lab
34.28k
91
Llava NeXT Video 7B DPO Hf
LLaVA-NeXT-Video是一个开源多模态聊天机器人,通过视频和图像数据混合训练优化,具备优秀的视频理解能力。
视频生成文本
Transformers

英语
L
llava-hf
12.61k
9
Internvideo2 5 Chat 8B
Apache-2.0
InternVideo2.5是一款基于长且丰富上下文(LRC)建模增强的视频多模态大语言模型,构建于InternVL2.5之上,通过提升感知细粒度细节和捕捉长时序结构的能力,显著改进了现有MLLM模型。
视频生成文本
Transformers

英语
I
OpenGVLab
8,265
60
Cogvlm2 Llama3 Caption
其他
CogVLM2-Caption是一个视频描述生成模型,用于为CogVideoX模型生成训练数据。
视频生成文本
Transformers

英语
C
THUDM
7,493
95
Spacetimegpt
时空GPT是一个能够进行空间和时间推理的视频描述生成模型,能够分析视频帧并生成描述视频事件的句子。
视频生成文本
Transformers

英语
S
Neleac
2,877
33
Video R1 7B
Apache-2.0
Video-R1-7B是基于Qwen2.5-VL-7B-Instruct优化的多模态大语言模型,专注于视频推理任务,能够理解视频内容并回答相关问题。
视频生成文本
Transformers

英语
V
Video-R1
2,129
9
Internvl 2 5 HiCo R16
Apache-2.0
InternVideo2.5 是一个基于 InternVL2.5 构建的视频多模态大语言模型(MLLM),通过长且丰富的上下文(LRC)建模进行了增强,能够感知细粒度细节并捕捉长时态结构。
视频生成文本
Transformers

英语
I
OpenGVLab
1,914
3
Videollm Online 8b V1plus
MIT
VideoLLM-online是一个基于Llama-3-8B-Instruct的多模态大语言模型,专注于在线视频理解和视频-文本生成任务。
视频生成文本
Safetensors
英语
V
chenjoya
1,688
23
Videochat R1 7B
Apache-2.0
VideoChat-R1_7B 是一个基于 Qwen2.5-VL-7B-Instruct 的多模态视频理解模型,能够处理视频和文本输入,生成文本输出。
视频生成文本
Transformers

英语
V
OpenGVLab
1,686
7
Qwen2.5 Vl 7b Cam Motion Preview
其他
基于Qwen2.5-VL-7B-Instruct微调的摄像机运动分析模型,专注于视频中的摄像机运动分类和视频-文本检索任务
视频生成文本
Transformers

Q
chancharikm
1,456
10
精选推荐AI模型
Llama 3 Typhoon V1.5x 8b Instruct
专为泰语设计的80亿参数指令模型,性能媲美GPT-3.5-turbo,优化了应用场景、检索增强生成、受限生成和推理任务
大型语言模型
Transformers

支持多种语言
L
scb10x
3,269
16
Cadet Tiny
Openrail
Cadet-Tiny是一个基于SODA数据集训练的超小型对话模型,专为边缘设备推理设计,体积仅为Cosmo-3B模型的2%左右。
对话系统
Transformers

英语
C
ToddGoldfarb
2,691
6
Roberta Base Chinese Extractive Qa
基于RoBERTa架构的中文抽取式问答模型,适用于从给定文本中提取答案的任务。
问答系统
中文
R
uer
2,694
98
AIbase是一个专注于MCP服务的平台,为AI开发者提供高质量的模型上下文协议服务,助力AI应用开发。
简体中文