test_evaluator.py 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. import sys
  15. import os
  16. from paddlex.engine import Engine
  17. # 设置环境变量
  18. # os.environ["PADDLE_PDX_PADDLEOCR_PATH"] = "/Users/zhch158/workspace/repository.git/PaddleX/paddle_env/lib/python3.11/site-packages/paddleocr"
  19. # 添加PaddleX路径
  20. # sys.path.insert(0, '/Users/zhch158/workspace/repository.git/PaddleX')
  21. def force_import_registrations():
  22. """强制导入所有注册模块"""
  23. try:
  24. # 强制导入注册模块
  25. import paddlex.repo_apis.PaddleOCR_api.table_rec.register
  26. import paddlex.repo_apis.PaddleOCR_api.text_rec.register
  27. import paddlex.repo_apis.PaddleOCR_api.text_det.register
  28. import paddlex.repo_apis.PaddleOCR_api.formula_rec.register
  29. # import paddlex.repo_apis.PaddleOCR_api.textline_orientation.register
  30. # import paddlex.repo_apis.PaddleOCR_api.doc_text_orientation.register
  31. print("✓ 所有注册模块导入成功")
  32. # 检查注册状态
  33. from paddlex.repo_apis.base.register import MODEL_INFO_REGISTRY
  34. table_models = [name for name in MODEL_INFO_REGISTRY._table.keys()
  35. if 'SLA' in name]
  36. print(f"已注册的表格模型: {table_models}")
  37. if 'SLANet_plus' in MODEL_INFO_REGISTRY._table:
  38. print("✓ SLANet_plus 已成功注册")
  39. return True
  40. else:
  41. print("✗ SLANet_plus 仍未注册")
  42. return False
  43. except Exception as e:
  44. print(f"注册模块导入失败: {e}")
  45. return False
  46. if __name__ == "__main__":
  47. # if force_import_registrations():
  48. # # 现在运行引擎
  49. # from paddlex.engine import Engine
  50. # print("开始运行...")
  51. # Engine().run()
  52. # else:
  53. # print("注册失败,无法继续")
  54. Engine().run()