### Complete Deployment Steps Example Source: https://github.com/paddlepaddle/paddlex/blob/release/3.7/docs/practical_tutorials/deployment_tutorial.en.md A consolidated example showing the sequence of commands to install the service, start the OCR service, and then call it using a Python script. ```bash # Install the service deployment plugin paddlex --install serving # Start the service paddlex --serve --pipeline OCR # Call the service | The code in fast_test.py is a Python calling example from the previous section wget https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/general_ocr_002.png -O demo.jpg python fast_test.py ``` -------------------------------- ### Server Startup Output Example Source: https://github.com/paddlepaddle/paddlex/blob/release/3.7/docs/pipeline_deploy/serving.en.md Example output observed when the PaddleX serving server starts successfully, indicating the GRPC, HTTP, and Metrics services are running. ```text I1216 11:37:21.601943 35 grpc_server.cc:4117] Started GRPCInferenceService at 0.0.0.0:8001 I1216 11:37:21.602333 35 http_server.cc:2815] Started HTTPService at 0.0.0.0:8000 I1216 11:37:21.643494 35 http_server.cc:167] Started Metrics Service at 0.0.0.0:8002 ``` -------------------------------- ### Full Deployment Steps Source: https://github.com/paddlepaddle/paddlex/blob/release/3.7/docs/practical_tutorials/deployment_tutorial.md A consolidated list of commands to install the serving plugin, start the service, and invoke it. This provides a quick end-to-end deployment workflow. ```bash # 安装服务化部署插件 paddlex --install serving # 启动服务 paddlex --serve --pipeline OCR # 调用服务 | fast_test.py 中代码为上一节的 Python 调用示例 wget https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/general_ocr_002.png -O demo.jpg python fast_test.py ``` -------------------------------- ### Quick Start Instance Segmentation Pipeline Source: https://github.com/paddlepaddle/paddlex/blob/release/3.7/docs/practical_tutorials/instance_segmentation_remote_sensing_tutorial.en.md Initiates a quick trial of the instance segmentation pipeline using a specified input image. Ensure PaddleX is installed and accessible in your environment. ```bash paddlex --pipeline instance_segmentation \ --input https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/remotesensing_demo.png ``` -------------------------------- ### PaddleOCR-VL Server Startup Information Source: https://github.com/paddlepaddle/paddlex/blob/release/3.7/docs/pipeline_usage/tutorials/ocr_pipelines/PaddleOCR-VL.en.md Example output indicating that the PaddleOCR-VL server has started successfully and is listening on a specific address and port. ```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) ``` -------------------------------- ### Install Serving Plugin Source: https://github.com/paddlepaddle/paddlex/blob/release/3.7/docs/pipeline_deploy/serving.en.md Install the serving plugin using the paddlex CLI. ```bash paddlex --install serving ``` -------------------------------- ### Install Ascend Initialization Script Source: https://github.com/paddlepaddle/paddlex/blob/release/3.7/deploy/ultra-infer/CMakeLists.txt Installs the ascend_init.sh script to the installation prefix if WITH_ASCEND is enabled. ```cmake if(WITH_ASCEND) install( FILES ${PROJECT_SOURCE_DIR}/scripts/ascend_init.sh DESTINATION ${CMAKE_INSTALL_PREFIX} ) endif() ``` -------------------------------- ### Install Project License and Configuration Files Source: https://github.com/paddlepaddle/paddlex/blob/release/3.7/deploy/ultra-infer/CMakeLists.txt Installs project license, version, and CMake configuration files to the installation prefix. ```cmake install( FILES ${PROJECT_SOURCE_DIR}/LICENSE ${PROJECT_SOURCE_DIR}/ThirdPartyNotices.txt ${PROJECT_SOURCE_DIR}/VERSION_NUMBER ${PROJECT_SOURCE_DIR}/UltraInfer.cmake ${PROJECT_SOURCE_DIR}/UltraInferCSharp.cmake ${PROJECT_SOURCE_DIR}/cmake/UltraInferConfig.cmake ${PROJECT_SOURCE_DIR}/cmake/utils.cmake ${PROJECT_SOURCE_DIR}/cmake/summary.cmake DESTINATION ${CMAKE_INSTALL_PREFIX} ) ``` -------------------------------- ### Install Initialization Script (Non-Windows) Source: https://github.com/paddlepaddle/paddlex/blob/release/3.7/deploy/ultra-infer/CMakeLists.txt Installs the ultra_infer_init.sh script to the installation prefix on non-Windows systems. ```cmake if(NOT WIN32) install( FILES ${PROJECT_SOURCE_DIR}/scripts/ultra_infer_init.sh DESTINATION ${CMAKE_INSTALL_PREFIX} ) else() install( FILES ${PROJECT_SOURCE_DIR}/scripts/ultra_infer_init.bat DESTINATION ${CMAKE_INSTALL_PREFIX} ) endif() ``` -------------------------------- ### Install All PaddleX Plugins Source: https://github.com/paddlepaddle/paddlex/blob/release/3.7/docs/installation/installation.en.md Installs all available PaddleX plugins. This is a convenient option when all functionalities are needed. ```bash paddlex --install ``` -------------------------------- ### Start Service with OCR Pipeline Source: https://github.com/paddlepaddle/paddlex/blob/release/3.7/docs/practical_tutorials/deployment_tutorial.md Start a service using the PaddleX CLI with a specified pipeline. This example uses the general OCR pipeline. ```bash paddlex --serve --pipeline OCR ``` -------------------------------- ### Install PaddleX with Base Dependencies Source: https://github.com/paddlepaddle/paddlex/blob/release/3.7/docs/installation/installation.en.md Installs the PaddleX wheel package along with essential dependencies for basic features. Use this for a more complete setup. ```bash pip install "paddlex[base]" ``` -------------------------------- ### Include Examples Subdirectory Source: https://github.com/paddlepaddle/paddlex/blob/release/3.7/deploy/ultra-infer/CMakeLists.txt Includes the examples subdirectory if BUILD_EXAMPLES is enabled and the directory exists. Sets executable output path if necessary. ```cmake if(BUILD_EXAMPLES AND EXISTS ${PROJECT_SOURCE_DIR}/examples) add_definitions(-DBUILD_EXAMPLES) if(NOT EXECUTABLE_OUTPUT_PATH STREQUAL ${CMAKE_CURRENT_BINARY_DIR}/bin) set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/bin) endif() include(${PROJECT_SOURCE_DIR}/cmake/gflags.cmake) add_subdirectory(examples) endif() ``` -------------------------------- ### Start Service with Object Detection Pipeline Source: https://github.com/paddlepaddle/paddlex/blob/release/3.7/docs/practical_tutorials/deployment_tutorial.md Demonstrates starting a service with a different pipeline, specifically the general object detection pipeline. This shows flexibility in choosing deployment targets. ```bash paddlex --serve --pipeline object_detection ``` -------------------------------- ### Get PaddleOCR-VL Pipeline Configuration Source: https://github.com/paddlepaddle/paddlex/blob/release/3.7/docs/pipeline_usage/tutorials/ocr_pipelines/PaddleOCR-VL.en.md Obtain the default pipeline configuration file for PaddleOCR-VL. This file will need to be modified to match your service setup. ```bash paddlex --get_pipeline_config PaddleOCR-VL-1.6 ``` -------------------------------- ### Run Basic Serving Server Source: https://github.com/paddlepaddle/paddlex/blob/release/3.7/docs/pipeline_deploy/serving.en.md Start the serving server using the paddlex CLI, specifying the pipeline name or configuration file path. ```bash paddlex --serve --pipeline {pipeline name or path to pipeline config file} [{other commandline options}] ``` -------------------------------- ### Instance Segmentation Command Line Example Source: https://github.com/paddlepaddle/paddlex/blob/release/3.7/docs/index.en.md Run instance segmentation by specifying the pipeline, input, threshold, save path, and device. ```bash paddlex --pipeline instance_segmentation \ --input https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/general_instance_segmentation_004.png \ --threshold 0.5 \ --save_path ./output \ --device gpu:0 ``` -------------------------------- ### Download Vehicle Attribute Demo Dataset Source: https://github.com/paddlepaddle/paddlex/blob/release/3.7/docs/module_usage/tutorials/cv_modules/vehicle_attribute_recognition.en.md Use this command to download the demo dataset for vehicle attribute recognition examples to a specified folder. Ensure you have `wget` installed. ```bash wget https://paddle-model-ecology.bj.bcebos.com/paddlex/data/vehicle_attribute_examples.tar -P ./dataset tar -xf ./dataset/vehicle_attribute_examples.tar -C ./dataset/ ``` -------------------------------- ### Acquire Example Dataset Source: https://github.com/paddlepaddle/paddlex/blob/release/3.7/docs/practical_tutorials/document_scene_information_extraction(layout_detection)_tutorial.en.md Use these bash commands to download and extract the example 'paperlayout' dataset for layout detection tasks. ```bash cd /path/to/paddlex wget https://paddle-model-ecology.bj.bcebos.com/paddlex/data/paperlayout.tar -P ./dataset tar -xf ./dataset/paperlayout.tar -C ./dataset/ ``` -------------------------------- ### PHP: Video Classification API Setup Source: https://github.com/paddlepaddle/paddlex/blob/release/3.7/docs/pipeline_usage/tutorials/video_pipelines/video_classification.en.md This PHP code snippet initializes the API URL and video path for video classification. It serves as a starting point for making API calls. ```php #include #include #include #include "cpp-httplib/httplib.h" // https://github.com/Huiyicc/cpp-httplib #include "nlohmann/json.hpp" // https://github.com/nlohmann/json #include "base64.hpp" // https://github.com/tobiaslocker/base64 int main() { httplib::Client client("localhost", 8080); const std::string filePath = "./demo.jpg"; std::ifstream file(filePath, std::ios::binary | std::ios::ate); if (!file) { std::cerr << "Error opening file: " << filePath << std::endl; return 1; } std::streamsize size = file.tellg(); file.seekg(0, std::ios::beg); std::vector buffer(size); if (!file.read(buffer.data(), size)) { std::cerr << "Error reading file." << std::endl; return 1; } std::string bufferStr(buffer.data(), static_cast(size)); std::string encodedFile = base64::to_base64(bufferStr); nlohmann::json jsonObj; jsonObj["file"] = encodedFile; jsonObj["fileType"] = 1; auto response = client.Post("/formula-recognition", jsonObj.dump(), "application/json"); if (response && response->status == 200) { nlohmann::json jsonResponse = nlohmann::json::parse(response->body); auto result = jsonResponse["result"]; if (!result.is_object() || !result["formulaRecResults"].is_array()) { std::cerr << "Unexpected response format." << std::endl; return 1; } for (size_t i = 0; i < result["formulaRecResults"].size(); ++i) { auto res = result["formulaRecResults"][i]; if (res.contains("prunedResult")) { std::cout << "Recognized formula: " << res["prunedResult"].dump() << std::endl; } if (res.contains("outputImages") && res["outputImages"].is_object()) { for (auto& [imgName, imgData] : res["outputImages"].items()) { std::string outputPath = imgName + "_" + std::to_string(i) + ".jpg"; std::string decodedImage = base64::from_base64(imgData.get()); ``` -------------------------------- ### Face Detection Inference with PaddleX Source: https://github.com/paddlepaddle/paddlex/blob/release/3.7/docs/module_usage/tutorials/cv_modules/face_detection.en.md Perform face detection inference on an image using a pre-trained model. This snippet demonstrates model creation, prediction, and saving results to an image and JSON file. Ensure you have downloaded the example image and installed the PaddleX wheel package. ```python from paddlex import create_model model_name = "PicoDet_LCNet_x2_5_face" model = create_model(model_name) output = model.predict("face_detection.png", batch_size=1) for res in output: res.print(json_format=False) res.save_to_img("./output/") res.save_to_json("./output/res.json") ``` -------------------------------- ### Download Demo Dataset for Layout Analysis Source: https://github.com/paddlepaddle/paddlex/blob/release/3.7/docs/module_usage/tutorials/ocr_modules/layout_analysis.en.md Use these commands to download the demo dataset for layout analysis to a specified folder. Ensure you are in the correct directory before executing. ```bash cd /path/to/paddlex wget https://paddle-model-ecology.bj.bcebos.com/paddlex/data/doclayoutv3_examples.tar -P ./dataset tar -xf ./dataset/doclayoutv3_examples.tar -C ./dataset/ ``` -------------------------------- ### Download Demo Dataset Source: https://github.com/paddlepaddle/paddlex/blob/release/3.7/docs/module_usage/tutorials/cv_modules/small_object_detection.md Use this command to download the demo dataset for small object detection examples. Ensure you are in the correct directory before executing. ```bash cd /path/to/paddlex wget https://paddle-model-ecology.bj.bcebos.com/paddlex/data/small_det_examples.tar -P ./dataset tar -xf ./dataset/small_det_examples.tar -C ./dataset/ ``` -------------------------------- ### Run Layout Parsing Pipeline via Command Line Source: https://github.com/paddlepaddle/paddlex/blob/release/3.7/docs/pipeline_usage/tutorials/ocr_pipelines/layout_parsing.md Execute the layout parsing pipeline using the command line. Ensure PaddleX is installed and specify input, output paths, and model configurations. This example uses a sample image and disables document orientation and unwarping. ```bash paddlex --pipeline layout_parsing \ --input layout_parsing_demo.png \ --use_doc_orientation_classify False \ --use_doc_unwarping False \ --use_textline_orientation False \ --save_path ./output \ --device gpu:0 ``` -------------------------------- ### Table Cell Detection Inference Source: https://github.com/paddlepaddle/paddlex/blob/release/3.7/docs/module_usage/tutorials/ocr_modules/table_cells_detection.en.md This snippet demonstrates how to load a pre-trained table cell detection model and perform inference on an image. It shows how to print the results, save them to an image, and save them to a JSON file. Ensure you have the PaddleX wheel package installed and the example image downloaded. ```python from paddlex import create_model model = create_model(model_name="RT-DETR-L_wired_table_cell_det") output = model.predict("table_recognition.jpg", threshold=0.3, batch_size=1) for res in output: res.print(json_format=False) res.save_to_img("./output/") res.save_to_json("./output/res.json") ``` -------------------------------- ### Create and Run Instance Segmentation Pipeline in Python Source: https://github.com/paddlepaddle/paddlex/blob/release/3.7/docs/pipeline_usage/tutorials/cv_pipelines/instance_segmentation.en.md Demonstrates how to create an instance segmentation pipeline using a custom configuration file and perform predictions on an image. It shows how to iterate through results, print them, and save them to files. ```python from paddlex import create_pipeline pipeline = create_pipeline(pipeline="./my_path/instance_segmentation.yaml") output = pipeline.predict( input="./general_instance_segmentation_004.png", threshold=0.5, ) for res in output: res.print() res.save_to_img("./output/") res.save_to_json("./output/") ``` -------------------------------- ### Verify PaddlePaddle Installation Source: https://github.com/paddlepaddle/paddlex/blob/release/3.7/docs/installation/paddlepaddle_install.md Run this command after installation to verify if PaddlePaddle is installed successfully and to check the installed version. ```bash python -c "import paddle; print(paddle.__version__)" ``` -------------------------------- ### Download Demo Dataset Source: https://github.com/paddlepaddle/paddlex/blob/release/3.7/docs/module_usage/tutorials/cv_modules/image_feature.en.md Use this command to download the example dataset for the Image Feature module to a specified directory. ```bash wget https://paddle-model-ecology.bj.bcebos.com/paddlex/data/Inshop_examples.tar -P ./dataset tar -xf ./dataset/Inshop_examples.tar -C ./dataset/ ``` -------------------------------- ### Download Example Dataset Source: https://github.com/paddlepaddle/paddlex/blob/release/3.7/docs/practical_tutorials/face_recognition_tutorial.md Use this command to download the cartoon face detection dataset for the tutorial. Ensure you are in the PaddleX project directory. ```bash cd /path/to/paddlex wget https://paddle-model-ecology.bj.bcebos.com/paddlex/data/cartoonface_coco_examples.tar -P ./dataset tar -xf ./dataset/cartoonface_coco_examples.tar -C ./dataset/ ```