VideoLLaMA2.1 7B 16F Base

提供商DAMO-NLP-SG
分类visual-question-answering
许可证apache-2.0
下载量990
星标0

简介

VideoLLaMA2.1 7B 16F Base 是一款专注于视频理解与问答的开源多模态模型。它通过增强的视觉编码能力,能够更精准地捕捉视频中的时空动态信息,而非简单地将视频视为一组静态图片的堆叠。对于开发者而言,该模型适合用于构建视频内容分析、自动化剪辑标注或智能视频检索等应用。由于其基于 LLaMA 架构,上手难度较低,能够无缝对接现有的 LLM 生态工具链,在保持 7B 参数量轻量化的同时,提供了较强的视频语义理解能力。

核心亮点

  • 深度优化视频时空理解,支持复杂动态场景问答
  • 7B 轻量级参数,兼顾推理速度与部署成本
  • 兼容 LLaMA 生态,方便开发者快速二次开发
  • Apache-2.0 协议,支持商业化灵活部署

使用方法

安装依赖
# 安装 Hugging Face transformers
pip install transformers torch
SDK 使用
# 使用 transformers 加载模型
from transformers import AutoModel, AutoTokenizer

model = AutoModel.from_pretrained("DAMO-NLP-SG/VideoLLaMA2.1-7B-16F-Base")
tokenizer = AutoTokenizer.from_pretrained("DAMO-NLP-SG/VideoLLaMA2.1-7B-16F-Base")

Hugging Face 下载

我们推荐使用命令行或者 Hugging Face Hub SDK 来进行模型的下载。

操作指引:在下载前,请先通过如下命令安装 huggingface_hub:

操作指引
pip install -U huggingface_hub

命令行下载

下载完整模型库

下载完整模型库
huggingface-cli download DAMO-NLP-SG/VideoLLaMA2.1-7B-16F-Base

下载单个文件到指定本地文件夹(以下载 config.json 到当前路径下 ./dir 目录为例)

下载单个文件到指定本地文件夹(以下载 config.json 到当前路径下 ./dir 目录为例)
huggingface-cli download DAMO-NLP-SG/VideoLLaMA2.1-7B-16F-Base config.json --local-dir ./dir

更多命令行下载选项,可参见官方文档

SDK 下载

SDK 下载
# 模型下载
from huggingface_hub import snapshot_download
model_dir = snapshot_download('DAMO-NLP-SG/VideoLLaMA2.1-7B-16F-Base')

Git 下载

请确保 lfs 已经被正确安装

Git 下载
git lfs install
git clone https://huggingface.co/DAMO-NLP-SG/VideoLLaMA2.1-7B-16F-Base

如果您希望跳过 lfs 大文件下载,可以使用如下命令

跳过 LFS
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/DAMO-NLP-SG/VideoLLaMA2.1-7B-16F-Base

模型文件托管在 Hugging Face Hub,使用 HF CLI / SDK / Git 直接下载,不经过本站。

PyTorch / Transformers 使用

安装 Transformers

安装 Transformers
pip install -U transformers torch

模型加载和推理

模型加载和推理
from transformers import AutoModelForCausalLM, AutoTokenizer

model = AutoModelForCausalLM.from_pretrained('DAMO-NLP-SG/VideoLLaMA2.1-7B-16F-Base')
tokenizer = AutoTokenizer.from_pretrained('DAMO-NLP-SG/VideoLLaMA2.1-7B-16F-Base')

模型下载

我们推荐使用命令行或者 ModelScope SDK 来进行模型的下载。

操作指引:在下载前,请先通过如下命令安装 ModelScope:

操作指引
pip install modelscope

命令行下载

下载完整模型库

下载完整模型库
modelscope download --model DAMO-NLP-SG/VideoLLaMA2.1-7B-16F-Base

下载单个文件到指定本地文件夹(以下载 README.md 到当前路径下 dir 目录为例)

下载单个文件到指定本地文件夹(以下载 README.md 到当前路径下 dir 目录为例)
modelscope download --model DAMO-NLP-SG/VideoLLaMA2.1-7B-16F-Base README.md --local_dir ./dir

更多更丰富的命令行下载选项,可参见具体文档

SDK 下载

SDK 下载
# 模型下载
from modelscope import snapshot_download
model_dir = snapshot_download('DAMO-NLP-SG/VideoLLaMA2.1-7B-16F-Base')

Git 下载

请确保 lfs 已经被正确安装

Git 下载
git lfs install
git clone https://www.modelscope.cn/DAMO-NLP-SG/VideoLLaMA2.1-7B-16F-Base.git

如果您希望跳过 lfs 大文件下载,可以使用如下命令

跳过 LFS
GIT_LFS_SKIP_SMUDGE=1 git clone https://www.modelscope.cn/DAMO-NLP-SG/VideoLLaMA2.1-7B-16F-Base.git

ModelScope 模型页直接下载模型文件;无需将模型文件放在本站服务器。

Notebook 快速开发

下载并安装 ModelScope library

下载并安装 ModelScope library
pip install "modelscope[audio,cv,nlp,multi-modal,science]" -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html

模型加载和推理

模型加载和推理
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks

p = pipeline('text-generation', 'DAMO-NLP-SG/VideoLLaMA2.1-7B-16F-Base')

完整文档

来源: HuggingFace

