/ Модель

Характеристики

Лицензия
MIT
Опубликована
1 авг 2024

InternVideo2-Chat-8B

Компьютерное зрениеВидео, текст → текст3 профессии

Видеоязыковая модель OpenGVLab на базе InternVideo2 и Mistral-7B для диалога и ответов на вопросы по содержанию видео.

37скачиваний за 30 дней26лайковвеса обновлены10 окт 2024

Бенчмарки

Как модель справилась с задачами пользователей ailist и что о ней публикуют открытые лидерборды

Публичные оценки

Из открытых лидербордов. Сравнивайте результаты одного теста при одинаковых условиях — отсутствие оценки не значит, что модель хуже.

В подключённых источниках результатов для этой модели пока нет.

Что умеет модель

Описание составлено по карточке модели и метаданным Hugging Face

InternVideo2-Chat-8B — видеоязыковая модель, разработанная командой OpenGVLab. Она объединяет видеокодировщик InternVideo2, обученный video BLIP и языковую модель Mistral-7B; видеокодировщик обновлялся в ходе обучения по прогрессивной схеме VideoChat. Модель принимает видео и текстовые запросы и предназначена для диалога о содержании видеороликов и ответов на вопросы по ним.

В README приведены результаты на MVBench и VideoMME: 60,3 и 41,9 соответственно для версии 8B; для вариантов HD и HD-F16 указаны отдельные, более высокие результаты. Модель сохранена в формате safetensors, лицензия репозитория — MIT. Для использования также требуется получить доступ к базовой Mistral-7B; условия этого доступа применяются отдельно. Карточка не описывает языковой охват шире английского тега метаданных и не приводит длину контекста.

Сценарии применения

  • ответы на вопросы о содержании видеоролика
  • краткий разбор событий в видео по запросу
  • диалоговое описание видеосюжета
  • оценка понимания видео на бенчмарках MVBench и VideoMME

Ограничения

Для использования необходимо отдельно получить разрешение на доступ к базовой Mistral-7B. Метаданные указывают английский язык; поддержка других языков не подтверждена.

Для каких профессий подходит3

Разделы каталога профессий, в задачах которых используется эта модель

Все профессии

Карточка модели

README от автора на Hugging Face, как он его опубликовал

Открыть на Hugging Face

InternVideo2-Chat-8B

[📂 GitHub] [📜 Tech Report] [🗨️ Chat Demo]

To further enrich the semantics embedded in InternVideo2 and improve its user-friendly in human communications, we tune InternVideo2 by incorporating it into a VideoLLM with a LLM and a video BLIP. We employ the progressive learning scheme in VideoChat by using InternVideo2 as the video encoder and train a video blip for communicating with open-sourced LLM. In training, the video encoder will be updated. Detailed training recipts are in VideoChat.

The BaseLLM of this model is Mistral-7B.Before using it, please ensure that you have obtained the access permission of Mistral-7B, if not yet obtained, please go toMistral-7B to obtain the access permission and add your HF_token to the environment variable.

📈 Performance

ModelMVBenchVideoMME(w/o sub)
InternVideo2-Chat-8B60.341.9
InternVideo2-Chat-8B-HD65.446.1
InternVideo2-Chat-8B-HD-F1667.549.4
InternVideo2-Chat-8B-InternLM61.949.1

🚀 How to use the model

  1. Apply for the permission of this project and the base LLM permission

  2. Fill the HF user access token into the environment variable

export HF_TOKEN=hf_....

If you don't know how to obtain the token starting with "hf_", please refer to: How to Get HF User access Token

  1. make sure to have transformers >= 4.39.0, peft==0.5.0
pip install transformers==4.39.1
pip install peft==0.5.0
pip install timm easydict einops

Install the requisite Python packages from pip_requirements

  1. Inference with Video input
import os
token = os.environ['HF_TOKEN']
import torch

tokenizer =  AutoTokenizer.from_pretrained('OpenGVLab/InternVideo2-Chat-8B', trust_remote_code=True, use_fast=False)

