PaddleX

3.4.3 · active · verified Sat Apr 11

PaddleX is a low-code development tool built on the PaddlePaddle deep learning framework. It integrates numerous ready-to-use pre-trained models, facilitating full-process AI development from model training to inference. Supporting various mainstream hardware, PaddleX aims to assist AI developers in industrial practice. The current version is 3.4.3, with an active release cadence.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize an OCR pipeline and perform inference on an image URL using the `create_pipeline` function and its `predict` method. The example uses a public image URL, but local file paths are also supported.

import os
from paddlex import create_pipeline

# Example for OCR pipeline
# Note: This quickstart assumes PaddlePaddle and necessary OCR dependencies are installed.
# You can replace 'OCR' with other supported pipeline names (e.g., 'GeneralInstanceSegmentation', 'ImageMultiLabelClassification').
# The 'input' can be a local path, directory, or URL to an image.
# For a real-world scenario, you might download an image or use a local file.
image_url = "https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/general_ocr_002.png"

try:
    # Create an OCR pipeline instance
    pipeline = create_pipeline(pipeline="OCR")
    print("OCR pipeline created successfully.")

    # Predict using the pipeline
    # The 'predict' method returns a dictionary of results.
    output = pipeline.predict(image_url)

    # Print the prediction results
    print("Prediction successful. Output:")
    print(output)

except Exception as e:
    print(f"An error occurred: {e}")
    print("Please ensure PaddlePaddle is installed and compatible, and relevant PaddleX dependencies (e.g., 'paddlex[ocr]') are installed.")

view raw JSON →