MiniCPM-V 官网
MiniCPM-V-2 模型文件下载
安装
- 克隆我们的仓库并跳转到相应目录
git clone https://github.com/OpenBMB/MiniCPM-V.git
cd MiniCPM-V
2. 创建 conda 环境
conda create -n minicpmv2 python=3.10 -y
conda activate minicpmv2
3. 安装依赖
pip install -r requirements.txt -i https://pypi.mirrors.ustc.edu.cn/simple
pip install gradio==3.40.0 -i https://pypi.mirrors.ustc.edu.cn/simple
python web_demo.py
cpolar http 7071
通过以下链接使用我们的网页端推理服务: OmniLMM-12B | MiniCPM-V 2.0.
推理
模型库
模型 | 简介 | 下载链接 |
---|---|---|
MiniCPM-V 2.0 | 最新版本,提供高效而领先的端侧双语多模态理解能力。 | 🤗 |
MiniCPM-V | 第一版 MiniCPM-V | 🤗 |
OmniLMM-12B | 性能最强的版本 | 🤗 |
多轮对话
请参考以下代码使用 MiniCPM-V
和 OmniLMM
进行推理。
from chat import OmniLMMChat, img2base64
chat_model = OmniLMMChat('openbmb/MiniCPM-V-2') # or 'openbmb/OmniLMM-12B'
im_64 = img2base64('./assets/hk_OCR.jpg')
# First round chat
msgs = [{"role": "user", "content": "Where should I go to buy a camera?"}]
inputs = {"image": im_64, "question": json.dumps(msgs)}
answer = chat_model.chat(inputs)
print(answer)
# Second round chat
# pass history context of multi-turn conversation
msgs.append({"role": "assistant", "content": answer})
msgs.append({"role": "user", "content": "Where is this store in the image?"})
inputs = {"image": im_64, "question": json.dumps(msgs)}
answer = chat_model.chat(inputs)
print(answer)
可以得到以下输出:
"You should go to the Canon store for a camera."
"The Canon store is located on the right side of the image."
微调
MiniCPM-V
我们支持使用 SWIFT 框架微调 MiniCPM-V 系列模型。SWIFT 支持近 200 种 LLM 和 MLLM(多模态大模型)的训练、推理、评测和部署。支持 PEFT 提供的轻量训练方案和完整的 Adapters 库支持的最新训练技术如 NEFTune、LoRA+、LLaMA-PRO 等。
参考文档:MiniCPM-V, MiniCPM-V-2
在算力平台AutoDL遇到的报错:
root@autodl-container-cffc47b4c5-4a5f97c0:~/tf-logs# conda activate minicpmv2 CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'. To initialize your shell, run
需要运行 conda init bash
unzip filename.zip
unzip filename.zip -d /path/to/directory
解压文件
ls -lh example.zip
显示文件大小