from transformers import AutoTokenizer, AutoModel
model = AutoModel.from_pretrained(
    'OpenGVLab/InternVideo2-Chat-8B',
    torch_dtype=torch.bfloat16,
    trust_remote_code=True).cuda()

from decord import VideoReader, cpu
from PIL import Image
import numpy as np
import numpy as np
import decord
from decord import VideoReader, cpu
import torch.nn.functional as F
import torchvision.transforms as T
from torchvision.transforms import PILToTensor
from torchvision import transforms
from torchvision.transforms.functional import InterpolationMode
decord.bridge.set_bridge("torch")

def get_index(num_frames, num_segments):
    seg_size = float(num_frames - 1) / num_segments
    start = int(seg_size / 2)
    offsets = np.array([
        start + int(np.round(seg_size * idx)) for idx in range(num_segments)
    ])
    return offsets


def load_video(video_path, num_segments=8, return_msg=False, resolution=224, hd_num=4, padding=False):
    vr = VideoReader(video_path, ctx=cpu(0), num_threads=1)
    num_frames = len(vr)
    frame_indices = get_index(num_frames, num_segments)

    mean = (0.485, 0.456, 0.406)
    std = (0.229, 0.224, 0.225)

    transform = transforms.Compose([
        transforms.Lambda(lambda x: x.float().div(255.0)),
        transforms.Resize(224, interpolation=transforms.InterpolationMode.BICUBIC),
        transforms.CenterCrop(224),
        transforms.Normalize(mean, std)
    ])

    frames = vr.get_batch(frame_indices)
    frames = frames.permute(0, 3, 1, 2)
    frames = transform(frames)

    T_, C, H, W = frames.shape
        
    if return_msg:
        fps = float(vr.get_avg_fps())
        sec = ", ".join([str(round(f / fps, 1)) for f in frame_indices])
        # " " should be added in the start and end
        msg = f"The video contains {len(frame_indices)} frames sampled at {sec} seconds."
        return frames, msg
    else:
        return frames

video_path = "yoga.mp4"
# sample uniformly 8 frames from the video
video_tensor = load_video(video_path, num_segments=8, return_msg=False)
video_tensor = video_tensor.to(model.device)

chat_history= []
response, chat_history = model.chat(tokenizer, '', 'describe the action step by step.', media_type='video', media_tensor=video_tensor, chat_history= chat_history, return_history=True,generation_config={'do_sample':False})
print(response)
# The video shows a woman performing yoga on a rooftop with a beautiful view of the mountains in the background. She starts by standing on her hands and knees, then moves into a downward dog position, and finally ends with a standing position. Throughout the video, she maintains a steady and fluid movement, focusing on her breath and alignment. The video is a great example of how yoga can be practiced in different environments and how it can be a great way to connect with nature and find inner peace.

response, chat_history = model.chat(tokenizer, '', 'What is she wearing?', media_type='video', media_tensor=video_tensor, chat_history= chat_history, return_history=True,generation_config={'do_sample':False})
# The woman in the video is wearing a black tank top and grey yoga pants.
print(response)

✏️ Citation

If this work is helpful for your research, please consider citing InternVideo and VideoChat.

@article{wang2024internvideo2,
  title={Internvideo2: Scaling video foundation models for multimodal video understanding},
  author={Wang, Yi and Li, Kunchang and Li, Xinhao and Yu, Jiashuo and He, Yinan and Wang, Chenting and Chen, Guo and Pei, Baoqi and Zheng, Rongkun and Xu, Jilan and Wang, Zun and others},
  journal={arXiv preprint arXiv:2403.15377},
  year={2024}
}

@article{li2023videochat,
  title={Videochat: Chat-centric video understanding},
  author={Li, KunChang and He, Yinan and Wang, Yi and Li, Yizhuo and Wang, Wenhai and Luo, Ping and Wang, Yali and Wang, Limin and Qiao, Yu},
  journal={arXiv preprint arXiv:2305.06355},
  year={2023}
}

Как запустить

На своей GPU в ailist. Цена — по текущим предложениям провайдеров

GPU в ailist

Универсальный рантайм

Нельзя запустить

Доступ к модели ограничен автором; у платформы нет доступа к весам.

Ревизия весов
3155410

0 моделей