Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,40 +1,22 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
import
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
output_path = "output.jpg"
|
| 24 |
-
cv2.imwrite(output_path, result)
|
| 25 |
-
|
| 26 |
-
return output_path
|
| 27 |
-
except Exception as e:
|
| 28 |
-
return str(e)
|
| 29 |
-
|
| 30 |
-
with gr.Blocks() as demo:
|
| 31 |
-
gr.Markdown("# Roop Face Swap (Hugging Face)")
|
| 32 |
-
with gr.Row():
|
| 33 |
-
source_img = gr.Image(type="filepath", label="Source Face")
|
| 34 |
-
target_img = gr.Image(type="filepath", label="Target Image")
|
| 35 |
-
btn = gr.Button("Swap Face")
|
| 36 |
-
output_img = gr.Image(label="Output Image")
|
| 37 |
-
|
| 38 |
-
btn.click(swap_face, inputs=[source_img, target_img], outputs=output_img)
|
| 39 |
-
|
| 40 |
-
demo.launch()
|
|
|
|
| 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)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|