---
license: apache-2.0
datasets:

  • OpenGVLab/VideoChat2-IT

  • Lin-Chen/ShareGPT4V

  • liuhaotian/LLaVA-Instruct-150K

language:
  • en

metrics:
  • accuracy

library_name: transformers
pipeline_tag: visual-question-answering
tags:
  • multimodal large language model

  • large video-language model

---

<p align="center">
<img src="https://cdn-uploads.huggingface.co/production/uploads/63913b120cf6b11c487ca31d/ROs4bHIp4zJ7g7vzgUycu.png" width="150" style="margin-bottom: 0.2;"/>
<p>

<h3 align="center"><a href="https://arxiv.org/abs/2406.07476">VideoLLaMA 2: Advancing Spatial-Temporal Modeling and Audio Understanding in Video-LLMs</a></h3>
<h5 align="center"> If you like our project, please give us a star ⭐ on <a href="https://github.com/DAMO-NLP-SG/VideoLLaMA2">Github</a> for the latest update. </h2>

<p align="center"><video src="https://cdn-uploads.huggingface.co/production/uploads/63913b120cf6b11c487ca31d/Wj7GuqQ0CB9JRoPo6_GoH.webm" width="800"></p>

📰 News

  • [2024.06.17] 👋👋 Update technical report with the latest results and the missing references. If you have works closely related to VideoLLaMA 2 but not mentioned in the paper, feel free to let us know.
  • [2024.06.03] Release training, evaluation, and serving codes of VideoLLaMA 2.

🌎 Model Zoo

| Model Name | Type | Visual Encoder | Language Decoder | # Training Frames | |:-------------------|:--------------:|:----------------|:------------------|:----------------------:| | VideoLLaMA2-7B-Base | Base | clip-vit-large-patch14-336 | Mistral-7B-Instruct-v0.2 | 8 | | VideoLLaMA2-7B | Chat | clip-vit-large-patch14-336 | Mistral-7B-Instruct-v0.2 | 8 | | VideoLLaMA2-7B-16F-Base | Base | clip-vit-large-patch14-336 | Mistral-7B-Instruct-v0.2 | 16 | | VideoLLaMA2-7B-16F | Chat | clip-vit-large-patch14-336 | Mistral-7B-Instruct-v0.2 | 16 | | VideoLLaMA2-8x7B-Base | Base | clip-vit-large-patch14-336 | Mixtral-8x7B-Instruct-v0.1 | 8 | | VideoLLaMA2-8x7B | Chat | clip-vit-large-patch14-336 | Mixtral-8x7B-Instruct-v0.1 | 8 | | VideoLLaMA2-72B-Base | Base | clip-vit-large-patch14-336 | Qwen2-72B-Instruct | 8 | | VideoLLaMA2-72B | Chat | clip-vit-large-patch14-336 | Qwen2-72B-Instruct | 8 | | VideoLLaMA2.1-7B-16F-Base (This Checkpoint) | Base | siglip-so400m-patch14-384 | Qwen2-7B-Instruct | 16 | | VideoLLaMA2.1-7B-16F | Chat | siglip-so400m-patch14-384 | Qwen2-7B-Instruct | 16 |

🚀 Main Results

Multi-Choice Video QA & Video Captioning

<p><img src="https://cdn-uploads.huggingface.co/production/uploads/63913b120cf6b11c487ca31d/Z81Dl2MeVlg8wLbYOyTvI.png" width="800" "/></p>

Open-Ended Video QA

<p><img src="https://cdn-uploads.huggingface.co/production/uploads/63913b120cf6b11c487ca31d/UoAr7SjbPSPe1z23HBsUh.png" width="800" "/></p>

🤖 Inference with VideoLLaMA2

python
import sys
sys.path.append('./')
from videollama2 import model_init, mm_infer
from videollama2.utils import disable_torch_init

def inference():
disable_torch_init()

# Video Inference
modal = 'video'
modal_path = 'assets/cat_and_chicken.mp4'
instruct = 'What animals are in the video, what are they doing, and how does the video feel?'

# Image Inference
modal = 'image'
modal_path = 'assets/sora.png'
instruct = 'What is the woman wearing, what is she doing, and how does the image feel?'

model_path = 'DAMO-NLP-SG/VideoLLaMA2-7B-16F'
model, processor, tokenizer = model_init(model_path)
output = mm_infer(processormodal, instruct, model=model, tokenizer=tokenizer, do_sample=False, modal=modal)

print(output)

if __name__ == "__main__":
inference()

Citation

If you find VideoLLaMA useful for your research and applications, please cite using this BibTeX:

bibtex
@article{damonlpsg2024videollama2,
title={VideoLLaMA 2: Advancing Spatial-Temporal Modeling and Audio Understanding in Video-LLMs},
author={Cheng, Zesen and Leng, Sicong and Zhang, Hang and Xin, Yifei and Li, Xin and Chen, Guanzheng and Zhu, Yongxin and Zhang, Wenqi and Luo, Ziyang and Zhao, Deli and Bing, Lidong},
journal={arXiv preprint arXiv:2406.07476},
year={2024},
url = {https://arxiv.org/abs/2406.07476}
}

@article{damonlpsg2023videollama,
title = {Video-LLaMA: An Instruction-tuned Audio-Visual Language Model for Video Understanding},
author = {Zhang, Hang and Li, Xin and Bing, Lidong},
journal = {arXiv preprint arXiv:2306.02858},
year = {2023},
url = {https://arxiv.org/abs/2306.02858}
}