Update app.py
Browse files
app.py
CHANGED
@@ -12,21 +12,19 @@ def run_scripts(target, source, use_face_enhancer):
|
|
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 |
|
19 |
-
# Run the second script
|
20 |
cmd2 = ["python3", "run.py", "-t", target.name if use_face_enhancer else output_path1, "-o", output_path2, "--frame-processor", "face_enhancer"]
|
21 |
subprocess.run(cmd2)
|
22 |
|
23 |
if not use_face_enhancer:
|
24 |
-
|
25 |
-
|
26 |
|
27 |
return output_path2
|
28 |
|
29 |
-
st.title("Face
|
30 |
|
31 |
target_image = st.file_uploader("Upload target image", type=["jpg", "png"])
|
32 |
|
@@ -41,4 +39,3 @@ if st.button("Swap Faces"):
|
|
41 |
st.image(output_file)
|
42 |
else:
|
43 |
st.error("Please provide a target image.")
|
44 |
-
|
|
|
12 |
output_path2 = "output2" + target_extension
|
13 |
|
14 |
if not use_face_enhancer:
|
|
|
15 |
cmd1 = ["python3", "run.py", "-s", source.name, "-t", target.name, "-o", output_path1, "--frame-processor", "face_swapper"]
|
16 |
subprocess.run(cmd1)
|
17 |
|
|
|
18 |
cmd2 = ["python3", "run.py", "-t", target.name if use_face_enhancer else output_path1, "-o", output_path2, "--frame-processor", "face_enhancer"]
|
19 |
subprocess.run(cmd2)
|
20 |
|
21 |
if not use_face_enhancer:
|
22 |
+
shutil.move(source.name, "processed_" + source.name) # Move uploaded source file
|
23 |
+
shutil.move(target.name, "processed_" + target.name) # Move uploaded target file
|
24 |
|
25 |
return output_path2
|
26 |
|
27 |
+
st.title("Face Swapper")
|
28 |
|
29 |
target_image = st.file_uploader("Upload target image", type=["jpg", "png"])
|
30 |
|
|
|
39 |
st.image(output_file)
|
40 |
else:
|
41 |
st.error("Please provide a target image.")
|
|