mariotawfik commited on
Commit
8fe886f
·
verified ·
1 Parent(s): 0afd2c9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -21
app.py CHANGED
@@ -92,27 +92,6 @@ def keygen(eval_key):
92
  user_id = eval_key[1]
93
  return eval_key[0]
94
 
95
- def safe_eval(encodings):
96
- try:
97
- # Debugging: Print the encodings string to understand its format
98
- print("Original Encodings String:", encodings)
99
-
100
- # Replace newline characters and multiple spaces
101
- sanitized = encodings.replace('\n', ',').replace(' ', '')
102
- sanitized = sanitized.replace(',,', ',') # Remove accidental double commas
103
-
104
- # Ensure the string starts and ends properly for evaluation
105
- if not sanitized.startswith("["):
106
- sanitized = "[" + sanitized
107
- if not sanitized.endswith("]"):
108
- sanitized = sanitized + "]"
109
-
110
- print("Sanitized Encodings String:", sanitized)
111
-
112
- return eval(sanitized)
113
- except SyntaxError as e:
114
- raise ValueError(f"Failed to safely parse the encodings string: {e}")
115
-
116
 
117
  def encode_quantize(test_file, eval_key, encodings):
118
  ugly = ['Machine', 'SizeOfOptionalHeader', 'Characteristics',
@@ -154,6 +133,7 @@ def encrypt_encoded_quantize(encodings):
154
  fhe_api = FHEModelClient(f"fhe_model", f".fhe_keys/{eval_key}")
155
  fhe_api.load()
156
 
 
157
  quantized_encodings = fhe_api.model.quantize_input(encodings).astype(numpy.uint8)
158
  encrypted_quantized_encoding = fhe_api.quantize_encrypt_serialize(encodings)
159
 
 
92
  user_id = eval_key[1]
93
  return eval_key[0]
94
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
 
96
  def encode_quantize(test_file, eval_key, encodings):
97
  ugly = ['Machine', 'SizeOfOptionalHeader', 'Characteristics',
 
133
  fhe_api = FHEModelClient(f"fhe_model", f".fhe_keys/{eval_key}")
134
  fhe_api.load()
135
 
136
+ encodings = json.loads(encodings)
137
  quantized_encodings = fhe_api.model.quantize_input(encodings).astype(numpy.uint8)
138
  encrypted_quantized_encoding = fhe_api.quantize_encrypt_serialize(encodings)
139