batuergun commited on
Commit
c37150a
1 Parent(s): 2fc0f1f
Files changed (1) hide show
  1. app.py +15 -2
app.py CHANGED
@@ -333,12 +333,25 @@ def decrypt_output(user_id):
333
  with encrypted_output_path.open("rb") as encrypted_output_file:
334
  encrypted_output = encrypted_output_file.read()
335
 
 
 
 
 
 
 
336
  # Retrieve the client API
337
  client = get_client(user_id)
338
 
339
  # Deserialize, decrypt and post-process the encrypted output
340
- decrypted_output = client.deserialize_decrypt_post_process(encrypted_output)
341
-
 
 
 
 
 
 
 
342
  return "Seizure detected" if decrypted_output else "No seizure detected"
343
 
344
  def resize_img(img, width=256, height=256):
 
333
  with encrypted_output_path.open("rb") as encrypted_output_file:
334
  encrypted_output = encrypted_output_file.read()
335
 
336
+ logger.debug(f"Encrypted output size: {len(encrypted_output)} bytes")
337
+ logger.debug(f"Encrypted output (first 100 bytes): {encrypted_output[:100].hex()}")
338
+
339
+ if not encrypted_output:
340
+ raise gr.Error("The encrypted output is empty. Please try running the FHE execution again.")
341
+
342
  # Retrieve the client API
343
  client = get_client(user_id)
344
 
345
  # Deserialize, decrypt and post-process the encrypted output
346
+ try:
347
+ decrypted_output = client.deserialize_decrypt_post_process(encrypted_output)
348
+ except RuntimeError as e:
349
+ logger.error(f"Error during deserialization: {str(e)}")
350
+ raise gr.Error("Failed to deserialize the encrypted output. The data might be corrupted or in an unexpected format.")
351
+ except Exception as e:
352
+ logger.error(f"Unexpected error during decryption: {str(e)}")
353
+ raise gr.Error(f"An unexpected error occurred during decryption: {str(e)}")
354
+
355
  return "Seizure detected" if decrypted_output else "No seizure detected"
356
 
357
  def resize_img(img, width=256, height=256):