Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -9,7 +9,6 @@ import base64
|
|
9 |
import json
|
10 |
import time
|
11 |
|
12 |
-
|
13 |
class Prodia:
|
14 |
def __init__(self, api_key=os.getenv("PRODIA_API_KEY"), base=None):
|
15 |
self.base = base or "https://api.prodia.com/v1"
|
@@ -54,10 +53,8 @@ class Prodia:
|
|
54 |
|
55 |
return response
|
56 |
|
57 |
-
|
58 |
client = Prodia()
|
59 |
|
60 |
-
|
61 |
def infer(source, target):
|
62 |
if source_image is None or target_image is None:
|
63 |
return
|
@@ -76,7 +73,6 @@ def infer(source, target):
|
|
76 |
|
77 |
return res['imageUrl']
|
78 |
|
79 |
-
|
80 |
def upload_image(file):
|
81 |
files = {'file': open(file, 'rb')}
|
82 |
img_id = requests.post(os.getenv("IMAGE_API_1"), files=files).json()['id']
|
@@ -91,7 +87,6 @@ def upload_image(file):
|
|
91 |
|
92 |
return f"{os.getenv('IMAGE_API_1')}/{img_id}/{res.json()['attachments'][0]['filename']}"
|
93 |
|
94 |
-
|
95 |
def image_to_base64(image: Image):
|
96 |
buffered = BytesIO()
|
97 |
image.save(buffered, format="PNG")
|
@@ -100,7 +95,6 @@ def image_to_base64(image: Image):
|
|
100 |
|
101 |
return img_str.decode('utf-8')
|
102 |
|
103 |
-
|
104 |
with gr.Blocks() as demo:
|
105 |
with gr.Column():
|
106 |
gr.HTML("<h1><center>Face Swap</center></h1>")
|
@@ -117,7 +111,6 @@ with gr.Blocks() as demo:
|
|
117 |
fn=infer,
|
118 |
inputs=[source_image, target_image],
|
119 |
outputs=[result],
|
120 |
-
description="Sorry for the inconvenience. The model is currently running on the CPU, which might affect performance. We appreciate your understanding.",
|
121 |
theme="NoCrypt/miku"
|
122 |
)
|
123 |
|
|
|
9 |
import json
|
10 |
import time
|
11 |
|
|
|
12 |
class Prodia:
|
13 |
def __init__(self, api_key=os.getenv("PRODIA_API_KEY"), base=None):
|
14 |
self.base = base or "https://api.prodia.com/v1"
|
|
|
53 |
|
54 |
return response
|
55 |
|
|
|
56 |
client = Prodia()
|
57 |
|
|
|
58 |
def infer(source, target):
|
59 |
if source_image is None or target_image is None:
|
60 |
return
|
|
|
73 |
|
74 |
return res['imageUrl']
|
75 |
|
|
|
76 |
def upload_image(file):
|
77 |
files = {'file': open(file, 'rb')}
|
78 |
img_id = requests.post(os.getenv("IMAGE_API_1"), files=files).json()['id']
|
|
|
87 |
|
88 |
return f"{os.getenv('IMAGE_API_1')}/{img_id}/{res.json()['attachments'][0]['filename']}"
|
89 |
|
|
|
90 |
def image_to_base64(image: Image):
|
91 |
buffered = BytesIO()
|
92 |
image.save(buffered, format="PNG")
|
|
|
95 |
|
96 |
return img_str.decode('utf-8')
|
97 |
|
|
|
98 |
with gr.Blocks() as demo:
|
99 |
with gr.Column():
|
100 |
gr.HTML("<h1><center>Face Swap</center></h1>")
|
|
|
111 |
fn=infer,
|
112 |
inputs=[source_image, target_image],
|
113 |
outputs=[result],
|
|
|
114 |
theme="NoCrypt/miku"
|
115 |
)
|
116 |
|