一、准备工作
1.创建conda虚拟环境
conda create -n llava python=3.10
2.git或者ssh,下载LLaVA工程文件
git clone https://github.com/haotian-liu/LLaVA.git
3.pip各种库
cd LLaVA
conda activate llava
pip install --upgrade pip
pip install -e .
pip install -e ".[train]"
pip install flash-attn --no-build-isolation
二、模型推理
1.开三个终端,分别
python -m llava.serve.controller --host 0.0.0.0 --port 10000
python -m llava.serve.gradio_web_server --controller http://localhost:10000 --model-list-mode reload
python -m llava.serve.model_worker --host 0.0.0.0 --controller http://localhost:10000 --port 40000 --worker http://localhost:40000 --model-path {模型的地址}
2.若在服务器上部署,还要ssh一下才能打开webui,先打开终端
ssh -L 8000:localhost:7xxx root@region-3.seetacloud.com -p 5xxxx
其中7xxx为你第二个terminal里的localhost后面的数字:
HTTP Request: HEAD http://localhost:7xxx/ "HTTP/1.1 200 OK" ,
5xxxx为autodl里的ssh登录指令。
3.打开webui
http://localhost:8000
4.可能出错
pip install fastapi==0.112.2
三、批量模型
1.下载llavabench,,放到LLaVA文件夹内
https://github.com/sgl-project/sglang/tree/main/benchmark/llava_bench
2.下载llavabench,,放到LLaVA文件夹内,改里面的路径
cd ~/llava_bench; conda activate llava; bash bench_hf_llava_bench.sh
python -m llava.eval.model_vqa \
--model-path XXX/LLaVA/llava-v1.5-13b \
--question-file XXX/LLaVA/llava-bench-in-the-wild/questions.jsonl \
--image-folder XXX/LLaVA/llava-bench-in-the-wild/images \
--answers-file ./answers_hf.jsonl \
--temperature 0 \
--conv-mode vicuna_v1