Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DCU上的通用OCR仅支持图像文字检测,不支持PDF检测 #3726

Open
335079777 opened this issue Mar 26, 2025 · 5 comments
Open

DCU上的通用OCR仅支持图像文字检测,不支持PDF检测 #3726

335079777 opened this issue Mar 26, 2025 · 5 comments
Assignees

Comments

@335079777
Copy link

335079777 commented Mar 26, 2025

描述问题

在DCU上已成功部署通用OCR产线,但是payload中只能是"image": image_data。而官方的通用OCR产线则是payload = {"file": image_data, "fileType": 1},可以选择图像还是pdf,而dcu上的版本只能选择图像.

API_URL = "http://0.0.0.0:8080/ocr" # 服务URL
image_path = "/root/test_2.png"
output_image_path = "/root/out.jpg"
output_txt_path = "/root/result.txt"
with open(image_path, "rb") as file:
image_bytes = file.read()
image_data = base64.b64encode(image_bytes).decode("ascii")

payload = {"image": image_data} # Base64编码的文件内容或者图像URL

@Bobholamovic
Copy link
Member

麻烦贴一下错误信息~

@335079777
Copy link
Author

之前是在release/3.0-beta1版本,不支持。现已更新成release/3.0-rc版本

环境:jupyterlab-pytorch:2.1.0-ubuntu20.04-dtk24.04.1-py3.10-devel

Paddlepaddle版本安装如下:
python -m pip install paddlepaddle-dcu==3.0.0 -i https://www.paddlepaddle.org.cn/packages/stable/dcu/
验证后应该是也可以识别DCU卡
Image

执行下述命令报错(加白后,错误信息一致)
paddlex --serve --pipeline OCR --device gpu:0

报错信息:
Using official model (PP-LCNet_x1_0_doc_ori), the model files will be automatically downloaded and saved in /root/.paddlex/official_models.
/opt/conda/lib/python3.10/site-packages/paddle/utils/cpp_extension/extension_utils.py:711: 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)
Skip checking if model is supported on device because the flag PADDLE_PDX_DISABLE_DEV_MODEL_WL has been set.
Traceback (most recent call last):
File "/opt/conda/bin/paddlex", line 33, in
sys.exit(load_entry_point('paddlex', 'console_scripts', 'paddlex')())
File "/root/PaddleX/paddlex/main.py", line 26, in console_entry
main()
File "/root/PaddleX/paddlex/paddlex_cli.py", line 432, in main
serve(
File "/root/PaddleX/paddlex/paddlex_cli.py", line 324, in serve
pipeline = create_pipeline(config=pipeline_config, device=device, use_hpip=use_hpip)
File "/root/PaddleX/paddlex/inference/pipelines/init.py", line 155, in create_pipeline
pipeline = BasePipeline.get(pipeline_name)(
File "/root/PaddleX/paddlex/inference/pipelines/ocr/pipeline.py", line 64, in init
self.doc_preprocessor_pipeline = self.create_pipeline(
File "/root/PaddleX/paddlex/inference/pipelines/base.py", line 113, in create_pipeline
pipeline = create_pipeline(
File "/root/PaddleX/paddlex/inference/pipelines/init.py", line 155, in create_pipeline
pipeline = BasePipeline.get(pipeline_name)(
File "/root/PaddleX/paddlex/inference/pipelines/doc_preprocessor/pipeline.py", line 57, in init
self.doc_ori_classify_model = self.create_model(doc_ori_classify_config)
File "/root/PaddleX/paddlex/inference/pipelines/base.py", line 86, in create_model
model = create_predictor(
File "/root/PaddleX/paddlex/inference/models/init.py", line 112, in create_predictor
return BasicPredictor.get(model_name)(
File "/root/PaddleX/paddlex/inference/models/image_classification/predictor.py", line 55, in init
self.preprocessors, self.infer, self.postprocessors = self._build()
File "/root/PaddleX/paddlex/inference/models/image_classification/predictor.py", line 88, in _build
infer = StaticInfer(
File "/root/PaddleX/paddlex/inference/models/common/static_infer.py", line 125, in init
self._update_option(option)
File "/root/PaddleX/paddlex/inference/models/common/static_infer.py", line 131, in _update_option
self._reset()
File "/root/PaddleX/paddlex/inference/models/common/static_infer.py", line 148, in _reset
) = self._create()
File "/root/PaddleX/paddlex/inference/models/common/static_infer.py", line 299, in _create
predictor = create_predictor(config)
ValueError: (InvalidArgument) Fail to set gflag: conv_workspace_size_limit, please make sure the gflag exists.
[Hint: Expected success == true, but received success:0 != true:1.] (at /paddle/paddle/fluid/inference/api/analysis_predictor.cc:2287)

启动命令改为下述命令,部署成功
paddlex --serve --pipeline OCR --device dcu:0

但测试发现,实际请求中并没有用DCU卡工作,而是CPU。

@Bobholamovic
Copy link
Member

paddlex --serve --pipeline OCR --device gpu:0这个指令试图使用GPU部署服务,如果不存在GPU设备,理论上应该不会执行成功;由于paddle底层对于DCU和GPU复用了一套处理,所以这里给出的报错信息可能不够清晰。

如果执行paddlex --serve --pipeline OCR --device dcu的话,是否可以呢?

@335079777
Copy link
Author

paddlex --serve --pipeline OCR --device dcu这样是可以部署运行的,但是实际测试中发现,DCU的利用率为0,看起来是用CPU来跑的,没有用DCU呢。

Image

@Bobholamovic
Copy link
Member

这个看上去大概率不是服务化部署的问题,建议试试本地推理(API或者CLI)是否也有类似的现象,如果也存在的话,我会联系更熟悉这块的同事帮忙看看

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants