start_paddlex_with_adapter.py 1002 B

123456789101112131415161718192021222324252627282930313233
  1. #!/usr/bin/env python3
  2. """
  3. PaddleX 服务启动包装器 - 自动激活适配器
  4. """
  5. import os
  6. import sys
  7. import subprocess
  8. def main():
  9. # 🎯 在当前进程中激活适配器
  10. if os.getenv("PADDLEX_ENABLE_TABLE_ADAPTER", "").lower() in ("true", "1", "yes"):
  11. sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'adapters'))
  12. try:
  13. from adapters import apply_table_recognition_adapter
  14. if apply_table_recognition_adapter():
  15. print("✅ Adapter activated in wrapper process")
  16. except Exception as e:
  17. print(f"⚠️ Failed to activate adapter: {e}")
  18. # 🎯 解析命令行参数
  19. args = sys.argv[1:] # 去掉脚本名
  20. # 🎯 导入 PaddleX CLI 主函数并在当前进程执行
  21. from paddlex.paddlex_cli import main as paddlex_main
  22. # 替换 sys.argv 以传递参数
  23. sys.argv = ['paddlex'] + args
  24. # 执行 PaddleX
  25. paddlex_main()
  26. if __name__ == "__main__":
  27. main()