Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -183,6 +183,10 @@ COLS = imp_df.loc[imp_df["cum"] <= 0.95, "col"].tolist()
|
|
| 183 |
# Final model
|
| 184 |
scaler_sel = MinMaxScaler().fit(X_tr[COLS])
|
| 185 |
Xtr_sel = scaler_sel.transform(X_tr[COLS])
|
|
|
|
|
|
|
|
|
|
|
|
|
| 186 |
final_model = ConcreteXGBClassifier(n_bits=8, **best_params, random_state=42)
|
| 187 |
final_model.fit(Xtr_sel, ytr_e)
|
| 188 |
final_model.compile(Xtr_sel)
|
|
@@ -203,22 +207,14 @@ import shutil
|
|
| 203 |
def generate_keys():
|
| 204 |
global client
|
| 205 |
|
| 206 |
-
#
|
| 207 |
-
if os.path.exists(fhe_dir):
|
| 208 |
-
shutil.rmtree(fhe_dir)
|
| 209 |
-
|
| 210 |
-
# 2. Yeniden compile et ve kaydet
|
| 211 |
-
final_model.compile(Xtr_sel)
|
| 212 |
-
dev = FHEModelDev(path_dir=fhe_dir, model=final_model)
|
| 213 |
-
dev.save()
|
| 214 |
-
|
| 215 |
-
# 3. Key klasörünü temizle
|
| 216 |
if os.path.exists(key_dir):
|
| 217 |
shutil.rmtree(key_dir)
|
| 218 |
os.makedirs(key_dir, exist_ok=True)
|
| 219 |
|
| 220 |
-
# 4. Yeni client oluştur ve key üret
|
| 221 |
client = FHEModelClient(path_dir=fhe_dir, key_dir=key_dir)
|
|
|
|
|
|
|
| 222 |
serialized_eval_keys = client.get_serialized_evaluation_keys()
|
| 223 |
|
| 224 |
return str(serialized_eval_keys[:120]) + "..."
|
|
@@ -227,6 +223,7 @@ def generate_keys():
|
|
| 227 |
|
| 228 |
|
| 229 |
|
|
|
|
| 230 |
def encrypt_excel(file):
|
| 231 |
global encrypted_input
|
| 232 |
if client is None:
|
|
|
|
| 183 |
# Final model
|
| 184 |
scaler_sel = MinMaxScaler().fit(X_tr[COLS])
|
| 185 |
Xtr_sel = scaler_sel.transform(X_tr[COLS])
|
| 186 |
+
|
| 187 |
+
if os.path.exists(fhe_dir):
|
| 188 |
+
shutil.rmtree(fhe_dir)
|
| 189 |
+
|
| 190 |
final_model = ConcreteXGBClassifier(n_bits=8, **best_params, random_state=42)
|
| 191 |
final_model.fit(Xtr_sel, ytr_e)
|
| 192 |
final_model.compile(Xtr_sel)
|
|
|
|
| 207 |
def generate_keys():
|
| 208 |
global client
|
| 209 |
|
| 210 |
+
# Klasörleri temizle
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 211 |
if os.path.exists(key_dir):
|
| 212 |
shutil.rmtree(key_dir)
|
| 213 |
os.makedirs(key_dir, exist_ok=True)
|
| 214 |
|
|
|
|
| 215 |
client = FHEModelClient(path_dir=fhe_dir, key_dir=key_dir)
|
| 216 |
+
|
| 217 |
+
# force yeni key yaratması için: eski key'leri sildik zaten
|
| 218 |
serialized_eval_keys = client.get_serialized_evaluation_keys()
|
| 219 |
|
| 220 |
return str(serialized_eval_keys[:120]) + "..."
|
|
|
|
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
+
|
| 227 |
def encrypt_excel(file):
|
| 228 |
global encrypted_input
|
| 229 |
if client is None:
|