Update app.py
Browse files
app.py
CHANGED
@@ -6,33 +6,24 @@ import os
|
|
6 |
def run_scripts(target, source, use_face_enhancer):
|
7 |
if target is None or (not use_face_enhancer and source is None):
|
8 |
return None
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
# Run both scripts
|
15 |
-
cmd1 = ["python3", "run.py", "-s", source.name, "-t", target.name, "-o", output_path1, "--frame-processor", "face_swapper"]
|
16 |
subprocess.run(cmd1)
|
|
|
17 |
|
18 |
-
|
19 |
-
cmd2 = ["python3", "run.py", "-t", target.name if use_face_enhancer else output_path1, "-o", output_path2, "--frame-processor", "face_enhancer"]
|
20 |
-
subprocess.run(cmd2)
|
21 |
-
|
22 |
-
if not use_face_enhancer:
|
23 |
-
os.remove(source.name)
|
24 |
-
os.remove(target.name)
|
25 |
-
|
26 |
-
return output_path2
|
27 |
|
28 |
iface = gr.Interface(
|
29 |
fn=run_scripts,
|
30 |
inputs=[
|
31 |
-
"
|
32 |
"file",
|
33 |
gr.inputs.Checkbox(default=False, label="Use only Face Enhancer") # New checkbox input
|
34 |
],
|
35 |
-
outputs="
|
36 |
title="Face swapper",
|
37 |
description="Upload a target image/video and a source image to swap faces.",
|
38 |
live=True
|
|
|
6 |
def run_scripts(target, source, use_face_enhancer):
|
7 |
if target is None or (not use_face_enhancer and source is None):
|
8 |
return None
|
9 |
+
outputfile=[]
|
10 |
+
for target_file in target :
|
11 |
+
target_extension = os.path.splitext(target.name)[-1]
|
12 |
+
output_path1 = "output1" + target_extension
|
13 |
+
cmd1 = ["python3", "run.py", "-s", source.name, "-t", target.name, "-o", output_path1, "--frame-processor", "face_swapper","face_enhancer"]
|
|
|
|
|
14 |
subprocess.run(cmd1)
|
15 |
+
outputfile.append(output_path1)
|
16 |
|
17 |
+
return outputfile
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
iface = gr.Interface(
|
20 |
fn=run_scripts,
|
21 |
inputs=[
|
22 |
+
"files",
|
23 |
"file",
|
24 |
gr.inputs.Checkbox(default=False, label="Use only Face Enhancer") # New checkbox input
|
25 |
],
|
26 |
+
outputs="files",
|
27 |
title="Face swapper",
|
28 |
description="Upload a target image/video and a source image to swap faces.",
|
29 |
live=True
|