tuon 1 年之前
父节点
当前提交
ea9fc3f11f
共有 3 个文件被更改,包括 13 次插入11 次删除
  1. 5 3
      api/image.py
  2. 7 7
      main.py
  3. 1 1
      start.sh

+ 5 - 3
api/image.py

@@ -38,10 +38,12 @@ def replace():
         return jsonify(error_resp("请选择需要替换的背景!"))
 
     img_path = get_upload_file_path(form.file_id.data)
+    bg_path = form.background.data
 
-    bg_path = get_upload_file_path(form.bg_file_id.data)
-    if os.path.exists(bg_path) is False:
-        bg_path = form.background.data
+    if is_empty(form.bg_file_id.data) is False:
+        bg_path = get_upload_file_path(form.bg_file_id.data)
+        if os.path.exists(bg_path):
+            bg_path = form.background.data
 
     result = tools.replace(img_path=img_path, background=bg_path, save_dir=get_output_dir())
 

+ 7 - 7
main.py

@@ -1,6 +1,5 @@
 import argparse
 import os
-import sys
 import tools
 import api
 from app import app
@@ -22,17 +21,18 @@ def parse_args():
     parser = argparse.ArgumentParser(
         description='PP-HumanSeg inference for video')
     parser.add_argument(
-        "--debug",
-        dest="debug",
-        help="debug mode",
-        default=True,
-        type=bool,
+        "--production",
+        dest="production",
+        help="production mode",
+        action="store_true",
         required=False)
     return parser.parse_args()
 
 
 if __name__ == '__main__':
     args = parse_args()
+    print("args: {}".format(args))
     init()
     tools.load_model()
-    app.run(port=20201, host="0.0.0.0", debug=args.debug)
+    debug = False if args.production else True
+    app.run(port=20201, host="0.0.0.0", debug=debug)

+ 1 - 1
start.sh

@@ -3,4 +3,4 @@ pid=$(ps -elf | grep $(pwd) | grep -v grep | awk '{print $4}')
 if [ "$pid"x != ""x ]; then
     kill -9 $pid
 fi
-nohup python main.py --debug=false &
+nohup python main.py --production &