6.9. GOT-OCR

GOT-OCR-2.0-hf

模型下载

  • url: GOT-OCR-2.0-hf

  • branch: main

  • commit id: d3017ef2c2c1395888c8d635c5e0508bcb0ac78d

  • 将上述url设定的路径下的内容全部下载到GOT-OCR-2.0-hf文件夹中。

requirements

python3 -m pip install opencv-python==4.11.0.86 opencv-python-headless==4.11.0.86

批量离线推理

python3 -m vllm_utils.benchmark_vision_language \
 --backend vllm \
 --demo \
 --model=[path of GOT-OCR-2.0-hf] \
 --prompt=[your prompt] \
 --input-vision-file=[path of your test image] \
 --dtype=bfloat16 \
 --max-output-len=1024 \
 --device=gcu \
 --tensor-parallel-size 1 \
 --max-model-len 2048 \
 --trust-remote-code \
 --block-size=64 \
 --max-num-batched-tokens 2048

注:

  • 默认为graph mode推理,若想使用eager mode,请添加--enforce-eager

性能测试

python3 -m vllm_utils.benchmark_vision_language \
 --backend vllm \
 --perf \
 --model=[path of GOT-OCR-2.0-hf] \
 --num-prompts 1 \
 --batch-size=1 \
 --input-len=1500 \
 --input-vision-shape=1024,1024 \
 --max-output-len=548 \
 --device=gcu \
 --dtype=bfloat16 \
 --tensor-parallel-size 1 \
 --max-model-len 2048 \
 --trust-remote-code \
 --block-size=64 \
 --max-num-batched-tokens 2048

注:

  • 默认为graph mode推理,若想使用eager mode,请添加--enforce-eager