### Install PPOCRLabel on Windows Source: https://github.com/mushroomcat9998/paddleocr/blob/main/PPOCRLabel/README.md Installs PPOCRLabel on Windows by first installing pyqt5, navigating to the PPOCRLabel directory, and then running the main Python script. Ensure Python 3 is used. ```shell pip install pyqt5 cd ./PPOCRLabel # Change the directory to the PPOCRLabel folder python PPOCRLabel.py ``` -------------------------------- ### Install PPOCRLabel on Ubuntu Linux Source: https://github.com/mushroomcat9998/paddleocr/blob/main/PPOCRLabel/README.md Installs PPOCRLabel on Ubuntu Linux. This involves installing pyqt5 and trash-cli, changing to the PPOCRLabel directory, and executing the main Python script using python3. ```shell pip3 install pyqt5 pip3 install trash-cli cd ./PPOCRLabel # Change the directory to the PPOCRLabel folder python3 PPOCRLabel.py ``` -------------------------------- ### Starting Serving with Configuration File Source: https://github.com/mushroomcat9998/paddleocr/blob/main/deploy/hubserving/readme_en.md This section details how to start the PaddleOCR serving API using a configuration file, supporting both CPU and GPU usage. ```APIDOC ## Starting Serving with Configuration File ### Description Start the PaddleOCR serving API using a configuration file (`config.json`). This method allows for specifying parameters like GPU usage, port, and number of workers. ### Method `hub serving start` ### Command ```shell hub serving start --config/-c config.json ``` ### Configuration File (`config.json`) ```json { "modules_info": { "ocr_system": { "init_args": { "version": "1.0.0", "use_gpu": true }, "predict_args": {} } }, "port": 8868, "use_multiprocess": false, "workers": 2 } ``` ### Parameters - `modules_info`: Information about the OCR modules. - `ocr_system`: Configuration for the OCR system module. - `init_args`: Arguments for initializing the module. Parameters are consistent with the `_initialize` function in `module.py`. - **`use_gpu`** (boolean) - If `true`, the GPU is used to start the service. Cannot be `true` if `use_multiprocess` is `true`. - `predict_args`: Arguments for prediction. Parameters are consistent with the `predict` function in `module.py`. - `port` (integer) - The port number for the serving API. - `use_multiprocess` (boolean) - Whether to use multiprocess. Cannot be `true` if `use_gpu` is `true`. - `workers` (integer) - The number of worker processes. ### Notes - Other parameters are ignored when using a configuration file. - If `use_gpu` is set to `true`, set the environment variable `CUDA_VISIBLE_DEVICES` before starting the service (e.g., `export CUDA_VISIBLE_DEVICES=0`). ### Example (GPU Usage) Use GPU card No. 3 to start the 2-stage series service: ```shell export CUDA_VISIBLE_DEVICES=3 hub serving start -c deploy/hubserving/ocr_system/config.json ``` ``` -------------------------------- ### Install PaddleSlim Source: https://github.com/mushroomcat9998/paddleocr/blob/main/deploy/slim/quantization/README_en.md Clones the PaddleSlim repository and installs it using setup.py. This is the first step to enable quantization functionalities. ```bash git clone https://github.com/PaddlePaddle/PaddleSlim.git cd PaddlSlim python setup.py install ``` -------------------------------- ### Install PPOCRLabel on macOS Source: https://github.com/mushroomcat9998/paddleocr/blob/main/PPOCRLabel/README.md Installs PPOCRLabel on macOS, which requires installing pyqt5, manually uninstalling and then installing a specific version of opencv-python (headless), navigating to the PPOCRLabel directory, and running the main Python script with python3. ```shell pip3 install pyqt5 pip3 uninstall opencv-python # Uninstall opencv manually as it conflicts with pyqt pip3 install opencv-contrib-python-headless==4.2.0.32 # Install the headless version of opencv cd ./PPOCRLabel # Change the directory to the PPOCRLabel folder python3 PPOCRLabel.py ``` -------------------------------- ### Install PaddleServing Server (GPU) Source: https://github.com/mushroomcat9998/paddleocr/blob/main/deploy/pdserving/README.md Installs the PaddleServing server package for GPU environments. This command should be used if you have a compatible GPU setup. ```bash pip3 install paddle-serving-server-gpu==0.6.1 # for GPU ``` -------------------------------- ### Install PaddleOCR using Pip Source: https://github.com/mushroomcat9998/paddleocr/blob/main/doc/doc_en/whl_en.md Installs the PaddleOCR package from PyPI. It is recommended to use version 2.0.1 or later for the best performance and features. This is the simplest way to get started with the library. ```bash pip install "paddleocr>=2.0.1" ``` -------------------------------- ### Install ADB for Linux Source: https://github.com/mushroomcat9998/paddleocr/blob/main/deploy/lite/readme_en.md Installs the Android Debug Bridge (ADB) tool on Linux systems using apt package manager. This command updates the package list and installs ADB along with wget for downloading necessary files. ```shell sudo apt update sudo apt install -y wget adb ``` -------------------------------- ### Install PaddlePaddle (CPU/GPU) Source: https://github.com/mushroomcat9998/paddleocr/blob/main/doc/doc_en/multi_languages_en.md Installs the PaddlePaddle deep learning framework. Choose the CPU version for general use or the GPU version if you have a compatible NVIDIA GPU and CUDA installed for accelerated performance. ```bash # cpu pip install paddlepaddle # gpu pip install paddlepaddle-gpu ``` -------------------------------- ### Install and Launch PPOCRLabel Source: https://context7.com/mushroomcat9998/paddleocr/llms.txt Instructions for installing the necessary dependencies for PPOCRLabel (PyQt5 and lxml) and launching the GUI-based annotation tool. The command assumes the user is in the PPOCRLabel directory and specifies the language for the tool. ```bash # Install dependencies pip install pyqt5 lxml # Launch PPOCRLabel cd PPOCRLabel python PPOCRLabel.py --lang en ``` -------------------------------- ### Install PaddleSlim Source: https://github.com/mushroomcat9998/paddleocr/blob/main/deploy/slim/prune/README_en.md This code snippet shows the commands to clone the PaddleSlim repository, checkout the develop branch, and install it using setup.py. This is the first step in preparing the environment for model pruning. ```bash git clone https://github.com/PaddlePaddle/PaddleSlim.git cd PaddleSlim git checkout develop python3 setup.py install ``` -------------------------------- ### Install PaddleOCR via Pip Source: https://context7.com/mushroomcat9998/paddleocr/llms.txt This command installs the PaddleOCR library using pip, ensuring version 2.0.1 or higher is used. This is the simplest way to get started with PaddleOCR for command-line tasks or integration into Python projects. ```bash pip install paddleocr>=2.0.1 ``` -------------------------------- ### Install PaddleServing App Source: https://github.com/mushroomcat9998/paddleocr/blob/main/deploy/pdserving/README.md Installs the paddle-serving-app package, which provides additional utilities and framework components for PaddleServing. ```bash pip3 install paddle-serving-app==0.6.1 ``` -------------------------------- ### Install PaddleOCR from Built Wheel Package Source: https://github.com/mushroomcat9998/paddleocr/blob/main/doc/doc_en/whl_en.md Builds a wheel package for PaddleOCR from its source code and then installs it. This method is useful for development or when a specific build is required. Replace 'x.x.x' with the actual version number. ```bash python3 setup.py bdist_wheel pip3 install dist/paddleocr-x.x.x-py3-none-any.whl ``` -------------------------------- ### Install PaddleOCR Package Source: https://github.com/mushroomcat9998/paddleocr/blob/main/doc/doc_en/multi_languages_en.md Installs the PaddleOCR library, recommended to use version 2.0.6 or later. Alternatively, you can build and install it locally from source for development or specific version needs. ```bash pip install "paddleocr>=2.0.6" # 2.0.6 version is recommended python3 setup.py bdist_wheel pip3 install dist/paddleocr-x.x.x-py3-none-any.whl # x.x.x is the version number of paddleocr ``` -------------------------------- ### Sending Prediction Requests Source: https://github.com/mushroomcat9998/paddleocr/blob/main/deploy/hubserving/readme_en.md Instructions on how to send prediction requests to the started serving API and the expected parameters. ```APIDOC ## Sending Prediction Requests ### Description After the service starts, send prediction requests using the provided script to obtain OCR results. ### Method `python tools/test_hubserving.py` ### Parameters - **`server_url`** (string) - Required - The service address. Format: `http://[ip_address]:[port]/predict/[module_name]`. - Examples: - `http://127.0.0.1:8865/predict/ocr_det` - `http://127.0.0.1:8866/predict/ocr_cls` - `http://127.0.0.1:8867/predict/ocr_rec` - `http://127.0.0.1:8868/predict/ocr_system` - **`image_path`** (string) - Required - The path to the test image or a directory of images. ### Example ```shell python tools/test_hubserving.py http://127.0.0.1:8868/predict/ocr_system ./doc/imgs/ ``` ``` -------------------------------- ### Install PaddleServing Server (CPU) Source: https://github.com/mushroomcat9998/paddleocr/blob/main/deploy/pdserving/README.md Installs the PaddleServing server package for CPU environments. This is a prerequisite for deploying models as a service. ```bash pip3 install paddle-serving-server==0.6.1 # for CPU ``` -------------------------------- ### Install ADB for MAC Source: https://github.com/mushroomcat9998/paddleocr/blob/main/deploy/lite/readme_en.md Installs the Android Debug Bridge (ADB) tool on macOS using Homebrew. ADB is essential for connecting to and managing Android devices from a computer, including debugging and file transfer. ```shell brew cask install android-platform-tools ``` -------------------------------- ### Install PaddleServing Client Source: https://github.com/mushroomcat9998/paddleocr/blob/main/deploy/pdserving/README.md Installs the PaddleServing client package, which is used to send requests to the deployed service. Ensure you download the correct wheel file for your Python version. ```bash wget https://paddle-serving.bj.bcebos.com/test-dev/whl/paddle_serving_client-0.0.0-cp37-none-any.whl pip3 install paddle_serving_client-0.0.0-cp37-none-any.whl ``` -------------------------------- ### Verify ADB Installation Source: https://github.com/mushroomcat9998/paddleocr/blob/main/deploy/lite/readme_en.md Verifies if the Android Debug Bridge (ADB) tool is successfully installed and recognizes connected devices. A successful output lists attached devices, indicating that the connection between the computer and the Android device is established. ```shell adb devices ``` -------------------------------- ### MKL Include and Library Setup (CMake) Source: https://github.com/mushroomcat9998/paddleocr/blob/main/deploy/cpp_infer/CMakeLists.txt Configures include directories and library paths for MKLML (Math Kernel Library) when `WITH_MKL` is enabled. It defines the specific MKL libraries to be linked based on the operating system (Windows or other). ```cmake if(WITH_MKL) include_directories("${PADDLE_LIB}/third_party/install/mklml/include") if (WIN32) set(MATH_LIB ${PADDLE_LIB}/third_party/install/mklml/lib/mklml.lib ${PADDLE_LIB}/third_party/install/mklml/lib/libiomp5md.lib) else () set(MATH_LIB ${PADDLE_LIB}/third_party/install/mklml/lib/libmklml_intel${CMAKE_SHARED_LIBRARY_SUFFIX} ${PADDLE_LIB}/third_party/install/mklml/lib/libiomp5${CMAKE_SHARED_LIBRARY_SUFFIX}) execute_process(COMMAND cp -r ${PADDLE_LIB}/third_party/install/mklml/lib/libmklml_intel${CMAKE_SHARED_LIBRARY_SUFFIX} /usr/lib) endif () endif() ``` -------------------------------- ### Start Text Detection Training (Shell) Source: https://github.com/mushroomcat9998/paddleocr/blob/main/doc/doc_en/detection_en.md Initiates the text detection model training process using a specified configuration file. Assumes CPU training if 'use_gpu' is false in the config. ```shell python3 tools/train.py -c configs/det/det_mv3_db.yml ``` -------------------------------- ### Start PaddleOCR Web Server on Windows Source: https://github.com/mushroomcat9998/paddleocr/blob/main/deploy/pdserving/README.md Launches the PaddleOCR web service on Windows. Users can choose between CPU or GPU modes depending on their hardware. The script is located within the 'win' directory. ```shell cd win python3 ocr_web_server.py gpu(for gpu user) or python3 ocr_web_server.py cpu(for cpu user) ``` -------------------------------- ### Start PaddleOCR Docker Container (CPU) Source: https://github.com/mushroomcat9998/paddleocr/blob/main/deploy/docker/hubserving/README.md This command starts a Docker container from the 'paddleocr:cpu' image. It maps port 8868 from the host to the container and names the container 'paddle_ocr'. This is for CPU-based inference. ```shell sudo docker run -dp 8868:8868 --name paddle_ocr paddleocr:cpu ``` -------------------------------- ### Prepare PaddleOCR Lite Demo Environment Source: https://github.com/mushroomcat9998/paddleocr/blob/main/deploy/lite/readme_en.md Prepares the PaddleOCR Lite C++ OCR demo environment by cloning the repository, navigating to the lite deployment directory, and running the prepare.sh script. This script downloads and sets up the necessary prediction library and files for running OCR on Android. ```shell git clone https://github.com/PaddlePaddle/PaddleOCR.git cd PaddleOCR/deploy/lite/ # run prepare.sh sh prepare.sh /{lite prediction library path}/inference_lite_lib.android.armv8 ``` -------------------------------- ### Start PaddleOCR Docker Container (GPU - NVIDIA Docker) Source: https://github.com/mushroomcat9998/paddleocr/blob/main/deploy/docker/hubserving/README.md This command starts a Docker container for PaddleOCR on a GPU using the 'nvidia-docker' command. It maps port 8868 and names the container 'paddle_ocr'. This requires NVIDIA Container Toolkit. ```shell sudo nvidia-docker run -dp 8868:8868 --name paddle_ocr paddleocr:gpu ``` -------------------------------- ### Start PaddleOCR Docker Container (GPU - Docker 19.03+) Source: https://github.com/mushroomcat9998/paddleocr/blob/main/deploy/docker/hubserving/README.md This command starts a Docker container for PaddleOCR on a GPU using the standard 'docker run' command with the '--gpus all' flag. It maps port 8868 and names the container 'paddle_ocr'. This is suitable for Docker version 19.03 and above. ```shell sudo docker run -dp 8868:8868 --gpus all --name paddle_ocr paddleocr:gpu ``` -------------------------------- ### Check PaddleOCR Service Status Source: https://github.com/mushroomcat9998/paddleocr/blob/main/deploy/docker/hubserving/README.md This command displays the logs of the running PaddleOCR Docker container. Successful completion is indicated by messages like 'Successfully installed ocr_system && Running on http://0.0.0.0:8868/'. ```shell docker logs -f paddle_ocr ``` -------------------------------- ### Add Custom Loss Function in PaddleOCR (Python) Source: https://github.com/mushroomcat9998/paddleocr/blob/main/doc/doc_en/add_new_algorithm_en.md This code example shows how to implement a custom loss function for PaddleOCR. It involves creating a class that inherits from `paddle.nn.Layer`, defining an __init__ method, and a __call__ method to compute the loss between predictions and labels. This enables custom loss calculations for training OCR models. ```python import paddle from paddle import nn class MyLoss(nn.Layer): def __init__(self, **kwargs): super(MyLoss, self).__init__() # you init code pass def __call__(self, predicts, batch): label = batch[1] # your loss code loss = self.loss(input=predicts, label=label) return {'loss': loss} ``` -------------------------------- ### Manual Configuration for Multi-language Training Source: https://github.com/mushroomcat9998/paddleocr/blob/main/doc/doc_en/recognition_en.md This example shows how to manually modify the configuration file template for multi-language training. Key parameters to adjust include global settings like GPU usage and epoch number, character type specific to the language, the path to the character dictionary, and dataset configurations for training and evaluation, including data directory and label file paths. ```yaml Global: use_gpu: True epoch_num: 500 ... character_type: it # language character_dict_path: {path/of/dict} # path of dict Train: dataset: name: SimpleDataSet data_dir: train_data/ # root directory of training data label_file_list: ["./train_data/train_list.txt"] # train label path ... Eval: dataset: name: SimpleDataSet data_dir: train_data/ # root directory of val data label_file_list: ["./train_data/val_list.txt"] # val label path ... ``` -------------------------------- ### Generate Italian Configuration File for Training (Bash) Source: https://github.com/mushroomcat9998/paddleocr/blob/main/doc/doc_en/models_list_en.md This command generates an Italian configuration file for training custom OCR models with PaddleOCR. It requires specifying paths for the training set, validation set, data directory, and optionally allows modification of default parameters. The command must be run from the specified directory within the PaddleOCR repository. ```bash cd {your/path/}PaddleOCR/configs/rec/multi_language/ python3 generate_multi_language_configs.py -l it --train {your/path/}PaddleOCR/train_data/train_list.txt --val {your/path/}PaddleOCR/train_data/val_list.txt --data_dir {your/path/}PaddleOCR/train_data -o "some_param=some_value" ``` -------------------------------- ### Run Paddle Lite Optimization Tool Source: https://github.com/mushroomcat9998/paddleocr/blob/main/deploy/lite/readme_en.md Executes the compiled Paddle Lite optimization tool to convert PaddlePaddle inference models into an optimized format. This command requires specifying input model files, output paths, and target deployment platforms. ```shell # Download and extract PaddleOCR V2.0 models wget https://paddleocr.bj.bcebos.com/dygraph_v2.0/slim/ch_ppocr_mobile_v2.0_det_slim_infer.tar && tar xf ch_ppocr_mobile_v2.0_det_slim_infer.tar wget https://paddleocr.bj.bcebos.com/dygraph_v2.0/slim/ch_ppocr_mobile_v2.0_rec_slim_infer.tar && tar xf ch_ppocr_mobile_v2.0_rec_slim_infer.tar wget https://paddleocr.bj.bcebos.com/dygraph_v2.0/slim/ch_ppocr_mobile_v2.0_cls_slim_infer.tar && tar xf ch_ppocr_mobile_v2.0_cls_slim_infer.tar # Convert V2.0 detection model to optimized format for ARM ./opt --model_file=./ch_ppocr_mobile_v2.0_det_slim_infer/inference.pdmodel --param_file=./ch_ppocr_mobile_v2.0_det_slim_infer/inference.pdiparams --optimize_out=./ch_ppocr_mobile_v2.0_det_slim_opt --valid_targets=arm --optimize_out_type=naive_buffer ``` -------------------------------- ### Generate Italian Configuration File for Prediction (Bash) Source: https://github.com/mushroomcat9998/paddleocr/blob/main/doc/doc_en/models_list_en.md This command generates a default configuration file for the Italian language, intended for prediction using PaddleOCR. It needs to be executed from the specified directory and uses the `-l` or `--language` parameter to set the target language. The default language dictionary provided by PaddleOCR is utilized. ```bash cd {your/path/}PaddleOCR/configs/rec/multi_language/ python3 generate_multi_language_configs.py -l it ``` -------------------------------- ### Build and Run C++ PaddleOCR Inference Source: https://context7.com/mushroomcat9998/paddleocr/llms.txt This section provides bash commands to build and run the C++ PaddleOCR inference application. First, it navigates to the `cpp_infer` directory, creates a build folder, and configures the CMake build with paths to Paddle Inference, MKL, GPU support, TensorRT, and OpenCV. After building with `make`, the `ppocr_system` executable is run with various arguments specifying model directories, image paths, and hardware acceleration options. This setup allows for high-performance OCR deployment. ```bash # Build C++ inference cd deploy/cpp_infer mkdir build && cd build cmake .. \ -DPADDLE_LIB=/path/to/paddle_inference \ -DWITH_MKL=ON \ -DWITH_GPU=ON \ -DWITH_TENSORRT=ON \ -DOPENCV_DIR=/path/to/opencv make -j8 # Run inference ./build/ppocr_system \ --det_model_dir=./inference/ch_ppocr_mobile_v2.0_det_infer \ --rec_model_dir=./inference/ch_ppocr_mobile_v2.0_rec_infer \ --cls_model_dir=./inference/ch_ppocr_mobile_v2.0_cls_infer \ --image_dir=./test_images/ \ --use_angle_cls=true \ --use_gpu=true \ --gpu_id=0 \ --gpu_mem=4000 ``` -------------------------------- ### Create Symbolic Link for Dataset (Linux/macOS) Source: https://github.com/mushroomcat9998/paddleocr/blob/main/doc/doc_en/recognition_en.md Creates a symbolic link to an existing dataset directory. This is useful for organizing training data without moving it. It takes the path to the dataset and the destination path within the PaddleOCR directory as arguments. ```bash # linux and mac os ln -sf /train_data/dataset ``` -------------------------------- ### Compile PaddleOCR C++ Inference Demo Source: https://github.com/mushroomcat9998/paddleocr/blob/main/deploy/cpp_infer/readme_en.md This section provides instructions for compiling the PaddleOCR C++ inference demo. The process involves using a `build.sh` script that configures the build using CMake. Users must replace placeholder paths for Paddle C++ inference library, OpenCV, CUDA, and cuDNN with their actual installation locations. The compilation generates an executable file named `ocr_system` in the `build` directory. ```shell sh tools/build.sh ``` ```shell OPENCV_DIR=your_opencv_dir LIB_DIR=your_paddle_inference_dir CUDA_LIB_DIR=your_cuda_lib_dir CUDNN_LIB_DIR=your_cudnn_lib_dir BUILD_DIR=build rm -rf ${BUILD_DIR} mkdir ${BUILD_DIR} cd ${BUILD_DIR} cmake .. \ -DPADDLE_LIB=${LIB_DIR} \ -DWITH_MKL=ON \ -DDEMO_NAME=ocr_system \ -DWITH_GPU=OFF \ -DWITH_STATIC_LIB=OFF \ -DUSE_TENSORRT=OFF \ -DOPENCV_DIR=${OPENCV_DIR} \ -DCUDNN_LIB=${CUDNN_LIB_DIR} \ -DCUDA_LIB=${CUDA_LIB_DIR} \ make -j ``` -------------------------------- ### Compile Paddle Lite Optimization Tool Source: https://github.com/mushroomcat9998/paddleocr/blob/main/deploy/lite/readme_en.md Compiles the Paddle Lite optimization tool from source code. This tool is essential for optimizing PaddlePaddle models. Ensure you have the Paddle-Lite repository cloned and are on the correct branch. ```shell git clone https://github.com/PaddlePaddle/Paddle-Lite.git cd Paddle-Lite git checkout release/v2.9 ./lite/tools/build.sh build_optimize_tool ``` -------------------------------- ### Install PaddleServing Server (GPU with CUDA/TensorRT) Source: https://github.com/mushroomcat9998/paddleocr/blob/main/deploy/pdserving/README.md Installs specific versions of the PaddleServing server for GPU environments with particular CUDA and TensorRT versions. Choose the command that matches your system configuration. ```bash pip3 install paddle-serving-server-gpu==0.6.1.post101 # GPU with CUDA10.1 + TensorRT6 ``` ```bash pip3 install paddle-serving-server-gpu==0.6.1.post11 # GPU with CUDA11 + TensorRT7 ``` -------------------------------- ### Quant-Aware Training for Detection Model Source: https://github.com/mushroomcat9998/paddleocr/blob/main/deploy/slim/quantization/README_en.md Performs quant-aware training for a detection model using a configuration file and a pre-trained model. It saves the quantized model to a specified directory. The example also shows how to download a provided model for quantization. ```bash python deploy/slim/quantization/quant.py -c configs/det/ch_ppocr_v2.0/ch_det_mv3_db_v2.0.yml -o Global.pretrained_model='your trained model' Global.save_model_dir=./output/quant_model # download provided model wget https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_det_train.tar tar -xf ch_ppocr_mobile_v2.0_det_train.tar python deploy/slim/quantization/quant.py -c configs/det/ch_ppocr_v2.0/ch_det_mv3_db_v2.0.yml -o Global.pretrained_model=./ch_ppocr_mobile_v2.0_det_train/best_accuracy Global.save_model_dir=./output/quant_model ``` -------------------------------- ### Generate Multi-language Configs using Script (Custom Parameters) Source: https://github.com/mushroomcat9998/paddleocr/blob/main/doc/doc_en/recognition_en.md This command generates a multi-language configuration file with custom parameters for training and validation datasets, data directories, and dictionary paths. It also allows overriding default parameters like GPU usage. The -l or --language parameter is mandatory. ```bash cd PaddleOCR/configs/rec/multi_language/ python3 generate_multi_language_configs.py -l it \ --train {path/of/train_label.txt} \ --val {path/of/val_label.txt} \ --data_dir {train_data/path} \ --dict {path/of/dict} \ -o Global.use_gpu=False \ ... ``` -------------------------------- ### Install Paddle Serving Server and App (Windows) Source: https://github.com/mushroomcat9998/paddleocr/blob/main/deploy/pdserving/README.md Installs the required Paddle Serving server and application components for Windows users. This specific version (0.5.0 CPU Mode) is recommended for Windows compatibility. ```shell pip3 install paddle-serving-server==0.5.0 pip3 install paddle-serving-app==0.3.1 ``` -------------------------------- ### Compile and Run PaddleOCR on Mobile via ADB Source: https://github.com/mushroomcat9998/paddleocr/blob/main/deploy/lite/readme_en.md Provides the shell commands to compile the PaddleOCR executable, push it to an Android phone using ADB, set environment variables, and run inference on a test image. ```shell # Execute the compilation and get the executable file ocr_db_crnn. # The first execution of this command will download dependent libraries such as opencv. After the download is complete, you need to execute it again make -j # Move the compiled executable file to the debug folder mv ocr_db_crnn ./debug/ # Push the debug folder to the phone adb push debug /data/local/tmp/ adb shell cd /data/local/tmp/debug export LD_LIBRARY_PATH=${PWD}:$LD_LIBRARY_PATH # The use of ocr_db_crnn is: # ./ocr_db_crnn Detection model file Orientation classifier model file Recognition model file Test image path Dictionary file path ./ocr_db_crnn ch_ppocr_mobile_v2.0_det_opt.nb ch_ppocr_mobile_v2.0_rec_opt.nb ch_ppocr_mobile_v2.0_cls_opt.nb ./11.jpg ppocr_keys_v1.txt ``` -------------------------------- ### Bash Command to Start PaddleServing OCR Service Source: https://context7.com/mushroomcat9998/paddleocr/llms.txt Command to start the PaddleServing OCR service. This script assumes the `web_service.py` file contains the OCR service implementation and makes it accessible on port 9998. ```bash # Start serving python web_service.py # Server startup output: # [PaddleServing] Starting OCR service on port 9998 # [PaddleServing] Detection model loaded # [PaddleServing] Recognition model loaded # [PaddleServing] Service ready at http://0.0.0.0:9998 ``` -------------------------------- ### Start, Resume, Evaluate, and Export Custom Detection Model Source: https://context7.com/mushroomcat9998/paddleocr/llms.txt Provides bash commands for managing the training and deployment of a custom text detection model. Includes starting training, resuming from a checkpoint, evaluating model performance, and exporting the model for inference. ```bash # Start training python tools/train.py -c configs/det/custom_det.yml # Resume training from checkpoint python tools/train.py -c configs/det/custom_det.yml \ -o Global.checkpoints=./output/custom_det/latest # Evaluate model python tools/eval.py -c configs/det/custom_det.yml \ -o Global.checkpoints=./output/custom_det/best_accuracy # Export to inference model python tools/export_model.py -c configs/det/custom_det.yml \ -o Global.pretrained_model=./output/custom_det/best_accuracy \ Global.save_inference_dir=./inference/custom_det # Expected training output: # [2024/01/15 10:23:45] epoch: [1/1200], iter: 10, loss: 2.3456, hmean: 0.6234 # [2024/01/15 10:24:12] epoch: [1/1200], iter: 20, loss: 2.1234, hmean: 0.6789 ```