1234567891011121314151617181920212223242526272829 |
- import os
- import time
- import requests
- class swap_face():
- def __init__(self, imgurl):
- self.imgurl = imgurl
- def run(self):
- name_hash = str(time.time()).replace('.','')
- src_img = 'FaceSwap/src_img/'+name_hash+'.jpg'
- sv_path = '../html/swap_save'+name_hash+'.avi'
- im = Image.open(requests.get(self.imgurl, stream=True).raw)
- im= im.convert("RGB")
- im.save(src_img)
- try:
- return 'asd'
- except:
- return '圖片錯誤'
-
- os.system('python3 FaceSwap/main_video.py --src_img '+src_img+' --video_path nina_noGesture_adj.mp4 --correct_color --save_path '+sv_path)
- while True:
- print('waiting...')
- if os.path.exists(sv_path):
- break
- time.sleep(5)
- print('waiting...')
- return "人物生成完成 at : www.choozmo.com:8168/swap_save/"+name_hash+".avi"
-
|