import gradio as gr import subprocess # 运行 Face Swap 代码 def run_script(source_video, target_face): cmd = f"python inference.py --source {source_video} --target {target_face}" result = subprocess.run(cmd, shell=True, capture_output=True, text=True) return result.stdout # Gradio UI iface = gr.Interface( fn=run_script, inputs=["file", "file"], outputs="text", title="Video Face Swap", description="Upload a video and a face image to swap faces." ) iface.launch()