MCPcopy Index your code
hub / github.com/PKU-YuanGroup/Chat-UniVi

github.com/PKU-YuanGroup/Chat-UniVi @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
343 symbols 1,267 edges 51 files 61 documented · 18%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Chat-UniVi: Unified Visual Representation Empowers Large Language Models with Image and Video Understanding

If you like our project, please give us a star ⭐ on GitHub for the latest update.
[![Demo](https://img.shields.io/badge/⚡-Hugging%20Face%20Demo-yellow.svg)](https://huggingface.co/spaces/Chat-UniVi/Chat-UniVi) [![hf](https://img.shields.io/badge/🤗-Hugging%20Face-blue.svg)](https://huggingface.co/Chat-UniVi) [![arXiv](https://img.shields.io/badge/Arxiv-2311.08046-b31b1b.svg?logo=arXiv)](https://arxiv.org/abs/2311.08046) [![License](https://img.shields.io/badge/Code%20License-Apache2.0-yellow)](https://github.com/PKU-YuanGroup/Chat-UniVi/blob/main/LICENSE) [![Hits](https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2FPKU-YuanGroup%2FChat-UniVi&count_bg=%2379C83D&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=Visitor&edge_flat=false)](https://hits.seeyoufarm.com) [![GitHub issues](https://img.shields.io/github/issues/PKU-YuanGroup/Chat-UniVi?color=critical&label=Issues)](https://github.com/PKU-YuanGroup/Chat-UniVi/issues?q=is%3Aopen+is%3Aissue) [![GitHub closed issues](https://img.shields.io/github/issues-closed/PKU-YuanGroup/Chat-UniVi?color=success&label=Issues)](https://github.com/PKU-YuanGroup/Chat-UniVi/issues?q=is%3Aissue+is%3Aclosed)

PWC

PWC

PWC

PWC

PWC

PWC

PWC

PWC

PWC

PWC

PWC

💡 I also have other LLM projects that may interest you ✨.

MoH: Multi-Head Attention as Mixture-of-Head Attention

Peng Jin, Bo Zhu, Li Yuan, Shuicheng Yan

github github arXiv

MoE++: Accelerating Mixture-of-Experts Methods with Zero-Computation Experts

Peng Jin, Bo Zhu, Li Yuan, Shuicheng Yan

github github arXiv

-->

📣 News

  • [2024/04/05] We've revised the temporal evaluation performance of video understanding, resulting in an actual model performance of 47.9 instead of the previously stated 57.8. We sincerely apologize for any inconvenience our oversight may have caused you.
  • [2024/04/05] Chat-UniVi has been selected as a Highlight paper at CVPR 2024! (Top 3% of 11532 submissions).
  • [2024/02/27] Our Chat-UniVi has been accepted by CVPR 2024!
  • [2024/01/05] We enhance the video loading code by introducing support for variable-length videos. This improvement involves eliminating the previous zero-filling operation on the video. We find that this updated video loading method significantly boosts performance (Results).
  • [2023/12/05] The visualization script is available at VISUALIZATION.md.
  • [2023/11/22] ⚡ The online demo is available at Hugging Face Demo. Welcome to try!
  • [2023/11/22] The processed data is available at DATA.md.
  • [2023/11/21] 💡 We release Chat-UniVi-13B. Our proposed unified visual representation framework greatly reduces the number of visual tokens, so you can train 13B unified image and video understanding models in full parameters directly on 8 A100 GPUs within 3 days. Chat-UniVi-13B has better performance (Results). The training code for Chat-UniVi-13B has been updated (TRAIN_AND_VALIDATE.md).
  • [2023/11/21] We provide inference code for video understanding and image understanding.
  • [2023/11/21] We enhance the video loading code by introducing support for variable-length videos. This improvement involves eliminating the previous zero-filling operation on the video. We find that this updated video loading method significantly boosts performance.
  • [2023/11/15] Code are available now! Welcome to watch 👀 this repository for the latest updates.

😮 Highlights

💡 Unified visual representation for image and video

We employ a set of dynamic visual tokens to uniformly represent images and videos. This representation framework empowers the model to efficiently utilize a limited number of visual tokens to simultaneously capture the spatial details necessary for images and the comprehensive temporal relationship required for videos.

🔥 Joint training strategy, making LLMs understand both image and video

Chat-UniVi is trained on a mixed dataset containing both images and videos, allowing direct application to tasks involving both mediums without requiring any modifications.

🤗 High performance, complementary learning with image and video

Extensive experimental results demonstrate that Chat-UniVi, as a unified model, consistently outperforms even existing methods exclusively designed for either images or videos.

⚡ Demo

Please change the model path on line 15 of the main_demo.py first. Then run the demo:

# For Chat-UniVi-7B
CUDA_VISIBLE_DEVICES=0 uvicorn main_demo_7B:app --host 0.0.0.0 --port 8888

# For Chat-UniVi-13B
CUDA_VISIBLE_DEVICES=0 uvicorn main_demo_13B:app --host 0.0.0.0 --port 8888

A conversation with both image and video

A conversation includes multiple videos

A conversation includes multiple images

A conversation includes the video

A conversation in Chinese

With translation API, our model can also support Chinese conversations. We will add code to support Chinese conversations in future updates.

🚀 Main Results

Image understanding

Following LLaVA, we report the relative scores to GPT-4 for instruction-following questions.

MethodsLLMConversationDetail DescriptionComplex ReasoningAll
Chat-UniVi-7BVicuna-7B84.174.293.784.2
Chat-UniVi-13BVicuna-13B84.179.494.786.1

Video understanding

Following Video-ChatGPT, we report the relative scores between the output of the model and the ground truth, with the assistance of GPT. It is worth noting that the results reported in Video-ChatGPT span a range from 0 to 5. To standardize the metrics, we normalize all scores to a scale of 0 to 100.

MethodsLLMCorrectDetailContextTemporalConsistency
Chat-UniVi-7BVicuna-7B57.858.269.247.956.2
Chat-UniVi-13BVicuna-13B59.459.870.5-60.6

ScienceQA

We report both zero-shot and fine-tuning results on the ScienceQA test set.

MethodsLLMAverageSubjectContext ModalityGrade
NATSOCLANTXTIMGNOG1-6G7-12
Chat-UniVi-7BVicuna-7B88.7888.5093.0385.9188.5185.9788.1588.8888.60
Chat-UniVi-13BVicuna-13B90.9990.4195.0588.9189.6488.0590.9491.1990.64

VideoQA

We follow the evaluation protocol in Video-ChatGPT, i.e., employing GPT-assisted evaluation to assess the capabilities of models.

Core symbols most depended-on inside this repo

print
called by 127
ChatUniVi/model/multimodal_encoder/utils.py
get_model
called by 43
ChatUniVi/model/arch.py
copy
called by 28
ChatUniVi/conversation.py
tokenizer_image_token
called by 27
ChatUniVi/mm_utils.py
append_message
called by 24
ChatUniVi/conversation.py
get_prompt
called by 13
ChatUniVi/demo.py
get_vision_tower
called by 12
ChatUniVi/model/arch.py
preprocess
called by 12
ChatUniVi/model/multimodal_encoder/processor.py

Shape

Method 147
Function 144
Class 52

Languages

Python100%

Modules by API surface

ChatUniVi/model/language_model/language_model/modeling_phi.py55 symbols
ChatUniVi/model/multimodal_encoder/eva_vit.py34 symbols
ChatUniVi/train/train.py32 symbols
ChatUniVi/model/cluster.py17 symbols
ChatUniVi/model/arch.py14 symbols
ChatUniVi/model/multimodal_encoder/utils.py12 symbols
ChatUniVi/model/multimodal_encoder/processor.py11 symbols
ChatUniVi/model/multimodal_encoder/eva_encoder.py11 symbols
ChatUniVi/model/multimodal_encoder/clip_encoder.py11 symbols
ChatUniVi/utils.py9 symbols
ChatUniVi/model/language_model/phi.py9 symbols
ChatUniVi/conversation.py9 symbols

For agents

$ claude mcp add Chat-UniVi \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact