Spaces:
Sleeping
Sleeping
timeout increased
Browse files
app.py
CHANGED
@@ -217,25 +217,25 @@ def send_input(user_id):
|
|
217 |
return response.ok
|
218 |
|
219 |
def run_fhe(user_id):
|
220 |
-
"""Apply the seizure detection model on the encrypted image previously sent using FHE.
|
221 |
-
|
222 |
-
Args:
|
223 |
-
user_id (int): The current user's ID.
|
224 |
-
"""
|
225 |
-
data = {
|
226 |
-
"user_id": user_id,
|
227 |
-
}
|
228 |
-
|
229 |
-
# Trigger the FHE execution on the encrypted image previously sent
|
230 |
url = SERVER_URL + "run_fhe"
|
231 |
-
|
232 |
-
|
233 |
-
data=data,
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
239 |
|
240 |
def get_output(user_id):
|
241 |
"""Retrieve the encrypted output (boolean).
|
|
|
217 |
return response.ok
|
218 |
|
219 |
def run_fhe(user_id):
|
220 |
+
"""Apply the seizure detection model on the encrypted image previously sent using FHE."""
|
221 |
+
data = {"user_id": user_id}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
222 |
url = SERVER_URL + "run_fhe"
|
223 |
+
|
224 |
+
try:
|
225 |
+
with requests.post(url=url, data=data, timeout=300) as response:
|
226 |
+
response.raise_for_status() # Raises an HTTPError for bad responses
|
227 |
+
if response.ok:
|
228 |
+
return response.json()
|
229 |
+
else:
|
230 |
+
raise gr.Error(f"Server responded with status code {response.status_code}")
|
231 |
+
except requests.exceptions.Timeout:
|
232 |
+
raise gr.Error("The request timed out. The server might be overloaded.")
|
233 |
+
except requests.exceptions.ConnectionError:
|
234 |
+
raise gr.Error("Failed to connect to the server. Please check your network connection.")
|
235 |
+
except requests.exceptions.RequestException as e:
|
236 |
+
raise gr.Error(f"An error occurred: {str(e)}")
|
237 |
+
except Exception as e:
|
238 |
+
raise gr.Error(f"An unexpected error occurred: {str(e)}")
|
239 |
|
240 |
def get_output(user_id):
|
241 |
"""Retrieve the encrypted output (boolean).
|