File size: 1,132 Bytes
21c7197 3cf0931 21c7197 4bee342 21c7197 4bee342 21c7197 4bee342 21c7197 3cf0931 21c7197 3cf0931 4bee342 21c7197 3cf0931 21c7197 3cf0931 21c7197 4bee342 21c7197 |
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 37 38 |
"A script to generate all development files necessary for the image filtering demo."
import shutil
import onnx
from common import AVAILABLE_FILTERS, FILTERS_PATH
from filters import Filter
from concrete.ml.deployment import FHEModelDev
print("Generating deployment files for all available filters")
for filter_name in AVAILABLE_FILTERS:
print("Filter:", filter_name, "\n")
# Create the filter instance
filter = Filter(filter_name)
# Compile the model on a representative inputset
filter.compile()
# Define the directory path associated to this filter
filter_path = FILTERS_PATH / filter_name
# Define the directory path associated to this filter's deployment files
deployment_path = filter_path / "deployment"
# Delete the deployment folder and its content if it already exists
if deployment_path.is_dir():
shutil.rmtree(deployment_path)
# Save the files needed for deployment
fhe_dev_filter = FHEModelDev(deployment_path, filter)
fhe_dev_filter.save()
# Save the ONNX model
onnx.save(filter.onnx_model, filter_path / "server.onnx")
print("Done !")
|