### Install dependencies and run demo Source: https://github.com/paddlepaddle/paddleocr/blob/main/paddleocr-js/README.md Initial setup commands to install npm dependencies and start the Vite demo application in development mode. ```bash npm install npm run dev:demo ``` -------------------------------- ### Quick Start Source: https://github.com/paddlepaddle/paddleocr/blob/main/docs/version3.x/inference_deployment/serving/paddleocr_official_api/typescript.en.md A quick start example demonstrating how to use the `ocr` method to process an image URL. ```APIDOC ## Quick Start ```ts import { Model, PaddleOCRClient } from "@paddleocr/api-sdk"; const client = new PaddleOCRClient(); const result = await client.ocr({ fileUrl: "https://example.com/invoice.pdf", model: Model.PPOCRv5, }); console.log(result.jobId, result.pages.length); ``` Use `filePath` for a local file. Pass exactly one of `fileUrl` or `filePath`. ``` -------------------------------- ### Quick Start Source: https://github.com/paddlepaddle/paddleocr/blob/main/paddleocr-js/packages/core/README_cn.md A quick start guide to initialize the OCR engine and perform prediction. ```APIDOC ## Quick Start ```js import { PaddleOCR } from "@paddleocr/paddleocr-js"; const ocr = await PaddleOCR.create({ lang: "ch", ocrVersion: "PP-OCRv5", ortOptions: { backend: "auto" } }); const [result] = await ocr.predict(fileOrBlob); console.log(result.items); ``` `predict` returns an array of `OcrResult` (one for each input image). When passing a single `Blob` / `File`, you will also get an array of length 1. Use destructuring or `results[0]` to access the result. ``` -------------------------------- ### Local Development Setup Source: https://github.com/paddlepaddle/paddleocr/blob/main/api_sdk/typescript/README.md Install dependencies and build the SDK for local development. These commands are used when contributing to the SDK. ```bash npm install npm run build ``` -------------------------------- ### Download Example Dataset for Text Recognition Source: https://github.com/paddlepaddle/paddleocr/blob/main/docs/version3.x/module_usage/text_recognition.en.md Use this command to download the example dataset for text recognition training. Ensure you have `wget` installed. ```shell wget https://paddle-model-ecology.bj.bcebos.com/paddlex/data/ocr_rec_dataset_examples.tar tar -xf ocr_rec_dataset_examples.tar ``` -------------------------------- ### Install Go SDK and Set Access Token Source: https://github.com/paddlepaddle/paddleocr/blob/main/docs/version3.x/inference_deployment/serving/paddleocr_official_api/go.md Install the Go SDK using 'go get' and set your AI Studio access token as an environment variable. This token is required for authentication. ```bash go get github.com/PaddlePaddle/PaddleOCR/api_sdk/go export PADDLEOCR_ACCESS_TOKEN="your-access-token" ``` -------------------------------- ### Basic Parallel Inference Setup Source: https://github.com/paddlepaddle/paddleocr/blob/main/docs/version3.x/inference_deployment/local_inference/parallel_inference.en.md This example demonstrates a basic parallel inference setup using the PPStructureV3 pipeline across multiple GPUs. Each instance processes one input file. ```bash python infer_mp.py \ --pipeline PPStructureV3 \ --input_dir input_images/ \ --device 'gpu:0,1,2,3' \ --output_dir output ``` -------------------------------- ### Install PaddleOCR Go SDK Source: https://github.com/paddlepaddle/paddleocr/blob/main/api_sdk/go/README.md Use 'go get' to install the PaddleOCR Go SDK. Versioned releases are available as submodule tags. ```bash go get github.com/PaddlePaddle/PaddleOCR/api_sdk/go ``` -------------------------------- ### Quick Start with DocVLM Command Line Source: https://github.com/paddlepaddle/paddleocr/blob/main/docs/version3.x/module_usage/doc_vlm.md Use this command to quickly experience the DocVLM module's capabilities. Ensure PaddleOCR is installed. ```bash paddleocr doc_vlm -i "{'image': 'https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/medal_table.png', 'query': '识别这份表格的内容, 以markdown格式输出'}" ``` -------------------------------- ### Install PaddleOCR SDK and Set Access Token Source: https://github.com/paddlepaddle/paddleocr/blob/main/docs/version3.x/inference_deployment/serving/paddleocr_official_api/typescript.en.md Install the SDK using npm and set your access token as an environment variable. This is the initial setup required before using the SDK. ```bash npm install @paddleocr/api-sdk export PADDLEOCR_ACCESS_TOKEN="your-access-token" ``` -------------------------------- ### Quick Start with Command Line Source: https://github.com/paddlepaddle/paddleocr/blob/main/docs/version3.x/module_usage/doc_vlm.md Experience PaddleOCR's DocVLM module with a single command line. This example uses a remote image and a query to extract table content in markdown format. ```APIDOC ## Quick Start with Command Line Use a single command to quickly experience PaddleOCR's DocVLM: ```bash paddleocr doc_vlm -i "{'image': 'https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/medal_table.png', 'query': '识别这份表格的内容, 以markdown格式输出'}" ``` This example uses the `paddle_dynamic` inference engine. Ensure PaddlePaddle is installed as per the [PaddlePaddle Installation Guide](../paddlepaddle_installation.md). ``` -------------------------------- ### Basic Service Deployment Server Output Source: https://github.com/paddlepaddle/paddleocr/blob/main/docs/version3.x/inference_deployment/serving/serving.md Example output when the PaddleX serving server starts successfully. It indicates the server is running and ready to accept requests. ```text INFO: Started server process [63108] INFO: Waiting for application startup. INFO: Application startup complete. INFO: Uvicorn running on http://0.0.0.0:8080 (Press CTRL+C to quit) ``` -------------------------------- ### Prepare Serving Environment Source: https://github.com/paddlepaddle/paddleocr/blob/main/deploy/paddleocr_vl_docker/hps/README_en.md Copy the example environment file and run the prepare script to download the SDK and configure the Triton pipeline. ```bash cp .env.example .env # Edit HPS_PIPELINE_NAME in .env if needed bash prepare.sh ``` -------------------------------- ### Install and Authenticate Source: https://github.com/paddlepaddle/paddleocr/blob/main/docs/version3.x/inference_deployment/serving/paddleocr_official_api/typescript.en.md Instructions on how to install the SDK and authenticate using an access token. ```APIDOC ## Install And Authenticate First obtain an access token from the [AI Studio Access Token page](https://aistudio.baidu.com/account/accessToken). ```bash npm install @paddleocr/api-sdk export PADDLEOCR_ACCESS_TOKEN="your-access-token" ``` The client reads `PADDLEOCR_ACCESS_TOKEN` by default and also accepts `token`: ```ts import { PaddleOCRClient } from "@paddleocr/api-sdk"; const client = new PaddleOCRClient({ token: process.env.PADDLEOCR_ACCESS_TOKEN, }); ``` ``` -------------------------------- ### Quick Start with PaddleOCR Orientation Classification Source: https://github.com/paddlepaddle/paddleocr/blob/main/docs/version3.x/module_usage/doc_img_orientation_classification.en.md This command quickly demonstrates the document image orientation classification module. It requires the PaddleOCR wheel package to be installed. The example uses a sample image URL. ```bash paddleocr doc_img_orientation_classification -i https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/img_rot180_demo.jpg ``` -------------------------------- ### Execute Packaging Script Source: https://github.com/paddlepaddle/paddleocr/blob/main/docs/version3.x/inference_deployment/others/packaging.md Examples of how to run the packaging script. Use `--file` to specify your main script and `--nvidia` to include NVIDIA dependencies. ```bash python package.py --file main.py # 将NVIDIA的CUDA、cuDNN相关依赖库打包至可执行文件的同级目录中。 python package.py --file main.py --nvidia ``` -------------------------------- ### Install X-AnyLabeling via Pip Source: https://github.com/paddlepaddle/paddleocr/blob/main/docs/data_anno_synth/x_anylabeling.md Install the X-AnyLabeling package using pip. This command is used for quick setup and integration. ```bash pip install x-anylabeling ``` -------------------------------- ### Install and Setup Pre-commit Hooks Source: https://github.com/paddlepaddle/paddleocr/blob/main/docs/community/code_and_doc.md Install the 'pre-commit' tool using pip and then install the Git pre-commit hooks in your current repository. This helps enforce code style and checks before committing. ```bash pip install pre-commit pre-commit install ``` -------------------------------- ### Prepare Data and Environment for Benchmark Training (Shell) Source: https://github.com/paddlepaddle/paddleocr/blob/main/test_tipc/docs/benchmark_train.md Use this script to set up the training data and install the required environment for benchmark testing. It takes a configuration file and mode as arguments. ```shell bash test_tipc/prepare.sh test_tipc/configs/det_mv3_db_v2_0/train_infer_python.txt benchmark_train ``` -------------------------------- ### Install PaddleOCR and GenAI Server Dependencies Source: https://github.com/paddlepaddle/paddleocr/blob/main/docs/version3.x/pipeline_usage/PaddleOCR-VL.en.md Install PaddleOCR with doc-parser support and the dependencies for the genai server using vLLM as an example. ```shell python -m pip install "paddleocr[doc-parser]" paddleocr install_genai_server_deps vllm ``` -------------------------------- ### Prepare Environment and Configuration Source: https://github.com/paddlepaddle/paddleocr/blob/main/deploy/paddleocr_vl_docker/hps/README.md Copy the example environment file and modify it as needed. The prepare.sh script downloads the SDK and configures Triton. ```bash cp .env.example .env # Modify HPS_PIPELINE_NAME in .env as needed bash prepare.sh ``` -------------------------------- ### Example Usage of Packaging Script Source: https://github.com/paddlepaddle/paddleocr/blob/main/docs/version3.x/inference_deployment/others/packaging.en.md Demonstrates how to run the packaging script with and without the --nvidia flag to include NVIDIA dependencies. ```bash python package.py --file main.py # Packages NVIDIA CUDA and cuDNN related dependencies into the same directory as the executable. python package.py --file main.py --nvidia ``` -------------------------------- ### Training log output example Source: https://github.com/paddlepaddle/paddleocr/blob/main/ppstructure/layout/README_ch.md Example of the expected log output when training starts successfully, showing model weight loading and epoch metrics. ```text [08/15 04:02:30] ppdet.utils.checkpoint INFO: Finish loading model weights: /root/.cache/paddle/weights/LCNet_x1_0_pretrained.pdparams [08/15 04:02:46] ppdet.engine INFO: Epoch: [0] [ 0/1929] learning_rate: 0.040000 loss_vfl: 1.216707 loss_bbox: 1.142163 loss_dfl: 0.544196 loss: 2.903065 eta: 17 days, 13:50:26 batch_cost: 15.7452 data_cost: 2.9112 ips: 1.5243 images/s [08/15 04:03:19] ppdet.engine INFO: Epoch: [0] [ 20/1929] learning_rate: 0.064000 loss_vfl: 1.180627 loss_bbox: 0.939552 loss_dfl: 0.442436 loss: 2.628206 eta: 2 days, 12:18:53 batch_cost: 1.5770 data_cost: 0.0008 ips: 15.2184 images/s [08/15 04:03:47] ppdet.engine INFO: Epoch: [0] [ 40/1929] learning_rate: 0.088000 loss_vfl: 0.543321 loss_bbox: 1.071401 loss_dfl: 0.457817 loss: 2.057003 eta: 2 days, 0:07:03 batch_cost: 1.3190 data_cost: 0.0007 ips: 18.1954 images/s [08/15 04:04:12] ppdet.engine INFO: Epoch: [0] [ 60/1929] learning_rate: 0.112000 loss_vfl: 0.630989 loss_bbox: 0.859183 loss_dfl: 0.384702 loss: 1.883143 eta: 1 day, 19:01:29 batch_cost: 1.2177 data_cost: 0.0006 ips: 19.7087 images/s ``` -------------------------------- ### Docker Compose Output Example Source: https://github.com/paddlepaddle/paddleocr/blob/main/docs/version3.x/pipeline_usage/PaddleOCR-VL-AMD-GPU.en.md This is an example of the expected output after successfully starting the PaddleOCR-VL service using Docker Compose. It indicates the Uvicorn server is running. ```text paddleocr-vl-api | INFO: Started server process [1] paddleocr-vl-api | INFO: Waiting for application startup. paddleocr-vl-api | INFO: Application startup complete. paddleocr-vl-api | INFO: Uvicorn running on http://0.0.0.0:8080 (Press CTRL+C to quit) ``` -------------------------------- ### Install PaddleOCR-VL Dependencies Manually Source: https://github.com/paddlepaddle/paddleocr/blob/main/docs/version3.x/pipeline_usage/PaddleOCR-VL-Iluvatar-GPU.en.md Installs the necessary PaddlePaddle inference engine and PaddleOCR packages for manual setup. Ensure you are within an activated virtual environment. ```shell python -m pip install paddlepaddle==3.2.0 -i https://www.paddlepaddle.org.cn/packages/stable/cpu/ python -m pip install paddle-iluvatar-gpu==3.2.0 -i https://www.paddlepaddle.org.cn/packages/stable/maca/ python -m pip install -U "paddleocr[doc-parser]" ``` -------------------------------- ### Copy Environment Example Source: https://github.com/paddlepaddle/paddleocr/blob/main/deploy/paddleocr_vl_docker/hps/README.md Copy the .env.example file to .env to configure service variables. ```bash cp .env.example .env ``` -------------------------------- ### Install All doc2md Dependencies Source: https://github.com/paddlepaddle/paddleocr/blob/main/docs/version3.x/doc2md.md This command installs all necessary dependencies for the `doc2md` functionality within `paddleocr` in one go. It simplifies the setup process for full `doc2md` support. ```bash pip install "paddleocr[doc2md]" ``` -------------------------------- ### Pipeline Configuration Example Source: https://github.com/paddlepaddle/paddleocr/blob/main/docs/version3.x/pipeline_usage/PP-ChatOCRv4.en.md Example of a pipeline configuration file, showing where to replace model directories for fine-tuned weights. ```yaml ...... SubModules: TextDetection: module_name: text_detection model_name: PP-OCRv5_server_det model_dir: null # Replace with the fine-tuned text detection model weights directory limit_side_len: 960 limit_type: max thresh: 0.3 box_thresh: 0.6 unclip_ratio: 1.5 TextRecognition: module_name: text_recognition model_name: PP-OCRv5_server_rec model_dir: null # Replace with the fine-tuned text recognition model weights directory batch_size: 1 batch_size: 1 score_thresh: 0 ...... ``` -------------------------------- ### Download and Install TensorRT (Manual) Source: https://github.com/paddlepaddle/paddleocr/blob/main/docs/version3.x/inference_deployment/local_inference/high_performance_inference.en.md Steps to download, extract, and install TensorRT, then configure the library path for use. ```bash # Download the TensorRT tar file wget https://developer.nvidia.com/downloads/compute/machine-learning/tensorrt/secure/8.6.1/tars/TensorRT-8.6.1.6.Linux.x86_64-gnu.cuda-11.8.tar.gz # Extract the TensorRT tar file tar xvf TensorRT-8.6.1.6.Linux.x86_64-gnu.cuda-11.8.tar.gz # Install the TensorRT wheel package python -m pip install TensorRT-8.6.1.6/python/tensorrt-8.6.1-cp310-none-linux_x86_64.whl # Add the absolute path of the TensorRT `lib` directory to LD_LIBRARY_PATH export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:TensorRT-8.6.1.6/lib" ``` -------------------------------- ### Install PaddleOCR-VL Dependencies Manually Source: https://github.com/paddlepaddle/paddleocr/blob/main/docs/version3.x/pipeline_usage/PaddleOCR-VL-Iluvatar-GPU.md This command installs the necessary PaddlePaddle framework and PaddleOCR-VL packages for manual setup. Ensure you are within an activated virtual environment and have Python versions 3.9-3.13. It's crucial to install version 3.2.0 or higher for the PaddlePaddle framework. ```shell python -m pip install paddlepaddle==3.2.0 -i https://www.paddlepaddle.org.cn/packages/stable/cpu/ python -m pip install paddle-iluvatar-gpu==3.2.0 -i https://www.paddlepaddle.org.cn/packages/stable/ixuca/ python -m pip install -U "paddleocr[doc-parser]" ``` -------------------------------- ### Device Selection Examples Source: https://github.com/paddlepaddle/paddleocr/blob/main/docs/version3.x/pipeline_usage/PP-StructureV3.en.md Examples of specifying different hardware accelerators for inference. If not set, the pipeline defaults to local GPU device 0 or CPU. ```text npu:0 ``` ```text xpu:0 ``` ```text mlu:0 ``` ```text dcu:0 ``` ```text metax_gpu:0 ``` ```text iluvatar_gpu:0 ``` -------------------------------- ### Install PaddleOCR-VL Dependencies Manually Source: https://github.com/paddlepaddle/paddleocr/blob/main/docs/version3.x/pipeline_usage/PaddleOCR-VL-MetaX-GPU.en.md Installs the necessary PaddlePaddle inference engine and PaddleOCR packages for manual setup. Ensure PaddlePaddle version is 3.2.0 or above. Uses specific repositories for CPU and MACA. ```shell python -m pip install paddlepaddle==3.2.0 -i https://www.paddlepaddle.org.cn/packages/stable/cpu/ python -m pip install paddle-metax-gpu==3.2.0 -i https://www.paddlepaddle.org.cn/packages/stable/maca/ python -m pip install -U "paddleocr[doc-parser]" ``` -------------------------------- ### Quick Start with Transformers Engine Source: https://github.com/paddlepaddle/paddleocr/blob/main/docs/version3.x/module_usage/doc_img_orientation_classification.en.md This command demonstrates using the document image orientation classification module with the 'transformers' inference engine. Ensure the Transformers environment is configured before running. ```bash # Use the transformers engine for inference paddleocr doc_img_orientation_classification -i https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/img_rot180_demo.jpg \ --engine transformers ``` -------------------------------- ### Quick Start Formula Recognition Command Source: https://github.com/paddlepaddle/paddleocr/blob/main/docs/version3.x/module_usage/formula_recognition.md Use this command for a quick, one-line experience of formula recognition. It requires PaddleOCR to be installed. ```bash paddleocr formula_recognition -i https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/general_formula_rec_001.png ``` -------------------------------- ### Install PaddleX Serving Plugin Source: https://github.com/paddlepaddle/paddleocr/blob/main/docs/version3.x/inference_deployment/serving/serving.md Use the PaddleX CLI to install the serving deployment plugin. This is a prerequisite for running the PaddleX server. ```bash paddlex --install serving ``` -------------------------------- ### Install DBNet.paddle using Conda or Manual Setup Source: https://github.com/paddlepaddle/paddleocr/blob/main/benchmark/PaddleOCR_DBNet/README.MD Provides commands to set up the environment using a YAML file or manual installation via pip and conda. Requires Python 3.6 and specific dependencies. ```bash conda env create -f environment.yml git clone https://github.com/WenmuZhou/DBNet.paddle.git cd DBNet.paddle/ # Or Manual Installation conda create -n dbnet python=3.6 conda activate dbnet conda install ipython pip pip install -r requirement.txt git clone https://github.com/WenmuZhou/DBNet.paddle.git cd DBNet.paddle/ ``` -------------------------------- ### Python Service Call for Table Recognition Source: https://github.com/paddlepaddle/paddleocr/blob/main/docs/version3.x/pipeline_usage/table_recognition_v2.md Example of how to call the table recognition service using Python. Ensure you have the 'requests' library installed. ```python import requests import json url = "http://127.0.0.1:8866/predict/table_recognition" # Example with image URL with open('table.jpg', 'rb') as f: image_data = f.read() files = { 'image': ('table.jpg', image_data) } # Optional parameters can be added here, e.g.: # data = { # "use_angle_cls": "true", # "det_limit_side_len": "512", # "det_limit_type": "max", # } response = requests.post(url, files=files) if response.status_code == 200: result = response.json() print(json.dumps(result, indent=4, ensure_ascii=False)) else: print(f"Error: {response.status_code}") print(response.text) ``` -------------------------------- ### Install PaddleOCR.js SDK Source: https://github.com/paddlepaddle/paddleocr/blob/main/paddleocr-js/packages/core/README_cn.md Install the SDK using npm. This is the first step before using the library. ```bash npm install @paddleocr/paddleocr-js ``` -------------------------------- ### Start service with command-line arguments Source: https://github.com/paddlepaddle/paddleocr/blob/main/deploy/hubserving/readme.md Start PaddleHub Serving with modules, port, and worker configuration. CPU-only method; use configuration file for GPU support. ```bash hub serving start --modules Module1==Version1, Module2==Version2, ... \ --port 8866 \ --use_multiprocess \ --workers ``` ```bash hub serving start -m ocr_system ``` -------------------------------- ### Install PaddleSlim for OCR Model Quantization Source: https://github.com/paddlepaddle/paddleocr/blob/main/deploy/slim/quantization/README_en.md This command installs the PaddleSlim library, a dependency required for performing quantization-aware training and model compression on PaddleOCR models. It specifies version 2.3.2 to ensure compatibility with the provided examples and functionalities. ```bash pip3 install paddleslim==2.3.2 ``` -------------------------------- ### Quick Start Table Classification Source: https://github.com/paddlepaddle/paddleocr/blob/main/docs/version3.x/module_usage/table_classification.en.md This command initiates table classification using the default paddle_static inference engine. Ensure PaddlePaddle is installed before running. ```bash paddleocr table_classification -i https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/table_recognition.jpg ``` -------------------------------- ### Start PP-OCRv3 Model Training Source: https://github.com/paddlepaddle/paddleocr/blob/main/deploy/paddlecloud/README.md These commands initiate the training process for the PP-OCRv3 model. The first command is for single GPU (or CPU if `use_gpu=false`), and the second is for multi-GPU distributed training. ```bash # 这里以 GPU 训练为例,使用 CPU 进行训练的话,需要指定参数 Global.use_gpu=false python3 tools/train.py -c configs/det/ch_PP-OCRv3/ch_PP-OCRv3_det_cml.yml -o Global.save_model_dir=./output/ Global.pretrained_model=./pre_train/ch_PP-OCRv3_det_distill_train/best_accuracy ``` ```bash # 启动训练,训练模型默认保存在output目录下,--gpus '0,1,2,3'表示使用0,1,2,3号GPU训练 python3 -m paddle.distributed.launch --log_dir=./debug/ --gpus '0,1,2,3' tools/train.py -c configs/det/ch_PP-OCRv3/ch_PP-OCRv3_det_cml.yml -o Global.save_model_dir=./output/ Global.pretrained_model=./pre_train/ch_PP-OCRv3_det_distill_train/best_accuracy ``` -------------------------------- ### Prepare and test with ARM_CPU backend Source: https://github.com/paddlepaddle/paddleocr/blob/main/test_tipc/docs/test_lite_arm_cpp.md Prepare test data, models, and Paddle-Lite prediction library for ARM_CPU testing using either download or compile method, then run tests on the device. ```shell # 数据、模型、Paddle-Lite预测库准备 #预测库为下载方式 bash test_tipc/prepare_lite_cpp.sh ./test_tipc/configs/ch_PP-OCRv2_det/model_linux_gpu_normal_normal_lite_cpp_arm_cpu.txt download #预测库为编译方式 bash test_tipc/prepare_lite_cpp.sh ./test_tipc/configs/ch_PP-OCRv2_det/model_linux_gpu_normal_normal_lite_cpp_arm_cpu.txt compile # 手机端测试: bash test_lite_arm_cpp.sh model_linux_gpu_normal_normal_lite_cpp_arm_cpu.txt ``` -------------------------------- ### Python Client for PaddleOCR-VL Source: https://github.com/paddlepaddle/paddleocr/blob/main/docs/version3.x/pipeline_usage/PaddleOCR-VL.md Example of how to set up a Python client to interact with the PaddleOCR-VL service. It includes basic setup for making requests to the service URL. ```python import base64 import requests import pathlib BASE_URL = "http://localhost:8080" image_path = "./demo.jpg" ``` -------------------------------- ### Initialize OpenAI Client and Submit to PP-DocBee Source: https://github.com/paddlepaddle/paddleocr/blob/main/docs/version3.x/pipeline_usage/doc_understanding.en.md This snippet shows how to initialize the OpenAI client with an API key and base URL, encode an image to base64, and then submit the image and a text prompt to the PP-DocBee model for analysis. It demonstrates a typical workflow for document understanding tasks. ```python client = OpenAI( api_key='xxxxxxxxx', base_url=f'{API_BASE_URL}' ) def encode_image(image_path): with open(image_path, "rb") as image_file: return base64.b64encode(image_file.read()).decode('utf-8') image_path = "medal_table.png" base64_image = encode_image(image_path) response = client.chat.completions.create( model="pp-docbee", messages=[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content":[ { "type": "text", "text": "识别这份表格的内容,输出html格式的内容" }, { "type": "image_url", "image_url": {"url": f"data:image/jpeg;base64,{base64_image}"} }, ] }, ], ) content = response.choices[0].message.content print('Reply:', content) ``` -------------------------------- ### Node.js Service Call for Table Recognition Source: https://github.com/paddlepaddle/paddleocr/blob/main/docs/version3.x/pipeline_usage/table_recognition_v2.md Example of how to call the table recognition service using Node.js with the 'axios' library. Ensure 'axios' and 'fs' are installed. ```javascript const axios = require('axios'); const fs = require('fs'); const url = 'http://127.0.0.1:8866/predict/table_recognition'; async function callTableRecognition() { try { const imageBuffer = fs.readFileSync('table.jpg'); const base64Image = imageBuffer.toString('base64'); const response = await axios.post(url, { image: base64Image // Optional parameters can be added here, e.g.: // use_angle_cls: 'true', // det_limit_side_len: '512', // det_limit_type: 'max' }, { headers: { 'Content-Type': 'application/json' } }); console.log(JSON.stringify(response.data, null, 4)); } catch (error) { console.error('Error calling table recognition service:', error.response ? error.response.data : error.message); } } callTableRecognition(); ``` -------------------------------- ### Download Seal Text Detection Demo Dataset Source: https://github.com/paddlepaddle/paddleocr/blob/main/docs/version3.x/module_usage/seal_text_detection.en.md Downloads and extracts the example dataset for seal text detection. Ensure PaddleOCR dependencies are installed before proceeding. ```shell wget https://paddle-model-ecology.bj.bcebos.com/paddlex/data/ocr_curve_det_dataset_examples.tar -P ./dataset tar -xf ./dataset/ocr_curve_det_dataset_examples.tar -C ./dataset/ ``` -------------------------------- ### Run Benchmark with Fixture and Iterations Source: https://github.com/paddlepaddle/paddleocr/blob/main/docs/version3.x/inference_deployment/cross_platform/ios_deployment.md Utilize a pre-existing fixture for benchmarking, configuring warm-up and measured iterations. ```bash ./scripts/run_benchmark.sh --fixture ios_ocr_benchmark_reference --warmup 2 --measured-iterations 20 ``` -------------------------------- ### Install Training Dependencies Source: https://github.com/paddlepaddle/paddleocr/blob/main/docs/version3.x/installation.en.md Installs the remaining dependencies required for model training and export after cloning the repository. This command reads from the 'requirements.txt' file. ```bash python -m pip install -r requirements.txt ```