|
@@ -51,10 +51,13 @@ app.mount("/static", StaticFiles(directory="static"), name="static")
|
|
|
app.mount("/static/img", StaticFiles(directory="static/img"), name="static/img")
|
|
|
|
|
|
tmp_video_dir = '../OpenshotService/tmp_video/'
|
|
|
+tmp_avatar_dir = '../face_swap/tmp_avatar/'
|
|
|
video_sub_folder = 'ai_anchor_video/'
|
|
|
+avatar_sub_folder = 'swap_save/'
|
|
|
tmp_img_sub_folder = 'tmp_img/'
|
|
|
img_upload_folder = '/var/www/html/'+tmp_img_sub_folder
|
|
|
video_dest = '/var/www/html/'+video_sub_folder
|
|
|
+avatar_dest = '/var/www/html/'+avatar_sub_folder
|
|
|
|
|
|
class swap_req(BaseModel):
|
|
|
imgurl: str
|
|
@@ -72,16 +75,16 @@ async def index2():
|
|
|
return FileResponse('static/index2.html')
|
|
|
|
|
|
@app.get("/gen_avatar")
|
|
|
-async def gen_avatar():
|
|
|
+async def avatar():
|
|
|
return FileResponse('static/gen_avatar.html')
|
|
|
-
|
|
|
+'''
|
|
|
@app.post("/swapFace")
|
|
|
async def swapFace(req:swap_req):
|
|
|
sf = swap_face(req.imgurl)
|
|
|
result = sf.run()
|
|
|
#notify_group(result)hi
|
|
|
return result
|
|
|
-
|
|
|
+'''
|
|
|
@app.post("/uploadfile/")
|
|
|
async def create_upload_file(file: UploadFile = File(...)):
|
|
|
img_name = str(time.time()).replace('.','')
|
|
@@ -159,3 +162,13 @@ def gen_video(name_hash,name,text_content, image_urls,avatar,client_id):
|
|
|
shutil.copy(tmp_video_dir+name_hash+'.mp4',video_dest+name_hash+'.mp4')
|
|
|
os.remove(tmp_video_dir+name_hash+'.mp4')
|
|
|
|
|
|
+
|
|
|
+def gen_avatar():
|
|
|
+ c = rpyc.connect("localhost", 8868)
|
|
|
+ c._config['sync_request_timeout'] = None
|
|
|
+ remote_svc = c.root
|
|
|
+ my_answer = remote_svc.call_avatar(name_hash,name,text_content, image_urls,avatar,client_id) # method call
|
|
|
+
|
|
|
+ shutil.copy(tmp_video_dir+name_hash+'.mp4',video_dest+name_hash+'.mp4')
|
|
|
+ os.remove(tmp_video_dir+name_hash+'.mp4')
|
|
|
+
|