Spaces:
Sleeping
Sleeping
placeholder
Browse files
server.py
CHANGED
@@ -10,6 +10,7 @@ from fastapi.responses import JSONResponse, Response
|
|
10 |
from fastapi.middleware.cors import CORSMiddleware
|
11 |
|
12 |
from concrete.ml.deployment import FHEModelServer
|
|
|
13 |
|
14 |
import gc
|
15 |
|
@@ -100,17 +101,21 @@ def run_fhe(user_id: str = Form()):
|
|
100 |
|
101 |
# Run the FHE execution
|
102 |
start = time.time()
|
103 |
-
try:
|
104 |
-
|
105 |
-
except MemoryError:
|
106 |
-
|
107 |
-
|
108 |
-
except Exception as e:
|
109 |
-
|
110 |
-
|
111 |
-
finally:
|
112 |
-
|
113 |
-
|
|
|
|
|
|
|
|
|
114 |
|
115 |
fhe_execution_time = round(time.time() - start, 2)
|
116 |
|
|
|
10 |
from fastapi.middleware.cors import CORSMiddleware
|
11 |
|
12 |
from concrete.ml.deployment import FHEModelServer
|
13 |
+
import numpy as np
|
14 |
|
15 |
import gc
|
16 |
|
|
|
101 |
|
102 |
# Run the FHE execution
|
103 |
start = time.time()
|
104 |
+
# try:
|
105 |
+
# encrypted_output = FHE_SERVER.run(encrypted_image, evaluation_key)
|
106 |
+
# except MemoryError:
|
107 |
+
# logger.error("FHE execution failed due to insufficient memory")
|
108 |
+
# raise HTTPException(status_code=503, detail="Insufficient memory during FHE execution")
|
109 |
+
# except Exception as e:
|
110 |
+
# logger.error(f"FHE execution failed: {str(e)}")
|
111 |
+
# raise HTTPException(status_code=500, detail="FHE execution failed")
|
112 |
+
# finally:
|
113 |
+
# # Force garbage collection after FHE execution
|
114 |
+
# gc.collect()
|
115 |
+
|
116 |
+
# Placeholder output
|
117 |
+
placeholder_output = np.random.randint(0, 2**64-1, size=(1, 2, 32769), dtype=np.uint64)
|
118 |
+
encrypted_output = placeholder_output.tobytes()
|
119 |
|
120 |
fhe_execution_time = round(time.time() - start, 2)
|
121 |
|