Skip to content

微调 PaddleOCR-VL 后不能直接进行推理 #5012

@megemini

Description

@megemini

Checklist:

描述问题

使用如下命令安装 paddlecor 相关组件进行推理:

python -m pip install -U "paddleocr[doc-parser]"
python -m pip install https://paddle-whl.bj.bcebos.com/nightly/cu126/safetensors/safetensors-0.6.2.dev0-cp38-abi3-linux_x86_64.whl
python -m pip install --force-reinstall opencv-python-headless
python -m pip install numpy==1.26.4

使用如下命令进行图片推理:

!python -m paddleocr doc_parser -i /home/aistudio/work/data/HUST-OBS/deciphered/0001/G_0001_後2.36.5合33075𠂤歷間.png \
    --vl_rec_model_name "PaddleOCR-VL-1.5-0.9B" \
    --vl_rec_model_dir "PaddleOCR-VL-15-SFT" \
    --save_path="PaddleOCR-VL-15-SFT_response" \
    --use_layout_detection=False \
    --prompt_label="ocr"

提示错误:

Checking connectivity to the model hosters, this may take a while. To bypass this check, set `PADDLE_PDX_DISABLE_MODEL_SOURCE_CHECK` to `True`.
/opt/conda/envs/python35-paddle120-env/lib/python3.10/site-packages/paddle/utils/cpp_extension/extension_utils.py:712: UserWarning: No ccache found. Please be aware that recompiling all source files may be required. You can download and install ccache from: https://github.com/ccache/ccache/blob/master/doc/INSTALL.md
  warnings.warn(warning_message)
Creating model: ('PaddleOCR-VL-1.5-0.9B', 'PaddleOCR-VL-15-SFT')
Traceback (most recent call last):
  File "/opt/conda/envs/python35-paddle120-env/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/opt/conda/envs/python35-paddle120-env/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/aistudio/external-libraries/lib/python3.10/site-packages/paddleocr/__main__.py", line 39, in <module>
    console_entry()
  File "/home/aistudio/external-libraries/lib/python3.10/site-packages/paddleocr/__main__.py", line 26, in console_entry
    main()
  File "/home/aistudio/external-libraries/lib/python3.10/site-packages/paddleocr/_cli.py", line 194, in main
    _execute(args)
  File "/home/aistudio/external-libraries/lib/python3.10/site-packages/paddleocr/_cli.py", line 183, in _execute
    args.executor(args)
  File "/home/aistudio/external-libraries/lib/python3.10/site-packages/paddleocr/_pipelines/paddleocr_vl.py", line 498, in execute_with_args
    perform_simple_inference(
  File "/home/aistudio/external-libraries/lib/python3.10/site-packages/paddleocr/_utils/cli.py", line 62, in perform_simple_inference
    wrapper = wrapper_cls(**init_params)
  File "/home/aistudio/external-libraries/lib/python3.10/site-packages/paddleocr/_pipelines/paddleocr_vl.py", line 86, in __init__
    super().__init__(**kwargs)
  File "/home/aistudio/external-libraries/lib/python3.10/site-packages/paddleocr/_pipelines/base.py", line 67, in __init__
    self.paddlex_pipeline = self._create_paddlex_pipeline()
  File "/home/aistudio/external-libraries/lib/python3.10/site-packages/paddleocr/_pipelines/base.py", line 105, in _create_paddlex_pipeline
    return create_pipeline(config=self._merged_paddlex_config, **kwargs)
  File "/home/aistudio/external-libraries/lib/python3.10/site-packages/paddlex/inference/pipelines/__init__.py", line 168, in create_pipeline
    pipeline = BasePipeline.get(pipeline_name)(
  File "/home/aistudio/external-libraries/lib/python3.10/site-packages/paddlex/utils/deps.py", line 208, in _wrapper
    return old_init_func(self, *args, **kwargs)
  File "/home/aistudio/external-libraries/lib/python3.10/site-packages/paddlex/inference/pipelines/_parallel.py", line 113, in __init__
    self._pipeline = self._create_internal_pipeline(config, self.device)
  File "/home/aistudio/external-libraries/lib/python3.10/site-packages/paddlex/inference/pipelines/_parallel.py", line 168, in _create_internal_pipeline
    return self._pipeline_cls(
  File "/home/aistudio/external-libraries/lib/python3.10/site-packages/paddlex/inference/pipelines/paddleocr_vl/pipeline.py", line 140, in __init__
    self.vl_rec_model = self.create_model(vl_rec_config)
  File "/home/aistudio/external-libraries/lib/python3.10/site-packages/paddlex/inference/pipelines/base.py", line 106, in create_model
    model = create_predictor(
  File "/home/aistudio/external-libraries/lib/python3.10/site-packages/paddlex/inference/models/__init__.py", line 83, in create_predictor
    return BasePredictor.get(model_name)(
  File "/home/aistudio/external-libraries/lib/python3.10/site-packages/paddlex/inference/models/doc_vlm/predictor.py", line 59, in __init__
    raise RuntimeError("Static graph models are not supported")
RuntimeError: Static graph models are not supported

需要手动将微调后的模型 赋值并修改名称 /home/aistudio/PaddleOCR-VL-15-SFT/model-00001-of-00001.safetensors 修改为 /home/aistudio/PaddleOCR-VL-15-SFT/model.safetensors 才能正常推理。

也就是说,如果需要使用微调后的模型,需要再手动复制一遍模型文件。

复现

  1. 您是否已经正常运行我们提供的教程

  2. 您是否在教程的基础上修改代码内容?还请您提供运行的代码

  3. 您使用的数据集是?

  4. 请提供您出现的报错信息及相关log

环境

  1. 请提供您使用的PaddlePaddle和PaddleX的版本号

  2. 请提供您使用的操作系统信息,如Linux/Windows/MacOS

  3. 请问您使用的Python版本是?

  4. 请问您使用的CUDA/cuDNN的版本号是?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions