Alex commited on
Commit
5d76255
·
verified ·
1 Parent(s): bf11926

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +42 -1
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
  def send_face_request(image, target, uuid_value, token):
106
  # Access the URL from Secrets (Private)
@@ -313,6 +342,18 @@ def create_interface():
313
  en_submit_button = gr.Button("Get Upload URL")
314
  en_submit_button.click(send_enhance_request, inputs=[en_url, en_uuid, en_token], outputs=en_output)
315
 
 
 
 
 
 
 
 
 
 
 
 
 
316
  with gr.Tab("Get Faceswap"):
317
  # Inputs for Get Upload URL
318
  fs_url = gr.Textbox(label="URL")
 
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_outpaint_request(image, canvas_info, uuid_value, token):
106
+ # Access the URL from Secrets (Private)
107
+ url = os.getenv('API_URL_OUT') # 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
+ "image_name": image,
123
+ "canvas_info": canvas_info
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
  def send_face_request(image, target, uuid_value, token):
135
  # Access the URL from Secrets (Private)
 
342
  en_submit_button = gr.Button("Get Upload URL")
343
  en_submit_button.click(send_enhance_request, inputs=[en_url, en_uuid, en_token], outputs=en_output)
344
 
345
+ with gr.Tab("Get OutPaint"):
346
+ # Inputs for Get Upload URL
347
+ out_url = gr.Textbox(label="URL")
348
+ out_canvas = gr.Textbox(label="Canvas")
349
+ out_uuid = gr.Textbox(label="UUID ID") # Default UUID
350
+ out_token = gr.Textbox(label="Token ID")
351
+ out_output = gr.Textbox() # Output for the upload URL response
352
+
353
+ # Bind the get_upload_url function to the interface
354
+ out_submit_button = gr.Button("Get Upload URL")
355
+ out_submit_button.click(send_outpaint_request, inputs=[out_url, out_canvas, out_uuid, out_token], outputs=out_output)
356
+
357
  with gr.Tab("Get Faceswap"):
358
  # Inputs for Get Upload URL
359
  fs_url = gr.Textbox(label="URL")