MiniGPT-4 README

The project's README from github.com/Vision-CAIR/MiniGPT-4. As one markdown file: README.md.

MiniGPT-V

MiniGPT-v2: Large Language Model as a Unified Interface for Vision-Language Multi-task Learning

Jun Chen, Deyao Zhu, Xiaoqian Shen, Xiang Li, Zechun Liu, Pengchuan Zhang, Raghuraman Krishnamoorthi, Vikas Chandra, Yunyang Xiong☨, Mohamed Elhoseiny☨

☨equal last author

YouTube

MiniGPT-4: Enhancing Vision-language Understanding with Advanced Large Language Models

Deyao Zhu*, Jun Chen*, Xiaoqian Shen, Xiang Li, Mohamed Elhoseiny

*equal contribution

Colab YouTube

King Abdullah University of Science and Technology

💡 Get help - Q&A or Discord 💬

**Example Community Efforts Built on Top of MiniGPT-4 **

News

[Oct.31 2023] We release the evaluation code of our MiniGPT-v2.

[Oct.24 2023] We release the finetuning code of our MiniGPT-v2.

[Oct.13 2023] Breaking! We release the first major update with our MiniGPT-v2

[Aug.28 2023] We now provide a llama 2 version of MiniGPT-4

Online Demo

Click the image to chat with MiniGPT-v2 around your images demo

Click the image to chat with MiniGPT-4 around your images demo

MiniGPT-v2 Examples

MiniGPT-v2 demos

MiniGPT-4 Examples

find wild write story
solve problem write Poem

More examples can be found in the project page.

Getting Started

Installation

1. Prepare the code and the environment

Git clone our repository, creating a python environment and activate it via the following command

git clone https://github.com/Vision-CAIR/MiniGPT-4.git
cd MiniGPT-4
conda env create -f environment.yml
conda activate minigptv

2. Prepare the pretrained LLM weights

MiniGPT-v2 is based on Llama2 Chat 7B. For MiniGPT-4, we have both Vicuna V0 and Llama 2 version. Download the corresponding LLM weights from the following huggingface space via clone the repository using git-lfs.

Llama 2 Chat 7B Vicuna V0 13B Vicuna V0 7B
Download Downlad Download

Then, set the variable llama_model in the model config file to the LLM weight path.

3. Prepare the pretrained model checkpoints

Download the pretrained model checkpoints

MiniGPT-v2 (after stage-2) MiniGPT-v2 (after stage-3) MiniGPT-v2 (online developing demo)
Download Download Download

For MiniGPT-v2, set the path to the pretrained checkpoint in the evaluation config file in eval_configs/minigptv2_eval.yaml at Line 8.

MiniGPT-4 (Vicuna 13B) MiniGPT-4 (Vicuna 7B) MiniGPT-4 (LLaMA-2 Chat 7B)
Download Download Download

For MiniGPT-4, set the path to the pretrained checkpoint in the evaluation config file in eval_configs/minigpt4_eval.yaml at Line 8 for Vicuna version or eval_configs/minigpt4_llama2_eval.yaml for LLama2 version.

Launching Demo Locally

For MiniGPT-v2, run

python demo_v2.py --cfg-path eval_configs/minigptv2_eval.yaml  --gpu-id 0

For MiniGPT-4 (Vicuna version), run

python demo.py --cfg-path eval_configs/minigpt4_eval.yaml  --gpu-id 0

For MiniGPT-4 (Llama2 version), run

python demo.py --cfg-path eval_configs/minigpt4_llama2_eval.yaml  --gpu-id 0

To save GPU memory, LLMs loads as 8 bit by default, with a beam search width of 1. This configuration requires about 23G GPU memory for 13B LLM and 11.5G GPU memory for 7B LLM. For more powerful GPUs, you can run the model in 16 bit by setting low_resource to False in the relevant config file:

Thanks @WangRongsheng, you can also run MiniGPT-4 on Colab

Training

For training details of MiniGPT-4, check here.

For finetuning details of MiniGPT-v2, check here

Evaluation

For finetuning details of MiniGPT-v2, check here

Acknowledgement

If you're using MiniGPT-4/MiniGPT-v2 in your research or applications, please cite using this BibTeX:



@article{chen2023minigptv2,
      title={MiniGPT-v2: large language model as a unified interface for vision-language multi-task learning}, 
      author={Chen, Jun and Zhu, Deyao and Shen, Xiaoqian and Li, Xiang and Liu, Zechu and Zhang, Pengchuan and Krishnamoorthi, Raghuraman and Chandra, Vikas and Xiong, Yunyang and Elhoseiny, Mohamed},
      year={2023},
      journal={arXiv preprint arXiv:2310.09478},
}

@article{zhu2023minigpt,
  title={MiniGPT-4: Enhancing Vision-Language Understanding with Advanced Large Language Models},
  author={Zhu, Deyao and Chen, Jun and Shen, Xiaoqian and Li, Xiang and Elhoseiny, Mohamed},
  journal={arXiv preprint arXiv:2304.10592},
  year={2023}
}

License

This repository is under BSD 3-Clause License. Many codes are based on Lavis with BSD 3-Clause License here.

MiniGPT-4 (Vision-CAIR/MiniGPT-4)

Searching Database…

25.6K ·GitHub
这是什么?这是 MiniGPT-4 和 MiniGPT-v2 的开源研究代码。这两个视觉-语言模型都以大语言模型作为接口,用于理解图片并就图片进行对话。
这是现成的应用,还是需要我自己配置的研究代码?这是研究代码库,并非打包好的应用:你需要自己克隆仓库、下载单独的大语言模型权重和检查点、编辑配置文件,然后在本地启动演示。
如何在本地跑起演示?克隆仓库并设置 Python 环境,下载基础大语言模型权重(Llama2 Chat 7B 或 Vicuna V0),下载与之匹配的 MiniGPT 预训练检查点,将配置文件指向这些路径,然后运行 MiniGPT-v2 或 MiniGPT-4 的演示脚本。
需要哪些大语言模型权重?需要多少 GPU 显存?MiniGPT-v2 需要 Llama2 Chat 7B;MiniGPT-4 需要 Vicuna V0(7B/13B)或 Llama2 其中之一,通过 git-lfs 从 HuggingFace 下载。默认以 8 位加载时,13B 模型约需 23GB GPU 显存,7B 模型约需 11.5GB。
为什么不能只下载一个模型就直接运行?预训练的大语言模型权重(Vicuna/Llama2)和 MiniGPT 检查点是分开发布的,必须分别下载,并通过配置文件手动连接在一起,演示才能运行。
MiniGPT-4 和 MiniGPT-v2 有什么区别?MiniGPT-v2 是更新的统一视觉-语言接口,基于 Llama2 Chat 7B 构建,用于多任务学习;MiniGPT-4 是较早的模型,运行在 Vicuna 或 Llama2 上,重点在于增强视觉-语言理解。两者均来自同一个 Vision-CAIR 团队。
它基于什么架构构建?MiniGPT-4 的架构沿用 BLIP-2,整个代码库构建在 Lavis 库之上,将视觉编码器与 Vicuna/Llama2 语言模型配对。
不安装任何东西能试用吗?可以,两个模型都有在线演示,点击项目页面即可无需任何设置,直接对自己的图片进行对话。
能否进一步降低 GPU 显存需求?模型默认以 8 位加载(7B 约 11.5GB,13B 约 23GB);如果你有性能更强的 GPU,可以在配置中切换为 16 位加载,以获得更好的效果。
Size
65 MB
Stars
25.6K
Updated
CommitSep 02
Age
3y
Commits · 90 Days