MagicFaceLab commited on
Commit
c79a705
·
verified ·
1 Parent(s): cc9114e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -9
app.py CHANGED
@@ -1,22 +1,30 @@
1
  import gradio as gr
2
  import subprocess
 
3
 
4
- def swap_faces(source_image, target_image):
 
 
5
  command = [
6
  "python", "infer.py",
7
- "--source", source_image,
8
- "--target", target_image,
9
- "--output", "output.jpg"
10
  ]
 
11
  subprocess.run(command)
12
- return "output.jpg"
13
 
14
  iface = gr.Interface(
15
  fn=swap_faces,
16
- inputs=["image", "image"],
17
- outputs="image",
18
- title="FaceFusion",
19
- description="Upload two images and swap faces using FaceFusion."
 
 
 
 
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)