Spaces:
Runtime error
Runtime error
Update app.py
Browse files91 unmodified lines929394959697989910010110210310410510610710810911011111211311411511611711835 unmodified lines15415515615715815991 unmodified linesuser_id = eval_key[1]return eval_key[0]def safe_eval(encodings):try:# Debugging: Print the encodings string to understand its formatprint("Original Encodings String:", encodings)# Replace newline characters and multiple spacessanitized = encodings.replace('\n', ',').replace(' ', '')sanitized = sanitized.replace(',,', ',') # Remove accidental double commas# Ensure the string starts and ends properly for evaluationif not sanitized.startswith("["):sanitized = "[" + sanitizedif not sanitized.endswith("]"):sanitized = sanitized + "]"print("Sanitized Encodings String:", sanitized)return eval(sanitized)except SyntaxError as e:raise ValueError(f"Failed to safely parse the encodings string: {e}")def encode_quantize(test_file, eval_key, encodings):ugly = ['Machine', 'SizeOfOptionalHeader', 'Characteristics',35 unmodified linesfhe_api = FHEModelClient(f"fhe_model", f".fhe_keys/{eval_key}")fhe_api.load()quantized_encodings = fhe_api.model.quantize_input(encodings).astype(numpy.uint8)encrypted_quantized_encoding = fhe_api.quantize_encrypt_serialize(encodings)91 unmodified lines92939495969735 unmodified lines13313413513613713813991 unmodified linesuser_id = eval_key[1]return eval_key[0]def encode_quantize(test_file, eval_key, encodings):ugly = ['Machine', 'SizeOfOptionalHeader', 'Characteristics',35 unmodified linesfhe_api = FHEModelClient(f"fhe_model", f".fhe_keys/{eval_key}")fhe_api.load()encodings = json.loads(encodings)quantized_encodings = fhe_api.model.quantize_input(encodings).astype(numpy.uint8)encrypted_quantized_encoding = fhe_api.quantize_encrypt_serialize(encodings)
app.py+1-21