Update app.py
Browse files
app.py
CHANGED
|
@@ -10,7 +10,7 @@ os.makedirs('temp', exist_ok=True)
|
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
-
def run_scripts(target, source, mode
|
| 14 |
if target is None or (source is None):
|
| 15 |
return None
|
| 16 |
with st.spinner("Processing..."):
|
|
@@ -33,7 +33,14 @@ def run_scripts(target, source, mode, use_face_enhancer):
|
|
| 33 |
cmd1 = ["python3", "run.py", "-s", f'temp/source{target_extension}', "-t", f'temp/target{target_extension}', "-o", output_path, "--frame-processor", "face_swapper"]
|
| 34 |
subprocess.run(cmd1)
|
| 35 |
|
| 36 |
-
if
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
cmd2 = ["python3", "run.py", "-t", f'temp/target{target_extension}', "-o", output_path, "--frame-processor", "face_enhancer"]
|
| 38 |
subprocess.run(cmd2)
|
| 39 |
|
|
@@ -50,9 +57,8 @@ st.markdown('<style>h1{color: Crimson; text-align: center;}</style>', unsafe_all
|
|
| 50 |
source_file = st.file_uploader("Upload source image")
|
| 51 |
target_file = st.file_uploader("Upload target image/video")
|
| 52 |
mode = st.radio("Choose Mode", ("Face Swapper", "Face Enhancer", "Both"))
|
| 53 |
-
use_face_enhancer = st.checkbox("Use Face Enhancer")
|
| 54 |
|
| 55 |
if source_file and target_file and st.button("Swap Faces"):
|
| 56 |
-
result = run_scripts(target_file, source_file, mode
|
| 57 |
if result:
|
| 58 |
st.image(result) # Display the result as an image
|
|
|
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
+
def run_scripts(target, source, mode):
|
| 14 |
if target is None or (source is None):
|
| 15 |
return None
|
| 16 |
with st.spinner("Processing..."):
|
|
|
|
| 33 |
cmd1 = ["python3", "run.py", "-s", f'temp/source{target_extension}', "-t", f'temp/target{target_extension}', "-o", output_path, "--frame-processor", "face_swapper"]
|
| 34 |
subprocess.run(cmd1)
|
| 35 |
|
| 36 |
+
if mode == "Face Enhancer":
|
| 37 |
+
cmd2 = ["python3", "run.py", "-t", f'temp/target{target_extension}', "-o", output_path, "--frame-processor", "face_enhancer"]
|
| 38 |
+
subprocess.run(cmd2)
|
| 39 |
+
|
| 40 |
+
if mode == "Both":
|
| 41 |
+
cmd1 = ["python3", "run.py", "-s", f'temp/source{target_extension}', "-t", f'temp/target{target_extension}', "-o", output_path, "--frame-processor", "face_swapper"]
|
| 42 |
+
subprocess.run(cmd1)
|
| 43 |
+
|
| 44 |
cmd2 = ["python3", "run.py", "-t", f'temp/target{target_extension}', "-o", output_path, "--frame-processor", "face_enhancer"]
|
| 45 |
subprocess.run(cmd2)
|
| 46 |
|
|
|
|
| 57 |
source_file = st.file_uploader("Upload source image")
|
| 58 |
target_file = st.file_uploader("Upload target image/video")
|
| 59 |
mode = st.radio("Choose Mode", ("Face Swapper", "Face Enhancer", "Both"))
|
|
|
|
| 60 |
|
| 61 |
if source_file and target_file and st.button("Swap Faces"):
|
| 62 |
+
result = run_scripts(target_file, source_file, mode)
|
| 63 |
if result:
|
| 64 |
st.image(result) # Display the result as an image
|