diff --git a/examples/post_training_quantization/onnx/mobilenet_v2/main.py b/examples/post_training_quantization/onnx/mobilenet_v2/main.py index 007b537ceb6..5f9850f8cbe 100755 --- a/examples/post_training_quantization/onnx/mobilenet_v2/main.py +++ b/examples/post_training_quantization/onnx/mobilenet_v2/main.py @@ -16,7 +16,7 @@ import numpy as np import onnx -import openvino.runtime as ov +import openvino as ov import torch from fastdownload import FastDownload from fastdownload import download_url 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 17564e61a06..88393421801 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 @@ -19,7 +19,7 @@ from typing import Any, Dict, Iterable, List, Optional, Tuple import numpy as np -import openvino.runtime as ov +import openvino as ov import torch from anomalib.data.mvtec import MVTec from anomalib.data.utils import download @@ -169,6 +169,10 @@ def transform_fn(data_item): print(f"[1/7] Save FP32 model: {fp32_ir_path}") fp32_size = get_model_size(fp32_ir_path, verbose=True) +# To avoid an accuracy drop when saving a model due to compression of unquantized +# weights to FP16, compress_to_fp16=False should be used. This is necessary because +# nncf.quantize_with_accuracy_control(...) keeps the most impactful operations within +# the model in the original precision to achieve the specified model accuracy. int8_ir_path = f"{ROOT}/stfpm_int8.xml" ov.save_model(ov_quantized_model, int8_ir_path, compress_to_fp16=False) print(f"[2/7] Save INT8 model: {int8_ir_path}") diff --git a/examples/post_training_quantization/openvino/mobilenet_v2/main.py b/examples/post_training_quantization/openvino/mobilenet_v2/main.py index 8986bedb5ab..d6533bd61d8 100644 --- a/examples/post_training_quantization/openvino/mobilenet_v2/main.py +++ b/examples/post_training_quantization/openvino/mobilenet_v2/main.py @@ -16,7 +16,7 @@ from typing import List, Optional import numpy as np -import openvino.runtime as ov +import openvino as ov import torch from fastdownload import FastDownload from sklearn.metrics import accuracy_score diff --git a/examples/post_training_quantization/openvino/yolov8/main.py b/examples/post_training_quantization/openvino/yolov8/main.py index 8b9718e239c..8280d9391b4 100644 --- a/examples/post_training_quantization/openvino/yolov8/main.py +++ b/examples/post_training_quantization/openvino/yolov8/main.py @@ -14,7 +14,7 @@ from typing import Any, Dict, Tuple import numpy as np -import openvino.runtime as ov +import openvino as ov import torch from tqdm import tqdm from ultralytics.cfg import get_cfg 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 b8440e1a0c4..f56bbed26bf 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 @@ -15,7 +15,7 @@ from typing import Any, Dict, Tuple import numpy as np -import openvino.runtime as ov +import openvino as ov import torch from tqdm import tqdm from ultralytics.cfg import get_cfg diff --git a/examples/post_training_quantization/torch/mobilenet_v2/main.py b/examples/post_training_quantization/torch/mobilenet_v2/main.py index 426f6f8f0df..35f9b35c06c 100644 --- a/examples/post_training_quantization/torch/mobilenet_v2/main.py +++ b/examples/post_training_quantization/torch/mobilenet_v2/main.py @@ -16,7 +16,7 @@ from typing import List, Optional import numpy as np -import openvino.runtime as ov +import openvino as ov import torch from fastdownload import FastDownload from openvino.tools import mo diff --git a/examples/post_training_quantization/torch/ssd300_vgg16/main.py b/examples/post_training_quantization/torch/ssd300_vgg16/main.py index d598d1f1ac2..6c495ec03ce 100644 --- a/examples/post_training_quantization/torch/ssd300_vgg16/main.py +++ b/examples/post_training_quantization/torch/ssd300_vgg16/main.py @@ -18,7 +18,7 @@ import nncf from nncf.torch import disable_tracing -import openvino.runtime as ov +import openvino as ov import torch import torchvision from fastdownload import FastDownload