赞
踩
下载官方仓库
git clone git@github.com:Vision-CAIR/MiniGPT-4.git
运行下面的命令创建并激活环境
git clone https://github.com/Vision-CAIR/MiniGPT-4.git
cd MiniGPT-4
conda env create -f environment.yml
conda activate minigptv
根据官方的文档,你可以根据自己需要的版本进行下载,本文主要是针对Vicuna V0 7B:https://huggingface.co/Vision-CAIR/vicuna-7b/tree/main
下载后上传至服务器(此时无prerained_minigpt4_7b.pth):
将MiniGPT-4/minigpt4/configs/models/minigpt4_vicuna0.yaml文件中第18行的
llama_model: "please set this value to the path of vicuna model"
修改为(vicuna-7b文件夹的路径要根据你自己的路径进行修改):
llama_model: "{vicuna-7b文件夹的路径}"
如下图所示:
这里需要根据官方说的对应版本下载。我们在这里下载Vicuna 7B对应的版本:https://drive.google.com/file/d/1RY9jV0dyqLX-o38LrumkKRh6Jtaop58R/view
上传prerained_minigpt4_7b.pth至服务器。我在这里上传到了刚刚下载模型的vicuna-7b文件夹下:
将eval_configs/minigpt4_eval.yaml的第8行:
ckpt: 'please set this value to the path of pretrained checkpoint'
修改为:
ckpt: '{prerained_minigpt4_7b.pth的路径}'
如果服务器可以连接huggingface,那么直接进行Step6就好,但是如果服务器无法访问,我们需要提前准备好以下三个模型。
下载网址:https://storage.googleapis.com/sfr-vision-language-research/LAVIS/models/BLIP2/blip2_pretrained_flant5xxl.pth
上传blip2_pretrained_flant5xxl.pth至服务器:
将MiniGPT-4/minigpt4/models/minigpt4.py文件下的:
q_former_model="https://storage.googleapis.com/sfr-vision-language-research/LAVIS/models/BLIP2/blip2_pretrained_flant5xxl.pth"
修改为:
q_former_model="服务器上blip2_pretrained_flant5xxl.pth的路径"
下载网址:https://huggingface.co/bert-base-uncased
上传至服务器:
同样,将MiniGPT-4/minigpt4/models/minigpt4.py文件下的:
encoder_config = BertConfig.from_pretrained("bert-base-uncased")
修改为:
encoder_config = BertConfig.from_pretrained("{服务器中bert-base-uncased的路径}")
下载网址:https://storage.googleapis.com/sfr-vision-language-research/LAVIS/models/BLIP2/eva_vit_g.pth
上传至服务器:
将MiniGPT-4/minigpt4/models/eva_vit.py下的:
url = "https://storage.googleapis.com/sfr-vision-language-research/LAVIS/models/BLIP2/eva_vit_g.pth"
cached_file = download_cached_file(
url, check_hash=False, progress=True
)
state_dict = torch.load(cached_file, map_location="cpu")
修改为:
local_path = "{服务器上eva_vit_g.pth的路径}"
state_dict = torch.load(local_path, map_location="cpu")
运行下面的命令:
python demo.py --cfg-path eval_configs/minigpt4_eval.yaml --gpu-id 0
点击下面的网址:
进入聊天页面,上传图片,输入文本,即可使用minigpt4交互聊天。
至此,minigpt4部署完成。如果还需要更多的配置,可以看官方文档:https://github.com/Vision-CAIR/MiniGPT-4?tab=readme-ov-file
如果在研究或应用中使用 MiniGPT-4/MiniGPT-v2,请使用此 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}
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。