Spaces:
Sleeping
Sleeping
Update server.py
Browse files
server.py
CHANGED
|
@@ -10,7 +10,7 @@ current_dir = Path(__file__).parent
|
|
| 10 |
|
| 11 |
# Load the model
|
| 12 |
fhe_model = FHEModelServer("deployment/financial_rating")
|
| 13 |
-
|
| 14 |
class PredictRequest(BaseModel):
|
| 15 |
evaluation_key: str
|
| 16 |
encrypted_encoding: str
|
|
@@ -25,26 +25,10 @@ def root():
|
|
| 25 |
|
| 26 |
@app.post("/predict_sentiment")
|
| 27 |
def predict_sentiment(query: PredictRequest):
|
| 28 |
-
|
| 29 |
-
|
| 30 |
encrypted_encoding = base64.b64decode(query.encrypted_encoding)
|
| 31 |
evaluation_key = base64.b64decode(query.evaluation_key)
|
| 32 |
prediction = fhe_model.run(encrypted_encoding, evaluation_key)
|
| 33 |
|
| 34 |
# Encode base64 the prediction
|
| 35 |
encoded_prediction = base64.b64encode(prediction).decode()
|
| 36 |
-
return {"encrypted_prediction": encoded_prediction}
|
| 37 |
-
|
| 38 |
-
'''
|
| 39 |
-
@app.post("/predict_legal")
|
| 40 |
-
def predict_legal(query: PredictRequest):
|
| 41 |
-
fhe_legal_model = FHEModelServer("deployment/legal_rating")
|
| 42 |
-
|
| 43 |
-
encrypted_encoding = base64.b64decode(query.encrypted_encoding)
|
| 44 |
-
evaluation_key = base64.b64decode(query.evaluation_key)
|
| 45 |
-
prediction = fhe_legal_model.run(encrypted_encoding, evaluation_key)
|
| 46 |
-
|
| 47 |
-
# Encode base64 the prediction
|
| 48 |
-
encoded_prediction = base64.b64encode(prediction).decode()
|
| 49 |
-
return {"encrypted_prediction": encoded_prediction}
|
| 50 |
-
'''
|
|
|
|
| 10 |
|
| 11 |
# Load the model
|
| 12 |
fhe_model = FHEModelServer("deployment/financial_rating")
|
| 13 |
+
|
| 14 |
class PredictRequest(BaseModel):
|
| 15 |
evaluation_key: str
|
| 16 |
encrypted_encoding: str
|
|
|
|
| 25 |
|
| 26 |
@app.post("/predict_sentiment")
|
| 27 |
def predict_sentiment(query: PredictRequest):
|
|
|
|
|
|
|
| 28 |
encrypted_encoding = base64.b64decode(query.encrypted_encoding)
|
| 29 |
evaluation_key = base64.b64decode(query.evaluation_key)
|
| 30 |
prediction = fhe_model.run(encrypted_encoding, evaluation_key)
|
| 31 |
|
| 32 |
# Encode base64 the prediction
|
| 33 |
encoded_prediction = base64.b64encode(prediction).decode()
|
| 34 |
+
return {"encrypted_prediction": encoded_prediction}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|