书生-进阶-第四关
目录
一、部署
环境准备
conda create -n lmdeploy python=3.10 -y
conda activate lmdeploy
pip install lmdeploy==0.6.1 gradio==4.44.1 timm==1.0.9
下载源码
git clone https://github.com/Control-derek/InternVL2-Tutorial.git
cd InternVL2-Tutorial
运行
conda activate lmdeploy
python demo.py
效果图
识别错误,图片应该是新疆菜大盘鸡!下面微调解决!
二、微调
环境准备
conda create --name xtuner-env python=3.10 -y
conda activate xtuner-env
pip install xtuner==0.1.23 timm==1.0.9
pip install 'xtuner[deepspeed]'
pip install torch==2.4.1 torchvision==0.19.1 torchaudio==2.4.1 --index-url https://download.pytorch.org/whl/cu121
pip install transformers==4.39.0 peft==0.13.2
复制配置文件
cp /root/InternVL2-Tutorial/xtuner_config/internvl_v2_internlm2_2b_lora_finetune_food.py /root/xtuner/xtuner/configs/internvl/v2/internvl_v2_internlm2_2b_lora_finetune_food.py
微调
xtuner train /root/xtuner/xtuner/configs/internvl/v2/internvl_v2_internlm2_2b_lora_finetune_food.py --deepspeed deepspeed_zero2
转换格式
python xtuner/configs/internvl/v1_5/convert_to_official.py xtuner/configs/internvl/v2/internvl_v2_internlm2_2b_lora_finetune_food.py ./work_dirs/internvl_v2_internlm2_2b_lora_finetune_food/iter_640.pth ./work_dirs/internvl_v2_internlm2_2b_lora_finetune_food/lr35_ep10/
修改模型路径并运行微调后的模型
cd /root/InternVL2-Tutorial
conda activate lmdeploy
python demo.py
效果图
回答正确!