PaddleX
PaddleX copied to clipboard
我能否使用其他语言调用Serving的Http API接口?
我找到一个文档有关此的描述 https://paddlepaddle.github.io/PaddleX/latest/pipeline_usage/tutorials/ocr_pipelines/OCR.html#3 而实际上面的文档是错的 但是在部署文档'https://paddlepaddle.github.io/PaddleX/latest/pipeline_deploy/serving.html#23' 中的服务化部署中明确写明 '各产线使用教程中的 “开发集成/部署” 部分提供了服务的 API 参考与多语言调用示例。在 此处 可以找到各产线的使用教程。' 中找到开发集成/部署¶ 找到OCR部分 在OCR文档中详细写明API 要求一个file字段 base64
但是无论我如何构造请求JSON 总是收到 172.16.1.207:55257 - "POST /ocr HTTP/1.1" 422 Unprocessable Entity INFO: 172.16.1.207:55267 - "POST /ocr HTTP/1.1" 422 Unprocessable Entity INFO: 172.16.1.207:50188 - "POST /ocr HTTP/1.1" 422 Unprocessable Entity INFO: 172.16.1.207:50478 - "POST /ocr HTTP/1.1" 422 Unprocessable Entity INFO: 172.16.1.207:50512 - "POST /ocr HTTP/1.1" 422 Unprocessable Entity 我构造的请求Json {"fileType":1,"file":"iVBORw0KGgoAAAANSUhEUgAACgAAAAWgC...."} 按照文档来说 这两个就可以了 ,我并不知道 我错在了哪里 我完全按照 https://paddlepaddle.github.io/PaddleX/latest/pipeline_deploy/serving.html#1 进行的部署
但是实际上 paddlex --serve --pipeline OCR 启动后endpoint 要求不是file而是image=base64 但是我虽然获得了200的Code result中依旧为空 我可以确定服务正常启动了
这文档是不是太糊弄人了?
那么我很好奇到底那个文档是正确的?
还是说 所谓的'多语言调用'本身就是屁?
就是纯装装样子?
422错误一般是因为输入的内容(请求体)不符合格式要求。建议可以查看返回的body中的errorMsg,其中存储有具体的错误信息~
如果你发现服务要求的是image而不是file,说明可能使用的paddlex代码版本和阅读的文档不匹配,可能需要确保代码和文档是匹配的,比如都使用最新的3.0版本
如果你发现服务要求的是image而不是file,说明可能使用的paddlex代码版本和阅读的文档不匹配,可能需要确保代码和文档是匹配的,比如都使用最新的3.0版本
我确认我是按照文档安装的3.0 额外的 我发现了更神奇的事情 ,同样的安装同样的图片,同样的脚本 同样的cuda cudnn 版本 一个有ocr 结果永远没有识别结果 我并不知道这到底是怎么回事
都是使用 cu126 进行的安装 有识别结果的 占用GPU 4.6GB 没有识别结果的在GPU使用3.6G之后 立即返回空结果 也不报错 同时都使用V5 ser 模型 我想我没必要从头开始学习py没错吧
这是脚本 就是官方脚本换了一下图片路径 from paddleocr import PaddleOCR
ocr = PaddleOCR( use_doc_orientation_classify=False, use_doc_unwarping=False, use_textline_orientation=False) # text detection + text recognition
ocr = PaddleOCR(use_doc_orientation_classify=True, use_doc_unwarping=True) # text image preprocessing + text detection + textline orientation classification + text recognition
ocr = PaddleOCR(use_doc_orientation_classify=False, use_doc_unwarping=False) # text detection + textline orientation classification + text recognition
ocr = PaddleOCR(
text_detection_model_name="PP-OCRv5_mobile_det",
text_recognition_model_name="PP-OCRv5_mobile_rec",
use_doc_orientation_classify=False,
use_doc_unwarping=False,
use_textline_orientation=False) # Switch to PP-OCRv5_mobile models
result = ocr.predict(".\1.png") for res in result: res.print() res.save_to_img("output") res.save_to_json("output") 在有结果的机器上 Creating model: ('PP-OCRv5_server_det', None) Using official model (PP-OCRv5_server_det), the model files will be automatically downloaded and saved in C:\Users\Strikene.paddlex\official_models. INFO: Could not find files for the given pattern(s). C:\paddle\venv\lib\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) Creating model: ('PP-OCRv5_server_rec', None) Using official model (PP-OCRv5_server_rec), the model files will be automatically downloaded and saved in C:\Users\Strikene.paddlex\official_models. {'res': {'input_path': '.\1.png', 'page_index': None, 'model_settings': {'use_doc_preprocessor': True, 'use_textline_orientation': False}, 'doc_preprocessor_res': {'input_path': None, 'page_index': None, 'model_settings': {'use_doc_orientation_classify': False, 'use_doc_unwarping': False}, 'angle': -1}, 'dt_polys': array([[[ 2, 4], ..., [ 2, 23]],
...,
[[ 120, 1341],
...,
[ 119, 1402]]], dtype=int16), 'text_det_params': {'limit_side_len': 64, 'limit_type': 'min', 'thresh': 0.3, 'max_side_limit': 4000, 'box_thresh': 0.6, 'unclip_ratio': 1.5}, 'text_type': 'general', 'textline_orientation_angles': array([-1, ..., -1]), 'text_rec_score_thresh': 0.0, 'rec_texts': ['P:0/', 'dX: 0.0', 'dY: 0.0', 'Xv: 0.0', 'Yv: 0.0', 'Prs: 1.0',..............................................
在没结果的机器上
C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\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) Creating model: ('PP-OCRv5_server_rec', None) Using official model (PP-OCRv5_server_rec), the model files will be automatically downloaded and saved in C:\Users\Administrator.paddlex\official_models. {'res': {'input_path': '.\1.png', 'page_index': None, 'model_settings': {'use_doc_preprocessor': True, 'use_textline_orientation': False}, 'doc_preprocessor_res': {'input_path': None, 'page_index': None, 'model_settings': {'use_doc_orientation_classify': False, 'use_doc_unwarping': False}, 'angle': -1}, 'dt_polys': array([], dtype=float64), 'text_det_params': {'limit_side_len': 64, 'limit_type': 'min', 'thresh': 0.3, 'max_side_limit': 4000, 'box_thresh': 0.6, 'unclip_ratio': 1.5}, 'text_type': 'general', 'text_rec_score_thresh': 0.0, 'rec_texts': [], 'rec_scores': array([], dtype=float64), 'rec_polys': array([], dtype=float64), 'rec_boxes': array([], dtype=float64)}}
我是实在想不明白 这是怎么回事 安装脚本 pip install paddlepaddle-gpu==3.0.0 -i https://www.paddlepaddle.org.cn/packages/stable/cu126/ pip install paddleocr
有结果机器 pip list (venv) c:\paddle>pip list Package Version
aiohappyeyeballs 2.6.1 aiohttp 3.12.12 aiosignal 1.3.2 annotated-types 0.7.0 anyio 4.9.0 astor 0.8.1 async-timeout 4.0.3 attrs 25.3.0 cachetools 6.0.0 certifi 2025.4.26 chardet 5.2.0 charset-normalizer 3.4.2 colorama 0.4.6 colorlog 6.9.0 cssselect 1.3.0 cssutils 2.11.1 dataclasses-json 0.6.7 decorator 5.2.1 distro 1.9.0 einops 0.8.1 et_xmlfile 2.0.0 exceptiongroup 1.3.0 filelock 3.18.0 frozenlist 1.7.0 fsspec 2025.5.1 ftfy 6.3.1 GPUtil 1.4.0 greenlet 3.2.3 h11 0.16.0 httpcore 1.0.9 httpx 0.28.1 huggingface-hub 0.32.5 idna 3.10 imagesize 1.4.1 Jinja2 3.1.6 jiter 0.10.0 joblib 1.5.1 jsonpatch 1.33 jsonpointer 3.0.0 langchain 0.2.17 langchain-community 0.2.17 langchain-core 0.2.43 langchain-openai 0.1.25 langchain-text-splitters 0.2.4 langsmith 0.1.147 lxml 5.4.0 MarkupSafe 3.0.2 marshmallow 3.26.1 more-itertools 10.7.0 multidict 6.4.4 mypy_extensions 1.1.0 networkx 3.4.2 numpy 1.24.4 nvidia-cublas-cu12 12.6.4.1 nvidia-cuda-runtime-cu12 12.6.77 nvidia-cudnn-cu12 9.5.1.17 nvidia-cufft-cu12 11.3.0.4 nvidia-curand-cu12 10.3.7.77 nvidia-cusolver-cu12 11.7.1.2 nvidia-cusparse-cu12 12.5.4.2 nvidia-nvjitlink-cu12 12.8.93 openai 1.63.2 opencv-contrib-python 4.10.0.84 openpyxl 3.1.5 opt-einsum 3.3.0 orjson 3.10.18 packaging 24.2 paddleocr 3.0.1 paddlepaddle-gpu 3.0.0 paddlex 3.0.1 pandas 1.5.3 pillow 11.2.1 pip 22.2.1 premailer 3.10.0 prettytable 3.16.0 propcache 0.3.2 protobuf 6.30.2 py-cpuinfo 9.0.0 pyclipper 1.3.0.post6 pydantic 2.11.5 pydantic_core 2.33.2 pypdfium2 4.30.1 python-dateutil 2.9.0.post0 pytz 2025.2 PyYAML 6.0.2 regex 2024.11.6 requests 2.32.4 requests-toolbelt 1.0.0 ruamel.yaml 0.18.14 ruamel.yaml.clib 0.2.12 scikit-learn 1.7.0 scipy 1.15.3 setuptools 63.2.0 shapely 2.1.1 six 1.17.0 sniffio 1.3.1 SQLAlchemy 2.0.41 tenacity 8.5.0 threadpoolctl 3.6.0 tiktoken 0.9.0 tokenizers 0.19.1 tqdm 4.67.1 typing_extensions 4.14.0 typing-inspect 0.9.0 typing-inspection 0.4.1 ujson 5.10.0 urllib3 2.4.0 wcwidth 0.2.13 yarl 1.20.1
[notice] A new release of pip available: 22.2.1 -> 25.1.1 [notice] To update, run: python.exe -m pip install --upgrade pip 没结果的机器pip list
(venv) F:\paddlex>pip list Package Version
aiofiles 24.1.0 aiohappyeyeballs 2.6.1 aiohttp 3.12.12 aiolimiter 1.2.1 aiosignal 1.3.2 annotated-types 0.7.0 anyio 4.8.0 anytree 2.12.1 astor 0.8.1 asttokens 2.4.1 async-timeout 4.0.3 attrs 25.3.0 autograd 1.7.0 azure-common 1.1.28 azure-core 1.32.0 azure-cosmos 4.9.0 azure-identity 1.19.0 azure-search-documents 11.5.2 azure-storage-blob 12.24.0 backports.tarfile 1.2.0 beartype 0.18.5 build 1.2.2.post1 CacheControl 0.14.2 cachetools 6.0.0 certifi 2024.12.14 cffi 1.17.1 chardet 5.2.0 charset-normalizer 3.4.1 cleo 2.1.0 click 8.1.8 colorama 0.4.6 colorlog 6.9.0 contourpy 1.3.1 crashtest 0.4.1 cryptography 44.0.0 cssselect 1.3.0 cssutils 2.11.1 cycler 0.12.1 dataclasses-json 0.6.7 decorator 5.2.1 deprecation 2.1.0 devtools 0.12.2 distlib 0.3.9 distro 1.9.0 dulwich 0.22.7 einops 0.8.1 environs 11.2.1 et_xmlfile 2.0.0 exceptiongroup 1.2.2 executing 2.1.0 fastjsonschema 2.21.1 filelock 3.16.1 fnllm 0.0.10 fonttools 4.55.3 frozenlist 1.7.0 fsspec 2024.12.0 ftfy 6.3.1 future 1.0.0 gensim 4.3.3 gguf 0.14.0 GPUtil 1.4.0 graphrag 1.1.2 graspologic 3.4.1 graspologic-native 1.2.1 greenlet 3.2.3 h11 0.14.0 httpcore 1.0.7 httpx 0.28.1 huggingface-hub 0.27.1 hyppo 0.4.0 idna 3.10 imagesize 1.4.1 importlib_metadata 8.5.0 installer 0.7.0 isodate 0.7.2 jaraco.classes 3.4.0
jaraco.context 6.0.1 jaraco.functools 4.1.0 Jinja2 3.1.5 jiter 0.8.2 joblib 1.4.2 json_repair 0.30.3 jsonpatch 1.33 jsonpointer 3.0.0 keyring 25.6.0 kiwisolver 1.4.8 lancedb 0.17.0 langchain 0.2.17 langchain-community 0.2.17 langchain-core 0.2.43 langchain-openai 0.1.25 langchain-text-splitters 0.2.4 langsmith 0.1.147 llvmlite 0.43.0 lxml 5.4.0 markdown-it-py 3.0.0 MarkupSafe 3.0.2 marshmallow 3.25.1 matplotlib 3.10.0 mdurl 0.1.2 more-itertools 10.6.0 mpmath 1.3.0 msal 1.31.1 msal-extensions 1.2.0 msgpack 1.1.0 multidict 6.4.4 mypy_extensions 1.1.0 networkx 3.4.2 nltk 3.9.1 numba 0.60.0 numpy 1.24.4 nvidia-cublas-cu12 12.6.4.1 nvidia-cuda-runtime-cu12 12.6.77 nvidia-cudnn-cu12 9.5.1.17 nvidia-cufft-cu12 11.3.0.4 nvidia-curand-cu12 10.3.7.77 nvidia-cusolver-cu12 11.7.1.2 nvidia-cusparse-cu12 12.5.4.2 nvidia-nvjitlink-cu12 12.8.93 openai 1.63.2 opencv-contrib-python 4.10.0.84 opencv-python 4.11.0.86 openpyxl 3.1.5 opt-einsum 3.3.0 orjson 3.10.18 overrides 7.7.0 packaging 24.2 paddleocr 3.0.1 paddlepaddle-gpu 3.0.0 paddlex 3.0.1 pandas 1.5.3 patsy 1.0.1 pillow 11.1.0 pip 22.2.1 pkginfo 1.12.0 platformdirs 4.3.6 poetry 2.0.1 poetry-core 2.0.1 portalocker 2.10.1 POT 0.9.5 premailer 3.10.0 prettytable 3.16.0 propcache 0.3.2 protobuf 4.25.5 psutil 7.0.0 py-cpuinfo 9.0.0 pyaml_env 1.2.2 pyarrow 15.0.2 pyclipper 1.3.0.post6 pycparser 2.22 pydantic 2.10.5 pydantic_core 2.27.2 Pygments 2.19.1 PyJWT 2.10.1 pylance 0.20.0 pynndescent 0.5.13 pyparsing 3.2.1 pypdfium2 4.30.1 pyproject_hooks 1.2.0 python-dateutil 2.9.0.post0 python-dotenv 1.0.1 pytz 2024.2 pywin32 308 pywin32-ctypes 0.2.3 PyYAML 6.0.2 RapidFuzz 3.11.0 regex 2024.11.6 requests 2.32.3 requests-toolbelt 1.0.0 rich 13.9.4 ruamel.yaml 0.18.14 ruamel.yaml.clib 0.2.12 safetensors 0.5.2 scikit-learn 1.6.1 scipy 1.12.0 seaborn 0.13.2 sentencepiece 0.2.0 sentry-sdk 2.29.1 setuptools 63.2.0 shapely 2.1.1 shellingham 1.5.4 six 1.17.0 smart-open 7.1.0 sniffio 1.3.1 SQLAlchemy 2.0.41 statsmodels 0.14.4 sympy 1.13.3 tenacity 8.5.0 threadpoolctl 3.5.0 tiktoken 0.8.0 tokenizers 0.19.1 tomli 2.2.1 tomlkit 0.13.2 torch 2.7.0 torchvision 0.22.0 tqdm 4.67.1 transformers 4.47.1 trove-classifiers 2025.1.10.15 typer 0.15.1 typing_extensions 4.12.2 typing-inspect 0.9.0 tzdata 2024.2 ujson 5.10.0 umap-learn 0.5.7 urllib3 2.3.0 virtualenv 20.28.1 wcwidth 0.2.13 wrapt 1.17.2 yarl 1.20.1 zipp 3.21.0
[notice] A new release of pip available: 22.2.1 -> 25.1.1 [notice] To update, run: python.exe -m pip install --upgrade pip
额外的 可以推理的显卡有7.X 算力 没有数据的显卡是P40 算力6.1 是不是因为6.1 就不能用了 即使驱动支持 cuda也支持?
我确认我是按照文档安装的3.0
3.0.0、3.0.0b1、3.0.0rc1这些都是不同的版本,如果你是按照其中一个文档安装了PaddleX,并且按照另一个文档中的方式请求,可能就会遇到这样的错误~不过,抱歉在beta、rc版本中引入了接口变更,给你造成了不便。
关于结果不一致的问题,我注意到两个机器的环境差异还是蛮大的,不确定是否有其他库的版本变更影响了精度。此外,没有数据的机器上还存在同时安装opencv-contrib-python和opencv-python这两个variant(而且还是不同版本)的错误。建议使用docker、conda或者更轻量的Python虚拟环境方案如virualenv/venv确保环境一致后进行比较,以便进一步判断问题是否和硬件有关~
The issue has no response for a long time and will be closed. You can reopen or new another issue if are still confused.
From Bot