Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -10,15 +10,17 @@ import base64
|
|
10 |
client = Prodia()
|
11 |
|
12 |
|
13 |
-
def
|
14 |
if source_image is None or target_image is None:
|
15 |
return
|
16 |
|
17 |
source_url = upload_image(source)
|
18 |
target_url = upload_image(target)
|
19 |
-
|
20 |
job = client.faceswap(source_url=source_url, target_url=target_url)
|
21 |
-
res = client.wait(job)
|
|
|
|
|
22 |
|
23 |
return res.image_url
|
24 |
|
@@ -61,6 +63,18 @@ with gr.Blocks() as demo:
|
|
61 |
result = gr.Image()
|
62 |
run_button = gr.Button("Swap Faces", variant="primary")
|
63 |
|
64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
|
66 |
demo.queue(max_size=20, api_open=False).launch(show_api=False, max_threads=400)
|
|
|
10 |
client = Prodia()
|
11 |
|
12 |
|
13 |
+
def infer(source, target):
|
14 |
if source_image is None or target_image is None:
|
15 |
return
|
16 |
|
17 |
source_url = upload_image(source)
|
18 |
target_url = upload_image(target)
|
19 |
+
|
20 |
job = client.faceswap(source_url=source_url, target_url=target_url)
|
21 |
+
res = client.wait(job, raise_on_fail=False)
|
22 |
+
if res.failed:
|
23 |
+
return
|
24 |
|
25 |
return res.image_url
|
26 |
|
|
|
63 |
result = gr.Image()
|
64 |
run_button = gr.Button("Swap Faces", variant="primary")
|
65 |
|
66 |
+
gr.Examples(
|
67 |
+
examples=[
|
68 |
+
[
|
69 |
+
"/examples/example1.jpg",
|
70 |
+
"/examples/example2.jpg"
|
71 |
+
]
|
72 |
+
],
|
73 |
+
fn=infer,
|
74 |
+
inputs=[source_image, target_image],
|
75 |
+
outputs=[result]
|
76 |
+
)
|
77 |
+
|
78 |
+
run_button.click(fn=infer, inputs=[source_image, target_image], outputs=[result])
|
79 |
|
80 |
demo.queue(max_size=20, api_open=False).launch(show_api=False, max_threads=400)
|