Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,22 +1,30 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import subprocess
|
|
|
|
| 3 |
|
| 4 |
-
def swap_faces(
|
|
|
|
|
|
|
| 5 |
command = [
|
| 6 |
"python", "infer.py",
|
| 7 |
-
"--source",
|
| 8 |
-
"--target",
|
| 9 |
-
"--output",
|
| 10 |
]
|
|
|
|
| 11 |
subprocess.run(command)
|
| 12 |
-
return
|
| 13 |
|
| 14 |
iface = gr.Interface(
|
| 15 |
fn=swap_faces,
|
| 16 |
-
inputs=[
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
)
|
| 21 |
|
| 22 |
iface.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import subprocess
|
| 3 |
+
import os
|
| 4 |
|
| 5 |
+
def swap_faces(source, target, is_video=False):
|
| 6 |
+
output_path = "output.mp4" if is_video else "output.jpg"
|
| 7 |
+
|
| 8 |
command = [
|
| 9 |
"python", "infer.py",
|
| 10 |
+
"--source", source,
|
| 11 |
+
"--target", target,
|
| 12 |
+
"--output", output_path
|
| 13 |
]
|
| 14 |
+
|
| 15 |
subprocess.run(command)
|
| 16 |
+
return output_path
|
| 17 |
|
| 18 |
iface = gr.Interface(
|
| 19 |
fn=swap_faces,
|
| 20 |
+
inputs=[
|
| 21 |
+
"file", # 允许上传文件(图片或视频)
|
| 22 |
+
"file", # 目标换脸对象(图片)
|
| 23 |
+
gr.Checkbox(label="Process as Video") # 选择是否处理视频
|
| 24 |
+
],
|
| 25 |
+
outputs="file",
|
| 26 |
+
title="MagicFaceLab - Video & Image Swap",
|
| 27 |
+
description="Upload an image or video and swap faces with the target face."
|
| 28 |
)
|
| 29 |
|
| 30 |
iface.launch(server_name="0.0.0.0", server_port=7860)
|