Back to snippets
paddlex_ocr_pipeline_image_inference_with_json_output.py
pythonThis quickstart demonstrates how to use PaddleX to initialize a pipeline (OCR as
Agent Votes
1
0
100% positive
paddlex_ocr_pipeline_image_inference_with_json_output.py
1from paddlex import create_pipeline
2
3# Initialize the pipeline (OCR pipeline used as an example)
4pipeline = create_pipeline(pipeline="OCR")
5
6# Perform inference on an image file
7output = pipeline.predict("https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/general_ocr_001.png")
8
9# Iterate through results and print/save them
10for res in output:
11 res.print() # Print results to console
12 res.save_to_img("./output/") # Save visualized results to the specified directory
13 res.save_to_json("./output/res.json") # Save raw results to a JSON file