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)

vlm
Searching Database…

25.6K ·GitHub
What is this?This is the open-sourced research code for MiniGPT-4 and MiniGPT-v2, two vision-language models that use a large language model as the interface for understanding and chatting about images.
Is this a ready-made app or research code I have to set up myself?It is a research codebase, not a packaged app: you clone the repo, download separate LLM weights and checkpoints, edit config files, and launch a local demo yourself.
How do I get the demo running locally?Clone the repo and set up a Python environment, download the base LLM weights (Llama2 Chat 7B or Vicuna V0), download the matching pretrained MiniGPT checkpoint, point the config files at those paths, then run the demo script for MiniGPT-v2 or MiniGPT-4.
Which LLM weights do I need and how much GPU memory does it take?MiniGPT-v2 needs Llama2 Chat 7B; MiniGPT-4 needs either Vicuna V0 (7B/13B) or Llama2, downloaded via git-lfs from HuggingFace. Loaded in 8-bit by default, it needs about 23GB GPU memory for the 13B model and 11.5GB for a 7B model.
Why can't I just download one model and run it right away?The pretrained LLM weights (Vicuna/Llama2) and the MiniGPT checkpoints are distributed separately and must be downloaded and wired together manually through config files before the demo works.
What's the difference between MiniGPT-4 and MiniGPT-v2?MiniGPT-v2 is the newer, unified vision-language interface built on Llama2 Chat 7B for multi-task learning, while MiniGPT-4 (the earlier model) runs on Vicuna or Llama2 and focuses on enhanced vision-language understanding; both come from the same Vision-CAIR team.
What architecture does it build on?MiniGPT-4's architecture follows BLIP-2, and the whole codebase is built on top of the Lavis library, pairing a vision encoder with the Vicuna/Llama2 language model.
Can I try it without installing anything?Yes, both models have online demos you can click on the project pages to chat about your own images without any setup.
Can I lower the GPU memory requirement further?Models load in 8-bit by default (about 11.5GB for 7B, 23GB for 13B); if you have a more powerful GPU you can switch to 16-bit loading in the config for better quality.
Size
65 MB
Stars
25.6K
Updated
CommitSep 02
Age
3y
Commits · 90 Days