Spaces:
Runtime error
Runtime error
Upload 3 files
Browse filesFiles changed (3)
- fhe_model/client.zipAdded+3
- fhe_model/server.zipAdded+3
- server.pyAdded+38
123version https://git-lfs.github.com/spec/v1oid sha256:af5402a23b687193c74da8aa5157c7b84728a80009075dd7e252b1fde04a8c57size 1593797123version https://git-lfs.github.com/spec/v1oid sha256:90903287cd81228b85e3f41bdc3610c94c8132b5b3fce68075656e44f3f69536size 45311234567891011121314151617181920212223242526272829303132333435363738"""Server that will listen for GET requests from the client."""from fastapi import FastAPIfrom joblib import loadfrom concrete.ml.deployment import FHEModelServerfrom pydantic import BaseModelimport base64from pathlib import Path
current_dir = Path(__file__).parent
# Load the modelfhe_model_HLM = FHEModelServer( Path.joinpath(current_dir, "fhe_model"))class PredictRequest(BaseModel): evaluation_key: str encrypted_encoding: str
# Initialize an instance of FastAPIapp = FastAPI()
# Define the default route@app.get("/")def root(): return {"message": "Welcome to Your ClairVault!"}
@app.post("/predict")def predict_HLM(query: PredictRequest): encrypted_encoding = base64.b64decode(query.encrypted_encoding) evaluation_key = base64.b64decode(query.evaluation_key) prediction = fhe_model_HLM.run(encrypted_encoding, evaluation_key)
# Encode base64 the prediction encoded_prediction = base64.b64encode(prediction).decode() return {"encrypted_prediction": encoded_prediction}fhe_model/client.zipAdded+3
fhe_model/server.zipAdded+3
server.pyAdded+38