Vision-CAIR commited on
Commit
ebfc4f8
1 Parent(s): a6e7156

change_readme

Browse files
Files changed (1) hide show
  1. README.md +8 -212
README.md CHANGED
@@ -1,212 +1,8 @@
1
- # MiniGPT4-Video: Advancing Multimodal LLMs for Video Understanding with Interleaved Visual-Textual Tokens
2
- <!-- technical report link -->
3
- <!-- demo link -->
4
- <a href='https://vision-cair.github.io/MiniGPT4-video/'><img src='https://img.shields.io/badge/Project-Page-Green'></a>
5
- <a href='https://arxiv.org/abs/2404.03413'><img src='https://img.shields.io/badge/Paper-PDF-red'></a>
6
- <a href='https://23e140b581cffa9101.gradio.live'><img src='https://img.shields.io/badge/Project-Demo-violet'></a>
7
- <!-- <a href='https://github.com/Vision-CAIR/MiniGPT4-video'><img src='https://img.shields.io/badge/Github-Code-blue'></a> -->
8
- ![demo_1](repo_imgs/sample_1.gif)
9
- ![demo_2](repo_imgs/sample_2.gif)
10
- ![demo_3](repo_imgs/sample_3.gif)
11
- ## Overview
12
- This paper introduces MiniGPT4-Video, a multimodal Large Language Model (LLM) designed specifically for video understanding. The model is capable of processing both temporal visual and textual data, making it adept at understanding the complexities of videos.
13
- Building upon the success of MiniGPT-v2, which excelled in translating visual features into the LLM space for single images and achieved impressive results on various image-text benchmarks, this paper extends the model's capabilities to process a sequence of frames, enabling it to comprehend videos.
14
- MiniGPT4-video does not only consider visual content but also incorporates textual conversations, allowing the model to effectively answer queries involving both visual and text components. The proposed model outperforms existing state-of-the-art methods, registering gains of 4.22%, 1.13%, 20.82%, and 13.1% on the MSVD, MSRVTT, TGIF, and TVQA benchmarks respectively.
15
- During inference, a speech to text model such as Whisper model is utilized to generate subtitles for the video. Then, both the video and the subtitle are input to the MiniGPT4-Video model with the instruction and the model outputs the answer.
16
- ![methodology](repo_imgs/MiniGPT4-video_fig.jpg)
17
-
18
- ## :rocket: Demo
19
- **1. Clone the repository** <br>
20
- ```bash
21
- git clone https://github.com/Vision-CAIR/MiniGPT4-video.git
22
- cd MiniGPT4-video
23
- ```
24
-
25
- **2. Set up the environment** <br>
26
- ```bash
27
- conda env create -f environment.yml
28
- ```
29
- **3. Download the checkpoints**
30
-
31
- | MiniGPT4-Video (Llama2 Chat 7B) | MiniGPT4-Video (Mistral 7B) |
32
- :------------------------------------------------------------------------------------------------:|:----------------------------------------------------------------------------------------------:
33
- | [Download](https://huggingface.co/Vision-CAIR/MiniGPT4-Video/blob/main/checkpoints/video_llama_checkpoint_last.pth) | [Download](https://huggingface.co/Vision-CAIR/MiniGPT4-Video/blob/main/checkpoints/video_mistral_checkpoint_last.pth) |
34
-
35
- **4. Run the demo** <br>
36
-
37
- ```bash
38
- # Llama2
39
- python minigpt4_video_demo.py --ckpt path_to_video_checkpoint --cfg-path test_configs/llama2_test_config.yaml
40
- # Mistral
41
- python minigpt4_video_demo.py --ckpt path_to_video_checkpoint --cfg-path test_configs/mistral_test_config.yaml
42
- ```
43
- ### Inference
44
- Do the previous steps and replace step 4 with this step
45
-
46
- ```bash
47
- # Llama2
48
- python minigpt4_video_inference.py --ckpt path_to_video_checkpoint --cfg-path test_configs/llama2_test_config.yaml --video_path path_to_video --question "Your question here"
49
- # Mistral
50
- python minigpt4_video_inference.py --ckpt path_to_video_checkpoint --cfg-path test_configs/mistral_test_config.yaml --video_path path_to_video --question "Your question here"
51
- ```
52
- ## :fire: Training
53
- ### To customize MiniGPT4-Video for your own Video-text dataset
54
- <!-- point to file here Custom_training.md -->
55
- You can find the steps to customize MiniGPT4-Video for your own video-text dataset in [Custom_training.md](Custom_training.md)
56
- ### Training datasets
57
- After downloading the datasets below, **you should go to the datasets configuration folder here minigpt4/configs/datasets set the paths for each dataset there.**<br>
58
- Image text training<br>
59
- You can find the steps to download the datasets in [MiniGPT4](https://github.com/Vision-CAIR/MiniGPT-4/tree/main/dataset)<br>
60
- + LAION <br>
61
- + Conceptual Captions <br>
62
- + SBU <br>
63
-
64
- Video text training:<br>
65
-
66
- + [CMD](https://www.robots.ox.ac.uk/~vgg/data/condensed-movies/) <br>
67
- + [Webvid](https://github.com/m-bain/webvid/) <br> <!-- + [Webvid](https://huggingface.co/datasets/TempoFunk/webvid-10M?row=2) <br> -->
68
- + [Video Instructional Dataset 100K](https://huggingface.co/datasets/MBZUAI/VideoInstruct-100K) <br>
69
-
70
- You can find the datasets annotation files for video_text datasets here [download](https://huggingface.co/Vision-CAIR/MiniGPT4-Video/tree/main/datasets/training_datasets) <br>
71
-
72
-
73
- ### Model training:
74
- You can edit the number of gpus in the each script.sh below<br>
75
- #### Stage 1 (image text pretraining)
76
-
77
- You can directly download the pretrained MiniGPT4 [checkpoint](https://drive.google.com/file/d/11nAPjEok8eAGGEG1N2vXo3kBLCg0WgUk/view?usp=sharing) aligned with Llama2. <br>
78
-
79
- Or train by yourself:
80
-
81
- ```bash
82
- # pretrain
83
- # Llama2
84
- torchrun --nproc-per-node NUM_GPU train.py --cfg-path train_configs/224_minigpt4_llama2_image.yaml
85
- # Mistral
86
- torchrun --nproc-per-node NUM_GPU train.py --cfg-path train_configs/224_minigpt4_mistral_image.yaml
87
-
88
- # align
89
- # To launch the second stage alignment, first specify the path to the checkpoint file trained in pretrain stage.
90
- # Llama2
91
- torchrun --nproc-per-node NUM_GPU train.py --cfg-path train_configs/224_minigpt4_llama2_image_align.yaml
92
- # Mistral
93
- torchrun --nproc-per-node NUM_GPU train.py --cfg-path train_configs/224_minigpt4_mistral_image_align.yaml
94
- ```
95
- You can download our trained weights for this stage from here [Llama2](https://huggingface.co/Vision-CAIR/MiniGPT4-Video/blob/main/checkpoints/image_llama2_checkpoint.pth) [Mistral](https://huggingface.co/Vision-CAIR/MiniGPT4-Video/blob/main/checkpoints/image_mistral_checkpoint.pth)<br>
96
- #### Stage 2 (video captioning pretraining)
97
-
98
- For **Llama2** <br>
99
- set the cfg-path in the script to `train_configs/224_v2_llama2_video_stage_2.yaml` <br>
100
- set the model name here `minigpt4/configs/datasets/cmd_video/default.yaml` and `minigpt4/configs/datasets/webvid/default.yaml` to llama2<br>
101
- For **Mistral**<br>
102
- set the cfg-path in the script to `train_configs/224_v2_mistral_video_stage_2.yaml` <br>
103
- set the model name here `minigpt4/configs/datasets/cmd_video/default.yaml` and `minigpt4/configs/datasets/webvid/default.yaml` to mistral<br>
104
-
105
- ```bash
106
- bash jobs_video/train/stage_2.sh
107
- ```
108
- You can download our trained weights for this stage from here [Llama2](https://huggingface.co/Vision-CAIR/MiniGPT4-Video/blob/main/checkpoints/video_captioning_llama_checkpoint_last.pth) [Mistral](https://huggingface.co/Vision-CAIR/MiniGPT4-Video/blob/main/checkpoints/video_captioning_mistral_checkpoint_last.pth)<br>
109
-
110
- #### Stage 3 (video Instruction finetuning)
111
-
112
- For **Llama2** <br>
113
- set the cfg-path in the script to `train_configs/224_v2_llama2_video_stage_3.yaml` <br>
114
- set the model name here `minigpt4/configs/datasets/video_chatgpt/default.yaml` to llama2<br>
115
-
116
- For **Mistral**<br>
117
- set the cfg-path in the script to `train_configs/224_v2_mistral_video_stage_3.yaml` <br>
118
- set the model name here `minigpt4/configs/datasets/video_chatgpt/default.yaml` to mistral<br>
119
-
120
- ```bash
121
- bash jobs_video/train/stage_3.sh
122
- ```
123
- You can download our trained weights for this stage from here [Llama2](https://huggingface.co/Vision-CAIR/MiniGPT4-Video/blob/main/checkpoints/video_llama_checkpoint_last.pth) [Mistral](https://huggingface.co/Vision-CAIR/MiniGPT4-Video/blob/main/checkpoints/video_mistral_checkpoint_last.pth)<br>
124
-
125
- ## :zap: Evaluation
126
- To reproduce the results use the best checkpoints for each model <br>
127
- [Llama2](https://huggingface.co/Vision-CAIR/MiniGPT4-Video/blob/main/checkpoints/video_captioning_llama_checkpoint_best.pth) [Mistral](https://huggingface.co/Vision-CAIR/MiniGPT4-Video/blob/main/checkpoints/video_captioning_mistral_checkpoint_best.pth)<br>
128
- We used the same evaluation as [Video-ChatGPT](https://mbzuai-oryx.github.io/Video-ChatGPT/)<br>
129
- <!-- ![short_results](repo_imgs/short_results.PNG) -->
130
-
131
- |Method| Using Subtitles | Information Correctness | Detailed Orientation | Contextual Understanding | Temporal Understanding | Consistency |
132
- |:--------------------:|:----:|:------------------------:|:---------------------:|:-------------------------:|:-----------------------:|:------------:|
133
- | LLaMA Adapter | :x:| 2.03 | 2.32| 2.30| 1.98| 2.15 |
134
- | Video LLaMA| :x:| 1.96 | 2.18| 2.16| 1.82| 1.79 |
135
- | Video Chat| :x:| 2.23 | 2.50| 2.53| 1.94| 2.24 |
136
- | Video-ChatGPT | :x:| 2.40 | 2.52| 2.62| 1.98| 2.37 |
137
- | BT-Adapter-7B | :x:| 2.68 | 2.69| 3.27| 2.34| 2.46 |
138
- | LLaMA-VID-7B| :x:| 2.96 | 3.00| 3.53| 2.46| 2.51 |
139
- | **Ours-7B Llama2**| :x:| 2.93 | 2.97| 3.45| **2.47**| **2.60**|
140
- | **Ours-7B Llama2**| :white_check_mark:| **3.08** | **3.02**| **3.57**| **2.65**| **2.67**|
141
- | **Ours-7B Mistral** | :x:| 2.83|2.52 |3.01 |2.32 |2.40 |
142
- | **Ours-7B Mistral**| :white_check_mark:| 2.91 | 2.57| 3.11|2.33 | 2.39|
143
-
144
-
145
-
146
- |Method| Using Subtitles | MSVD Acc.↑ | MSVD Score↑ | MSRVTT Acc.↑ | MSRVTT Score↑ | TGIF Acc.↑ | TGIF Score↑ | ActivityNet Acc.↑ | ActivityNet Score↑ | TVQA Acc.↑ |
147
- |:---------------------------------------:|:----------------:|:-----------:|:------------:|:--------------:|:---------------:|:-----------:|:------------:|:-------------------:|:--------------------:|:------------:|
148
- | FrozenBiLM|:x:|32.2| --|16.8 |--| 41 |-- |24.7|--|29.7 |
149
- | LLaMA Adapter|:x:|54.9| 3.1 |43.8 |2.7| -- |-- |34.2| 2.7| --|
150
- | Video LLaMA|:x:|51.6| 2.5 |29|1.8| -- |-- |12.4| 1.1| --|
151
- | Video Chat|:x:|56.3| 2.8 |45|2.5|34.4| 2.3 |26.5| 2.2|--|
152
- | Video-ChatGPT|:x:|64.9| 3.3 |49.3 |2.8|51.4| 3.0 |35.2| 2.7|23.35|
153
- | BT-Adapter-7B|:x:|67.7| 3.7 |57|3.2| -- |-- |45.7| 3.2| --|
154
- | LLaMA-VID-7B |:x:|69.7| 3.7 |57.7 |3.2| -- |-- |**47.4**| **3.3**| --|
155
- | **Ours-7B LLama2**|:x:|72.93|3.84|58.83|3.29|67.9|3.71| 45.85 |3.23|36.45|
156
- | **Ours-7B Llama2**|:white_check_mark:|72.93|3.84|**59.73**|**3.3** |67.9|3.71| 46.3|3.4 |46.94|
157
- | **Ours-7B Mistral**|:x:|**73.92**|**4.06**|58.26|3.52|**72.22**|**4.08**|44.25 |3.35|33.90|
158
- | **Ours-7B Mistral**|:white_check_mark:|**73.92**|**4.06**|58.68|3.53 |**72.22**|**4.08**| 44.38|3.36 |**54.21** |
159
-
160
- ### Download datasets for evaluation
161
- + [MSVD](https://www.cs.utexas.edu/users/ml/clamp/videoDescription/) <br>
162
- + [MSRVTT](https://cove.thecvf.com/datasets/839) <br>
163
- + [TGIF](https://github.com/YunseokJANG/tgif-qa/blob/master/dataset/README.md) <br>
164
- + [ActivityNet](https://mbzuaiac-my.sharepoint.com/:u:/g/personal/hanoona_bangalath_mbzuai_ac_ae/ESa302OCJMNHsMk7wuBbQc8BZH5CqlcdCWiSpXynQZDfAQ?e=CrOPbm) <br>
165
- + [TVQA](https://tvqa.cs.unc.edu/) <br>
166
- + [Video-ChatGPT benchmark](https://mbzuai-oryx.github.io/Video-ChatGPT/) <br>
167
-
168
- You can find the evaluation datasets annotation files [download](https://huggingface.co/Vision-CAIR/MiniGPT4-Video/tree/main/datasets/evaluation_datasets) <br>
169
-
170
- ### Run evaluation script
171
- Set the each evaluation script parameters to include the path to the checkpoints, the dataset name and whether to use subtitles or not <br>
172
-
173
- ```bash
174
- # Llama2
175
- bash jobs_video/eval/llama2_evaluation.sh
176
- # Mistral
177
- bash jobs_video/eval/mistral_evalualtion.sh
178
- ```
179
- Then Use GPT3.5 turbo to compare the predictions with the ground truth and generate the accuracy and scores <br>
180
- Set these variables in both evaluate_benchmark.sh and evaluate_zeroshot.sh <br>
181
- ```bash
182
- PRED="path_to_predictions"
183
- OUTPUT_DIR="path_to_output_dir"
184
- API_KEY="openAI_key"
185
- NUM_TASKS=128
186
- ```
187
- Then to evaluate [Video-ChatGPT benchmark] run the following script <br>
188
- ```bash
189
- bash test_benchmark/quantitative_evaluation/evaluate_benchmark.sh
190
- ```
191
- To evaluate open ended questions run the following script <br>
192
- ```bash
193
- bash test_benchmark/quantitative_evaluation/evaluate_zeroshot.sh
194
- ```
195
-
196
- If you're using MiniGPT4-Video in your research or applications, please cite using this BibTeX:
197
- ```
198
- @article{ataallah2024minigpt4,
199
- title={MiniGPT4-Video: Advancing Multimodal LLMs for Video Understanding with Interleaved Visual-Textual Tokens},
200
- author={Ataallah, Kirolos and Shen, Xiaoqian and Abdelrahman, Eslam and Sleiman, Essam and Zhu, Deyao and Ding, Jian and Elhoseiny, Mohamed},
201
- journal={arXiv preprint arXiv:2404.03413},
202
- year={2024}
203
- }
204
- ```
205
-
206
- ## Acknowledgements
207
- [MiniGPT4](https://github.com/Vision-CAIR/MiniGPT-4) <br>
208
- [Video-ChatGPT](https://mbzuai-oryx.github.io/Video-ChatGPT)
209
-
210
- ## License
211
- This repository is under [BSD 3-Clause License](LICENSE.md).
212
- Many codes are based on [MiniGPT4](https://github.com/Vision-CAIR/MiniGPT-4).
 
1
+ title: MiniGPT4 Video Zero
2
+ emoji: 🎞️🍿
3
+ colorFrom: green
4
+ colorTo: yellow
5
+ sdk: gradio
6
+ sdk_version: 4.27.0
7
+ app_file: minigpt4_video_demo.py
8
+ pinned: false