Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -34,7 +34,7 @@ model_names=['financial_rating','legal_rating']
|
|
| 34 |
|
| 35 |
|
| 36 |
FHE_MODEL_PATH = "deployment/financial_rating"
|
| 37 |
-
FHE_LEGAL_PATH = "deployment/legal_rating"
|
| 38 |
#FHE_LEGAL_PATH="deployment/legal_rating"
|
| 39 |
|
| 40 |
print("Loading the transformer model...")
|
|
@@ -169,19 +169,9 @@ def keygen(selected_tasks):
|
|
| 169 |
def encode_quantize_encrypt(text, user_id):
|
| 170 |
if not user_id:
|
| 171 |
raise gr.Error("You need to generate FHE keys first.")
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
if encodings.shape[1] < 1736:
|
| 176 |
-
# 在后面填充零
|
| 177 |
-
padding = np.zeros((1, 1736 - encodings.shape[1]))
|
| 178 |
-
encodings = np.hstack((encodings, padding))
|
| 179 |
-
elif encodings.shape[1] > 1736:
|
| 180 |
-
# 截取前1736列
|
| 181 |
-
encodings = encodings[:, :1736]
|
| 182 |
-
else:
|
| 183 |
-
fhe_api = FHEModelClient(FHE_MODEL_PATH, f".fhe_keys/{user_id}")
|
| 184 |
-
encodings = transformer_vectorizer.transform([text])
|
| 185 |
|
| 186 |
fhe_api.load()
|
| 187 |
quantized_encodings = fhe_api.model.quantize_input(encodings).astype(numpy.uint8)
|
|
|
|
| 34 |
|
| 35 |
|
| 36 |
FHE_MODEL_PATH = "deployment/financial_rating"
|
| 37 |
+
#FHE_LEGAL_PATH = "deployment/legal_rating"
|
| 38 |
#FHE_LEGAL_PATH="deployment/legal_rating"
|
| 39 |
|
| 40 |
print("Loading the transformer model...")
|
|
|
|
| 169 |
def encode_quantize_encrypt(text, user_id):
|
| 170 |
if not user_id:
|
| 171 |
raise gr.Error("You need to generate FHE keys first.")
|
| 172 |
+
|
| 173 |
+
fhe_api = FHEModelClient(FHE_MODEL_PATH, f".fhe_keys/{user_id}")
|
| 174 |
+
encodings = transformer_vectorizer.transform([text])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 175 |
|
| 176 |
fhe_api.load()
|
| 177 |
quantized_encodings = fhe_api.model.quantize_input(encodings).astype(numpy.uint8)
|