main.py 918 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. import argparse
  2. import os
  3. import tools
  4. import api
  5. from app import app
  6. cur_dirs = os.path.abspath(os.path.dirname(__file__))
  7. save_dir = os.path.join(cur_dirs, 'outputs')
  8. upload_dir = os.path.join(cur_dirs, "uploads")
  9. app.config['UPLOAD_FOLDER'] = upload_dir
  10. def init():
  11. if os.path.exists(upload_dir) is False:
  12. os.makedirs(upload_dir)
  13. api.set_options(upload_dir, save_dir)
  14. def parse_args():
  15. parser = argparse.ArgumentParser(
  16. description='PP-HumanSeg inference for video')
  17. parser.add_argument(
  18. "--production",
  19. dest="production",
  20. help="production mode",
  21. action="store_true",
  22. required=False)
  23. return parser.parse_args()
  24. if __name__ == '__main__':
  25. args = parse_args()
  26. print("args: {}".format(args))
  27. init()
  28. tools.load_model()
  29. debug = False if args.production else True
  30. app.run(port=20201, host="0.0.0.0", debug=debug)