Spaces:
Runtime error
Runtime error
Upload server.py
Browse files
server.py
CHANGED
@@ -9,7 +9,7 @@ from pathlib import Path
|
|
9 |
current_dir = Path(__file__).parent
|
10 |
|
11 |
# Load the model
|
12 |
-
|
13 |
Path.joinpath(current_dir, "fhe_model")
|
14 |
)
|
15 |
class PredictRequest(BaseModel):
|
@@ -28,10 +28,10 @@ def root():
|
|
28 |
|
29 |
|
30 |
@app.post("/predict")
|
31 |
-
def
|
32 |
encrypted_encoding = base64.b64decode(query.encrypted_encoding)
|
33 |
evaluation_key = base64.b64decode(query.evaluation_key)
|
34 |
-
prediction =
|
35 |
|
36 |
# Encode base64 the prediction
|
37 |
encoded_prediction = base64.b64encode(prediction).decode()
|
|
|
9 |
current_dir = Path(__file__).parent
|
10 |
|
11 |
# Load the model
|
12 |
+
fhe_model = FHEModelServer(
|
13 |
Path.joinpath(current_dir, "fhe_model")
|
14 |
)
|
15 |
class PredictRequest(BaseModel):
|
|
|
28 |
|
29 |
|
30 |
@app.post("/predict")
|
31 |
+
def predict(query: PredictRequest):
|
32 |
encrypted_encoding = base64.b64decode(query.encrypted_encoding)
|
33 |
evaluation_key = base64.b64decode(query.evaluation_key)
|
34 |
+
prediction = fhe_model.run(encrypted_encoding, evaluation_key)
|
35 |
|
36 |
# Encode base64 the prediction
|
37 |
encoded_prediction = base64.b64encode(prediction).decode()
|