test_layout_parsing.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. # Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. from paddlex import create_pipeline
  15. pipeline = create_pipeline(pipeline="layout_parsing")
  16. output = pipeline.predict(
  17. "./test_samples/demo_paper.png",
  18. use_doc_orientation_classify=False,
  19. use_doc_unwarping=False,
  20. use_common_ocr=True,
  21. use_seal_recognition=True,
  22. use_table_recognition=True,
  23. )
  24. # output = pipeline.predict(
  25. # "./test_samples/layout.jpg",
  26. # use_doc_orientation_classify=False,
  27. # use_doc_unwarping=False,
  28. # use_common_ocr=True,
  29. # use_seal_recognition=True,
  30. # use_table_recognition=True,
  31. # )
  32. # output = pipeline.predict(
  33. # "./test_samples/test_layout_parsing.jpg",
  34. # use_doc_orientation_classify=True,
  35. # use_doc_unwarping=True,
  36. # use_common_ocr=True,
  37. # use_seal_recognition=True,
  38. # use_table_recognition=True,
  39. # )
  40. # output = pipeline.predict(
  41. # "./test_samples/财报1.pdf",
  42. # use_doc_orientation_classify=False,
  43. # use_doc_unwarping=False,
  44. # use_common_ocr=True,
  45. # use_seal_recognition=True,
  46. # use_table_recognition=True,
  47. # )
  48. # output = pipeline.predict(
  49. # "./test_samples/layout_double_column.png",
  50. # use_doc_orientation_classify=False,
  51. # use_doc_unwarping=False,
  52. # use_common_ocr=True,
  53. # use_seal_recognition=True,
  54. # use_table_recognition=True,
  55. # )
  56. for res in output:
  57. res.print()
  58. res.save_to_img("./output")
  59. res.save_to_json("./output")
  60. res.save_to_xlsx("./output")
  61. res.save_to_html("./output")