test_paddleocr_vl_genai-client.py 1.4 KB

12345678910111213141516171819202122232425262728293031
  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/流水分析/B用户_扫描流水/PaddleOCR_VL_Results/B用户_扫描流水/B用户_扫描流水_page_002.png"
  7. input_path = "/Users/zhch158/workspace/data/至远彩色印刷工业有限公司/2023年度报告母公司.img/2023年度报告母公司_page_003_270.png"
  8. pipeline_path = "./my_config/PaddleOCR-VL-Client_debug.yaml"
  9. pipeline_name = Path(pipeline_path).stem
  10. output_path = Path(f"./sample_data/single_pipeline_output/{pipeline_name}/")
  11. pipeline = create_pipeline(pipeline=pipeline_path)
  12. # For Image
  13. output = pipeline.predict(
  14. input=input_path,
  15. useLayoutDetection=False, # 开启版面分析
  16. useDocOrientationClassify=False, # 开启文档方向分类
  17. useDocUnwarping=False, # 开启文档去畸变
  18. prompt_label="table", # 指定识别类别的提示词
  19. )
  20. # 可视化结果并保存 json 结果
  21. for res in output:
  22. res.print()
  23. # res.save_to_json(save_path="sample_data/output")
  24. # res.save_to_markdown(save_path="sample_data/output")
  25. output_path.mkdir(parents=True, exist_ok=True)
  26. res.save_all(save_path=output_path.as_posix()) # 保存所有结果到指定路径