InternVideo2.5 是一款基于长且丰富的上下文(LRC)建模增强的视频多模态大语言模型(MLLM),构建于 InternVL2.5 之上。
下载量 129
发布时间 : 3/18/2025
模型介绍
内容详情
替代品
模型简介
InternVideo2.5 通过提升感知细粒度细节和捕捉长时态结构的能力,显著改进了现有的 MLLM。通过使用直接偏好优化(TPO)进行密集视觉任务标注,以及通过自适应分层令牌压缩(HiCo)实现紧凑的时空表示来实现这一点。
模型特点
长且丰富的上下文(LRC)建模
通过提升感知细粒度细节和捕捉长时态结构的能力,显著改进现有的 MLLM。
自适应分层令牌压缩(HiCo)
实现紧凑的时空表示,每帧仅使用 16 个令牌。
直接偏好优化(TPO)
通过密集视觉任务标注增强模型性能。
模型能力
视频理解
视频描述生成
多模态对话
长视频分析
使用案例
视频内容分析
视频详细描述
对视频内容进行详细描述,包括场景、动作和对象。
生成详细的视频描述文本
视频问答
回答关于视频内容的特定问题。
准确回答视频相关问题
长视频处理
长视频摘要
对长视频内容进行摘要和关键帧提取。
生成视频摘要和关键帧描述
language:
- en library_name: transformers license: apache-2.0 metrics:
- accuracy tags:
- multimodal pipeline_tag: video-text-to-text model-index:
- name: InternVL2.5_HiCo_R16
results:
- task:
type: multimodal
dataset:
name: MLVU
type: mlvu
metrics:
- type: accuracy value: 71.5 name: accuracy verified: true
- task:
type: multimodal
dataset:
name: MVBench
type: mvbench
metrics:
- type: accuracy value: 74.0 name: accuracy verified: true
- task:
type: multimodal
dataset:
name: Perception Test
type: percepTest
metrics:
- type: accuracy value: 71.4 name: accuracy verified: true
- task:
type: multimodal
dataset:
name: LongVideoBench
type: longvideobench
metrics:
- type: accuracy value: 59.6 name: accuracy verified: true
- task:
type: multimodal
dataset:
name: VideoMME (w/o sub)
type: videomme
metrics:
- type: accuracy value: 64.9 name: accuracy verified: true
- task:
type: multimodal
dataset:
name: MLVU
type: mlvu
metrics:
📕InternVL2.5_HiCo_R16⚡
InternVideo2.5 是一款基于 长且丰富的上下文(LRC)建模 增强的视频多模态大语言模型(MLLM,构建于 InternVL2.5 之上)。它通过提升感知细粒度细节和捕捉长时态结构的能力,显著改进了现有的 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={Wang, Yi and Li, Xinhao and Yan, Ziang and He, Yinan and Yu, Jiashuo and Zeng, Xiangyu and Wang, Chenting and Ma, Changlian and Huang, Haian and Gao, Jianfei and Dou, Min and Chen, Kai and Wang, Wenhai and Qiao, Yu and Wang, Yali and Wang, Limin},
journal={arXiv preprint arXiv:2501.12386},
year={2025}
}
@article{li2024videochatflash,
title={VideoChat-Flash: 长上下文视频建模的分层压缩},
author={Li, Xinhao and Wang, Yi and Yu, Jiashuo and Zeng, Xiangyu and Zhu, Yuhan and Huang, Haian and Gao, Jianfei and Li, Kunchang and He, Yinan and Wang, Chenting and others},
journal={arXiv preprint arXiv:2501.00574},
year={2024}
}
Xclip Base Patch32
MIT
X-CLIP是CLIP的扩展版本,用于通用视频语言理解,通过对比学习在(视频,文本)对上训练,适用于视频分类和视频-文本检索等任务。
文本生成视频
Transformers

英语
X
microsoft
309.80k
84
LTX Video
其他
首个基于DiT的视频生成模型,能够实时生成高质量视频,支持文本转视频和图像+文本转视频两种场景。
文本生成视频
英语
L
Lightricks
165.42k
1,174
Animatediff Lightning
Openrail
极速文本生成视频模型,生成速度比原版AnimateDiff快十倍以上
文本生成视频
A
ByteDance
144.00k
925
V Express
V-Express是一个基于音频和面部关键点条件生成的视频生成模型,能够将音频输入转换为动态视频输出。
文本生成视频
英语
V
tk93
118.36k
85
Cogvideox 5b
其他
CogVideoX是源自清影的视频生成模型的开源版本,提供高质量的视频生成能力。
文本生成视频
英语
C
THUDM
92.32k
611
Llava NeXT Video 7B Hf
LLaVA-NeXT-Video是一个开源多模态聊天机器人,通过视频和图像数据混合训练获得优秀的视频理解能力,在VideoMME基准上达到开源模型SOTA水平。
文本生成视频
Transformers

英语
L
llava-hf
65.95k
88
Wan2.1 T2V 14B Diffusers
Apache-2.0
万2.1是一套全面开放的视频基础模型,旨在突破视频生成的边界,支持中英文文本生成视频、图像生成视频等多种任务。
文本生成视频
支持多种语言
W
Wan-AI
48.65k
24
Wan2.1 T2V 1.3B Diffusers
Apache-2.0
万2.1是一套全面开放的视频基础模型,具备顶尖性能、支持消费级GPU、多任务支持、视觉文本生成和高效视频VAE等特点。
文本生成视频
支持多种语言
W
Wan-AI
45.29k
38
Wan2.1 T2V 14B
Apache-2.0
万2.1是一套综合性开源视频基础模型,具备文本生成视频、图像生成视频、视频编辑、文本生成图像及视频生成音频等多任务能力,支持中英双语文本生成。
文本生成视频
支持多种语言
W
Wan-AI
44.88k
1,238
Wan2.1 T2V 14B Gguf
Apache-2.0
基于GGUF格式转换的文本生成视频模型,支持通过ComfyUI-GGUF自定义节点使用
文本生成视频
W
city96
42.38k
130
精选推荐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应用开发。
简体中文