test_paddleocr_vl_genai-client.py 1.2 KB

1234567891011121314151617181920212223242526272829
  1. from paddlex import create_pipeline
  2. import time
  3. from pathlib import Path
  4. # input_path = "./sample_data/300674-母公司现金流量表-扫描.png"
  5. # input_path = "/home/ubuntu/zhch/data/至远彩色印刷工业有限公司/2023年度报告母公司.img/2023年度报告母公司_page_006.png"
  6. input_path = "/Users/zhch158/workspace/data/至远彩色印刷工业有限公司/PaddleOCR_VL_Results/2023年度报告母公司/2023年度报告母公司_page_003.png"
  7. pipeline_path = "./my_config/PaddleOCR-VL-Client.yaml"
  8. pipeline_name = Path(pipeline_path).stem
  9. output_path = Path(f"./sample_data/single_pipeline_output/{pipeline_name}/")
  10. pipeline = create_pipeline(pipeline=pipeline_path)
  11. # For Image
  12. output = pipeline.predict(
  13. input=input_path,
  14. useLayoutDetection=False, # 开启版面分析
  15. useDocOrientationClassify=False, # 开启文档方向分类
  16. useDocUnwarping=False, # 开启文档去畸变
  17. )
  18. # 可视化结果并保存 json 结果
  19. for res in output:
  20. res.print()
  21. # res.save_to_json(save_path="sample_data/output")
  22. # res.save_to_markdown(save_path="sample_data/output")
  23. output_path.mkdir(parents=True, exist_ok=True)
  24. res.save_all(save_path=output_path.as_posix()) # 保存所有结果到指定路径