File size: 959 Bytes
21f0a5b
 
 
 
 
 
 
 
16c68ef
 
 
 
 
21f0a5b
16c68ef
21f0a5b
16c68ef
21f0a5b
 
 
 
16c68ef
21f0a5b
 
 
16c68ef
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
import gradio as gr
import subprocess
import shutil
import os

def run_scripts(target, source, use_face_enhancer):
    if target is None or (not use_face_enhancer and source is None):
        return None
    outputfile=[]
    for target_file in target :
        target_extension = os.path.splitext(target.name)[-1]
        output_path1 = "output1" + target_extension
        cmd1 = ["python3", "run.py", "-s", source.name, "-t", target.name, "-o", output_path1, "--frame-processor", "face_swapper","face_enhancer"]
        subprocess.run(cmd1)
        outputfile.append(output_path1)

    return outputfile

iface = gr.Interface(
    fn=run_scripts,
    inputs=[
        "files",
        "file",
        gr.inputs.Checkbox(default=False, label="Use only Face Enhancer")  # New checkbox input
    ],
    outputs="files",
    title="Face swapper",
    description="Upload a target image/video and a source image to swap faces.",
    live=True
)

iface.launch()