Spaces:
Running
Running
Alex
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -129,7 +129,27 @@ def send_face_request(image, target, uuid_value, token):
|
|
129 |
if response.status_code == 200:
|
130 |
return response.text
|
131 |
else:
|
132 |
-
return f"Error: {response.status_code} - {response.text}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
133 |
|
134 |
# Function for Image-to-Image (Send POST request with an image and other parameters)
|
135 |
def send_inpaint2image_request(image, mask, prompt, ratio, uuid_value, token, style):
|
@@ -301,7 +321,19 @@ def create_interface():
|
|
301 |
|
302 |
# Bind the get_upload_url function to the interface
|
303 |
fs_submit_button = gr.Button("Get Upload URL")
|
304 |
-
fs_submit_button.click(send_face_request, inputs=[fs_url, fs_target, fs_uuid, fs_token], outputs=fs_output)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
305 |
|
306 |
with gr.Tab("Image Put"):
|
307 |
# Inputs for Image Put
|
|
|
129 |
if response.status_code == 200:
|
130 |
return response.text
|
131 |
else:
|
132 |
+
return f"Error: {response.status_code} - {response.text}"
|
133 |
+
|
134 |
+
def send_face_request_d(image, target, uuid_value, token):
|
135 |
+
# Construct the URL with the provided UUID value
|
136 |
+
image_url = f"cutpaste_yearbook/result/2024-11-26/rst_58cd61f5-7424-494a-9d19-09d2ca51fed7_{uuid_value}.jpg"
|
137 |
+
|
138 |
+
# Static response JSON with dynamic image URL
|
139 |
+
static_response = {
|
140 |
+
"data": {
|
141 |
+
"image_url": [image_url],
|
142 |
+
"task_id": uuid_value # Assuming the task_id is the same as the uuid_value
|
143 |
+
},
|
144 |
+
"error": "",
|
145 |
+
"message": "",
|
146 |
+
"next": "",
|
147 |
+
"response": "ok",
|
148 |
+
"status": "200"
|
149 |
+
}
|
150 |
+
|
151 |
+
# Return the static JSON response as a string
|
152 |
+
return json.dumps(static_response)
|
153 |
|
154 |
# Function for Image-to-Image (Send POST request with an image and other parameters)
|
155 |
def send_inpaint2image_request(image, mask, prompt, ratio, uuid_value, token, style):
|
|
|
321 |
|
322 |
# Bind the get_upload_url function to the interface
|
323 |
fs_submit_button = gr.Button("Get Upload URL")
|
324 |
+
fs_submit_button.click(send_face_request, inputs=[fs_url, fs_target, fs_uuid, fs_token], outputs=fs_output)
|
325 |
+
|
326 |
+
with gr.Tab("Demo Faceswap"):
|
327 |
+
# Inputs for Get Upload URL
|
328 |
+
dfs_url = gr.Textbox(label="URL")
|
329 |
+
dfs_target = gr.Textbox(label="Target URL")
|
330 |
+
dfs_uuid = gr.Textbox(label="UUID ID") # Default UUID
|
331 |
+
dfs_token = gr.Textbox(label="Token ID")
|
332 |
+
dfs_output = gr.Textbox() # Output for the upload URL response
|
333 |
+
|
334 |
+
# Bind the get_upload_url function to the interface
|
335 |
+
dfs_submit_button = gr.Button("Get Upload URL")
|
336 |
+
dfs_submit_button.click(send_face_request_d, inputs=[dfs_url, dfs_target, dfs_uuid, dfs_token], outputs=dfs_output)
|
337 |
|
338 |
with gr.Tab("Image Put"):
|
339 |
# Inputs for Image Put
|