mariotawfik commited on
Commit
31cd022
·
1 Parent(s): 4bca5fa
Files changed (1) hide show
  1. app.py +7 -0
app.py CHANGED
@@ -132,6 +132,13 @@ def encode_quantize(test_file, eval_key, encodings):
132
  def encrypt_encoded_quantize(encodings):
133
  fhe_api = FHEModelClient(f"fhe_model", f".fhe_keys/{eval_key}")
134
  fhe_api.load()
 
 
 
 
 
 
 
135
  quantized_encodings = fhe_api.model.quantize_input(encodings).astype(numpy.uint8)
136
  encrypted_quantized_encoding = fhe_api.quantize_encrypt_serialize(encodings)
137
 
 
132
  def encrypt_encoded_quantize(encodings):
133
  fhe_api = FHEModelClient(f"fhe_model", f".fhe_keys/{eval_key}")
134
  fhe_api.load()
135
+
136
+ encodings = np.array(encodings, dtype=np.float32)
137
+
138
+ # Check for NaN or Inf values
139
+ if np.isnan(encodings).any() or np.isinf(encodings).any():
140
+ raise ValueError("Encodings contain NaN or Inf values, which cannot be processed.")
141
+
142
  quantized_encodings = fhe_api.model.quantize_input(encodings).astype(numpy.uint8)
143
  encrypted_quantized_encoding = fhe_api.quantize_encrypt_serialize(encodings)
144