ソースを参照

add swap face test

ming 3 年 前
コミット
5cf1317ff5
2 ファイル変更7 行追加3 行削除
  1. 5 3
      main.py
  2. 2 0
      util/swap_face.py

+ 5 - 3
main.py

@@ -111,11 +111,13 @@ async def progress_page():
 
 @app.post("/swapFace")
 async def swapFace(req:swap_req):
-    sf = swap_face(req.imgurl)
+    x = threading.Thread(target=runswap, args=(req.imgurl))
+    x.start()
+    return {'msg':'ok'}
+def runswap(imgurl):
+    sf = swap_face(imgurl)
     result = sf.run()
     #notify_group(result)
-    print(result)
-    
 
 @app.post("/make_anchor_video_v2")
 async def make_anchor_video_v2(req:request):

+ 2 - 0
util/swap_face.py

@@ -2,6 +2,7 @@ import os
 import time
 import requests
 from PIL import Image
+import threading
 class swap_face():
     def __init__(self, imgurl):
         self.imgurl = imgurl
@@ -27,4 +28,5 @@ class swap_face():
             print('waiting...')
 
         return "人物生成完成 at : www.choozmo.com:8168/swap_save/"+name_hash+".avi"
+