Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
import
|
2 |
import subprocess
|
3 |
import shutil
|
4 |
import os
|
@@ -6,12 +6,13 @@ 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 |
target_extension = os.path.splitext(target.name)[-1]
|
10 |
output_path1 = "output1" + target_extension
|
11 |
output_path2 = "output2" + target_extension
|
12 |
|
13 |
if not use_face_enhancer:
|
14 |
-
# Run
|
15 |
cmd1 = ["python3", "run.py", "-s", source.name, "-t", target.name, "-o", output_path1, "--frame-processor", "face_swapper"]
|
16 |
subprocess.run(cmd1)
|
17 |
|
@@ -25,17 +26,19 @@ def run_scripts(target, source, use_face_enhancer):
|
|
25 |
|
26 |
return output_path2
|
27 |
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
)
|
40 |
-
|
41 |
-
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
import subprocess
|
3 |
import shutil
|
4 |
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 |
target_extension = os.path.splitext(target.name)[-1]
|
11 |
output_path1 = "output1" + target_extension
|
12 |
output_path2 = "output2" + target_extension
|
13 |
|
14 |
if not use_face_enhancer:
|
15 |
+
# Run the first script
|
16 |
cmd1 = ["python3", "run.py", "-s", source.name, "-t", target.name, "-o", output_path1, "--frame-processor", "face_swapper"]
|
17 |
subprocess.run(cmd1)
|
18 |
|
|
|
26 |
|
27 |
return output_path2
|
28 |
|
29 |
+
st.title("Face swapper")
|
30 |
+
|
31 |
+
target_image = st.file_uploader("Upload target image", type=["jpg", "png"])
|
32 |
+
|
33 |
+
source_image = st.file_uploader("Upload source image (optional)", type=["jpg", "png"])
|
34 |
+
|
35 |
+
use_face_enhancer = st.checkbox("Use only Face Enhancer", value=False)
|
36 |
+
|
37 |
+
if st.button("Swap Faces"):
|
38 |
+
output_file = run_scripts(target_image, source_image, use_face_enhancer)
|
39 |
+
if output_file:
|
40 |
+
st.success("Face swapping completed!")
|
41 |
+
st.image(output_file)
|
42 |
+
else:
|
43 |
+
st.error("Please provide a target image.")
|
44 |
+
|