export_lite.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve.
  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 paddlelite.lite as lite
  15. import os
  16. import argparse
  17. def export_lite():
  18. opt = lite.Opt()
  19. model_file = os.path.join(FLAGS.model_path, '__model__')
  20. params_file = os.path.join(FLAGS.model_path, '__params__')
  21. opt.run_optimize("", model_file, params_file, FLAGS.place, FLAGS.save_dir)
  22. if __name__ == '__main__':
  23. parser = argparse.ArgumentParser(description=__doc__)
  24. parser.add_argument(
  25. "--model_path",
  26. type=str,
  27. default="",
  28. help="model path.",
  29. required=True)
  30. parser.add_argument(
  31. "--place",
  32. type=str,
  33. default="arm",
  34. help="preprocess config path.",
  35. required=True)
  36. parser.add_argument(
  37. "--save_dir",
  38. type=str,
  39. default="paddlex.onnx",
  40. help="Directory for storing the output visualization files.",
  41. required=True)
  42. FLAGS = parser.parse_args()
  43. export_lite()