-
Notifications
You must be signed in to change notification settings - Fork 5
/
run.py
21 lines (14 loc) · 853 Bytes
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import coremltools
from coremltools.models.neural_network.quantization_utils import *
mode_name = "food"
model = coremltools.models.MLModel(mode_name+".mlmodel")
functions = ["linear", "linear_lut", "kmeans"]
for function in functions :
for bit in [16,8,7,6,5,4,3,2,1]:
print("processing ",function," on ",bit,".")
lin_quant_model = quantize_weights(model, bit, function)
lin_quant_model.short_description = str(bit)+" bit per quantized weight, using "+function+"."
lin_quant_model.save(mode_name+"_"+function+"_"+str(bit)+".mlmodel")
compare_models(model, lin_quant_model, 'testing_data/pizza')
#compare_models(model, lin_quant_model, '/Users/rezashirazian/Projects/Practice/Quantize/testing_data/pizza')
# lin_quant_model.save("/Users/rezashirazian/Projects/Practice/Quantize/food_8_linear.mlmodel")