From 3056252ccc78e2879429d76796f0aa1ffdf6435a Mon Sep 17 00:00:00 2001 From: Alexander Suslov Date: Mon, 25 Sep 2023 11:35:32 +0400 Subject: [PATCH] migrate to ov.save_model(...) --- .../anomaly_stfpm_quantize_with_accuracy_control/main.py | 4 ++-- .../post_training_quantization/openvino/mobilenet_v2/main.py | 4 ++-- examples/post_training_quantization/openvino/yolov8/main.py | 2 +- .../openvino/yolov8_quantize_with_accuracy_control/main.py | 2 +- .../post_training_quantization/torch/mobilenet_v2/main.py | 4 ++-- .../post_training_quantization/torch/ssd300_vgg16/main.py | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/post_training_quantization/openvino/anomaly_stfpm_quantize_with_accuracy_control/main.py b/examples/post_training_quantization/openvino/anomaly_stfpm_quantize_with_accuracy_control/main.py index daaa491e4ba..17564e61a06 100644 --- a/examples/post_training_quantization/openvino/anomaly_stfpm_quantize_with_accuracy_control/main.py +++ b/examples/post_training_quantization/openvino/anomaly_stfpm_quantize_with_accuracy_control/main.py @@ -165,12 +165,12 @@ def transform_fn(data_item): # Benchmark performance, calculate compression rate and validate accuracy fp32_ir_path = f"{ROOT}/stfpm_fp32.xml" -ov.serialize(ov_model, fp32_ir_path) +ov.save_model(ov_model, fp32_ir_path, compress_to_fp16=False) print(f"[1/7] Save FP32 model: {fp32_ir_path}") fp32_size = get_model_size(fp32_ir_path, verbose=True) int8_ir_path = f"{ROOT}/stfpm_int8.xml" -ov.serialize(ov_quantized_model, int8_ir_path) +ov.save_model(ov_quantized_model, int8_ir_path, compress_to_fp16=False) print(f"[2/7] Save INT8 model: {int8_ir_path}") int8_size = get_model_size(int8_ir_path, verbose=True) diff --git a/examples/post_training_quantization/openvino/mobilenet_v2/main.py b/examples/post_training_quantization/openvino/mobilenet_v2/main.py index 2cc6ab0329f..8986bedb5ab 100644 --- a/examples/post_training_quantization/openvino/mobilenet_v2/main.py +++ b/examples/post_training_quantization/openvino/mobilenet_v2/main.py @@ -137,12 +137,12 @@ def transform_fn(data_item): # Benchmark performance, calculate compression rate and validate accuracy fp32_ir_path = f"{ROOT}/mobilenet_v2_fp32.xml" -ov.serialize(ov_model, fp32_ir_path) +ov.save_model(ov_model, fp32_ir_path, compress_to_fp16=False) print(f"[1/7] Save FP32 model: {fp32_ir_path}") fp32_model_size = get_model_size(fp32_ir_path, verbose=True) int8_ir_path = f"{ROOT}/mobilenet_v2_int8.xml" -ov.serialize(ov_quantized_model, int8_ir_path) +ov.save_model(ov_quantized_model, int8_ir_path, compress_to_fp16=False) print(f"[2/7] Save INT8 model: {int8_ir_path}") int8_model_size = get_model_size(int8_ir_path, verbose=True) diff --git a/examples/post_training_quantization/openvino/yolov8/main.py b/examples/post_training_quantization/openvino/yolov8/main.py index f20730970f6..8b9718e239c 100644 --- a/examples/post_training_quantization/openvino/yolov8/main.py +++ b/examples/post_training_quantization/openvino/yolov8/main.py @@ -158,7 +158,7 @@ def main(): # Quantize mode in OpenVINO representation quantized_model = quantize(ov_model, data_loader, validator) quantized_model_path = Path(f"{ROOT}/{MODEL_NAME}_openvino_model/{MODEL_NAME}_quantized.xml") - ov.serialize(quantized_model, str(quantized_model_path)) + ov.save_model(quantized_model, str(quantized_model_path), compress_to_fp16=False) # Validate FP32 model fp_stats, total_images, total_objects = validate(ov_model, tqdm(data_loader), validator) diff --git a/examples/post_training_quantization/openvino/yolov8_quantize_with_accuracy_control/main.py b/examples/post_training_quantization/openvino/yolov8_quantize_with_accuracy_control/main.py index a6e17830289..b8440e1a0c4 100644 --- a/examples/post_training_quantization/openvino/yolov8_quantize_with_accuracy_control/main.py +++ b/examples/post_training_quantization/openvino/yolov8_quantize_with_accuracy_control/main.py @@ -222,7 +222,7 @@ def main(): quantized_model = quantize_ac(ov_model, data_loader, validator) quantized_model_path = Path(f"{ROOT}/{MODEL_NAME}_openvino_model/{MODEL_NAME}_quantized.xml") - ov.serialize(quantized_model, str(quantized_model_path)) + ov.save_model(quantized_model, str(quantized_model_path), compress_to_fp16=False) # Validate FP32 model fp_stats, total_images, total_objects = validate(ov_model, tqdm(data_loader), validator) diff --git a/examples/post_training_quantization/torch/mobilenet_v2/main.py b/examples/post_training_quantization/torch/mobilenet_v2/main.py index 9297d5cf94f..426f6f8f0df 100644 --- a/examples/post_training_quantization/torch/mobilenet_v2/main.py +++ b/examples/post_training_quantization/torch/mobilenet_v2/main.py @@ -173,12 +173,12 @@ def transform_fn(data_item): ov_quantized_model = mo.convert_model(int8_onnx_path) fp32_ir_path = f"{ROOT}/mobilenet_v2_fp32.xml" -ov.serialize(ov_model, fp32_ir_path) +ov.save_model(ov_model, fp32_ir_path, compress_to_fp16=False) print(f"[1/7] Save FP32 model: {fp32_ir_path}") fp32_model_size = get_model_size(fp32_ir_path, verbose=True) int8_ir_path = f"{ROOT}/mobilenet_v2_int8.xml" -ov.serialize(ov_quantized_model, int8_ir_path) +ov.save_model(ov_quantized_model, int8_ir_path, compress_to_fp16=False) print(f"[2/7] Save INT8 model: {int8_ir_path}") int8_model_size = get_model_size(int8_ir_path, verbose=True) diff --git a/examples/post_training_quantization/torch/ssd300_vgg16/main.py b/examples/post_training_quantization/torch/ssd300_vgg16/main.py index c90ee304e2c..d598d1f1ac2 100644 --- a/examples/post_training_quantization/torch/ssd300_vgg16/main.py +++ b/examples/post_training_quantization/torch/ssd300_vgg16/main.py @@ -163,12 +163,12 @@ def main(): ov_quantized_model = mo.convert_model(int8_onnx_path) fp32_ir_path = f"{ROOT}/ssd300_vgg16_fp32.xml" - ov.serialize(ov_model, fp32_ir_path) + ov.save_model(ov_model, fp32_ir_path, compress_to_fp16=False) print(f"[1/7] Save FP32 model: {fp32_ir_path}") fp32_model_size = get_model_size(fp32_ir_path, verbose=True) int8_ir_path = f"{ROOT}/ssd300_vgg16_int8.xml" - ov.serialize(ov_quantized_model, int8_ir_path) + ov.save_model(ov_quantized_model, int8_ir_path, compress_to_fp16=False) print(f"[2/7] Save INT8 model: {int8_ir_path}") int8_model_size = get_model_size(int8_ir_path, verbose=True)