File size: 961 Bytes
21f0a5b 52dcdf4 21f0a5b 16c68ef 92b2d0f 8c405bb 52dcdf4 3ec3d92 21f0a5b 16c68ef 21f0a5b 16c68ef 21f0a5b 16c68ef 550a8ef 21f0a5b 16c68ef 21f0a5b 0c93b15 21f0a5b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
import gradio as gr
import subprocess
import shutil
import os
from datetime import datetime
def run_scripts(target, source, use_face_enhancer):
outputfile=[]
for target_file in target :
target_extension = os.path.splitext(target_file.name)[-1]
target_name = os.path.splitext(target_file.name)[1]
timestamp = datetime.now().strftime("%Y%m%d%H%M%S")
output_path1 = "output" + timestamp + target_extension
cmd1 = ["python3", "run.py", "-s", source.name, "-t", target_file.name, "-o", output_path1, "--frame-processor", "face_swapper","face_enhancer",'--many-faces']
subprocess.run(cmd1)
outputfile.append(output_path1)
return outputfile
iface = gr.Interface(
fn=run_scripts,
inputs=[
"files",
"file"
],
outputs="files",
title="Face swapper",
description="Upload a target image/video and a source image to swap faces.",
live=False
)
iface.launch()
|