Spaces:
Runtime error
Runtime error
Upload 2 files
Browse files
app.py
CHANGED
@@ -21,7 +21,10 @@ import numpy as np
|
|
21 |
import pdb
|
22 |
# This repository's directory
|
23 |
REPO_DIR = Path(__file__).parent
|
24 |
-
subprocess.Popen(["uvicorn", "server:app"], cwd=REPO_DIR)
|
|
|
|
|
|
|
25 |
|
26 |
# if not exists, create a directory for the FHE keys called .fhe_keys
|
27 |
if not os.path.exists(".fhe_keys"):
|
@@ -146,7 +149,7 @@ def run_fhe(user_id):
|
|
146 |
headers = {"Content-type": "application/json"}
|
147 |
|
148 |
response = requests.post(
|
149 |
-
"http://localhost:
|
150 |
data=json.dumps(query),
|
151 |
headers=headers,
|
152 |
)
|
@@ -177,7 +180,6 @@ def decrypt_prediction(user_id):
|
|
177 |
return predictions
|
178 |
|
179 |
|
180 |
-
|
181 |
def process_pipeline(test_file):
|
182 |
|
183 |
eval_key = keygen()
|
@@ -205,4 +207,4 @@ if __name__ == "__main__":
|
|
205 |
description="This is a FHE Model",
|
206 |
)
|
207 |
|
208 |
-
app.launch(share=True)
|
|
|
21 |
import pdb
|
22 |
# This repository's directory
|
23 |
REPO_DIR = Path(__file__).parent
|
24 |
+
# subprocess.Popen(["uvicorn", "server:app"], cwd=REPO_DIR)
|
25 |
+
|
26 |
+
|
27 |
+
subprocess.Popen(["uvicorn", "server:app", "--port", "3000"], cwd=REPO_DIR)
|
28 |
|
29 |
# if not exists, create a directory for the FHE keys called .fhe_keys
|
30 |
if not os.path.exists(".fhe_keys"):
|
|
|
149 |
headers = {"Content-type": "application/json"}
|
150 |
|
151 |
response = requests.post(
|
152 |
+
"http://localhost:3000/predict",
|
153 |
data=json.dumps(query),
|
154 |
headers=headers,
|
155 |
)
|
|
|
180 |
return predictions
|
181 |
|
182 |
|
|
|
183 |
def process_pipeline(test_file):
|
184 |
|
185 |
eval_key = keygen()
|
|
|
207 |
description="This is a FHE Model",
|
208 |
)
|
209 |
|
210 |
+
app.launch() #share=True)
|
server.py
CHANGED
@@ -5,6 +5,8 @@ from concrete.ml.deployment import FHEModelServer
|
|
5 |
from pydantic import BaseModel
|
6 |
import base64
|
7 |
from pathlib import Path
|
|
|
|
|
8 |
|
9 |
current_dir = Path(__file__).parent
|
10 |
|
@@ -35,4 +37,7 @@ def predict(query: PredictRequest):
|
|
35 |
|
36 |
# Encode base64 the prediction
|
37 |
encoded_prediction = base64.b64encode(prediction).decode()
|
38 |
-
return {"encrypted_prediction": encoded_prediction}
|
|
|
|
|
|
|
|
5 |
from pydantic import BaseModel
|
6 |
import base64
|
7 |
from pathlib import Path
|
8 |
+
import uvicorn
|
9 |
+
|
10 |
|
11 |
current_dir = Path(__file__).parent
|
12 |
|
|
|
37 |
|
38 |
# Encode base64 the prediction
|
39 |
encoded_prediction = base64.b64encode(prediction).decode()
|
40 |
+
return {"encrypted_prediction": encoded_prediction}
|
41 |
+
|
42 |
+
#if __name__ == "__main__":
|
43 |
+
# uvicorn.run(app, host="0.0.0.0", port=3000)
|