Spaces:
Running
Running
Alex
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -100,7 +100,36 @@ def send_enhance_request(image, uuid_value, token):
|
|
100 |
if response.status_code == 200:
|
101 |
return response.text
|
102 |
else:
|
103 |
-
return f"Error: {response.status_code} - {response.text}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
|
105 |
# Function for Image-to-Image (Send POST request with an image and other parameters)
|
106 |
def send_inpaint2image_request(image, mask, prompt, ratio, uuid_value, token, style):
|
@@ -262,6 +291,18 @@ def create_interface():
|
|
262 |
en_submit_button = gr.Button("Get Upload URL")
|
263 |
en_submit_button.click(send_enhance_request, inputs=[en_url, en_uuid, en_token], outputs=en_output)
|
264 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
265 |
with gr.Tab("Image Put"):
|
266 |
# Inputs for Image Put
|
267 |
image_input = gr.File(label="Upload Image") # Input for image file
|
|
|
100 |
if response.status_code == 200:
|
101 |
return response.text
|
102 |
else:
|
103 |
+
return f"Error: {response.status_code} - {response.text}"
|
104 |
+
|
105 |
+
def send_face_request(image, target, uuid_value, token):
|
106 |
+
# Access the URL from Secrets (Private)
|
107 |
+
url = os.getenv('API_URL_FACE') # Secret variable for the URL
|
108 |
+
if not url:
|
109 |
+
return "Error: API URL not set in environment secrets."
|
110 |
+
|
111 |
+
# Define the headers with the required values
|
112 |
+
headers = {
|
113 |
+
"Uid": uuid_value, # Using the provided UUID
|
114 |
+
"Versioncode": "16701",
|
115 |
+
"Accept-Version": "v1",
|
116 |
+
"Token": token, # Replace with the actual token
|
117 |
+
"Content-Type": "application/x-www-form-urlencoded"
|
118 |
+
}
|
119 |
+
|
120 |
+
# Define the values to be sent in the POST request
|
121 |
+
data = {
|
122 |
+
"sourceUrl": image,
|
123 |
+
"targetUrl": target
|
124 |
+
}
|
125 |
+
|
126 |
+
response = requests.post(url, headers=headers, data=data)
|
127 |
+
|
128 |
+
# Return the response text or any relevant information
|
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):
|
|
|
291 |
en_submit_button = gr.Button("Get Upload URL")
|
292 |
en_submit_button.click(send_enhance_request, inputs=[en_url, en_uuid, en_token], outputs=en_output)
|
293 |
|
294 |
+
with gr.Tab("Get Faceswap"):
|
295 |
+
# Inputs for Get Upload URL
|
296 |
+
fs_url = gr.Textbox(label="URL")
|
297 |
+
fs_target = gr.Textbox(label="Target URL")
|
298 |
+
fs_uuid = gr.Textbox(label="UUID ID") # Default UUID
|
299 |
+
fs_token = gr.Textbox(label="Token ID")
|
300 |
+
fs_output = gr.Textbox() # Output for the upload URL response
|
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
|
308 |
image_input = gr.File(label="Upload Image") # Input for image file
|