File size: 829 Bytes
2dcbc14
fe8d446
68c9ed6
2dcbc14
 
 
 
 
 
68c9ed6
 
2dcbc14
 
68c9ed6
 
2dcbc14
 
68c9ed6
2dcbc14
 
 
 
68c9ed6
2dcbc14
 
68c9ed6
 
2dcbc14
 
68c9ed6
2dcbc14
fee1bf4
2dcbc14
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import pandas as pd
from concrete.ml.deployment import FHEModelDev
from concrete.ml.common.serialization.loaders import load
import shutil
from pathlib import Path


script_dir = Path(__file__).parent

DEPLOYMENT_DIR = script_dir / "deployment"

print("Compiling the model...")

with (DEPLOYMENT_DIR / "serialized_model").open("r") as file:
    model = load(file)

# Load the data from the csv file to be used for compilation
data = pd.read_csv(DEPLOYMENT_DIR / "samples_for_compilation.csv", index_col=0).values

# Compile the model
model.compile(data)

dev_model_path = DEPLOYMENT_DIR / "sentiment_fhe_model"

# Delete the deployment folder if it exist
if dev_model_path.is_dir():
    shutil.rmtree(dev_model_path)

fhe_api = FHEModelDev(
    model=model, path_dir=dev_model_path
)
fhe_api.save(via_mlir=True)


print("Done!")