-
Notifications
You must be signed in to change notification settings - Fork 213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ERROR : While Quantization of OpenVINO model #1631
Comments
Greetings, @ashish-2005! Please provide a complete stack trace of your error and perhaps more complete reproduction code (including the way to obtain the model .xml/.bin files) so that we could help you out here. |
Hii @vshampor
MODEL_DIR_PATH = pathlib.Path("SavedModel")
MODEL_DIR_PATH.mkdir(exist_ok=True)
tf.saved_model.save(model,str(MODEL_DIR_PATH))
from openvino.tools import mo
from openvino.runtime import serialize
model_ir = mo.convert_model(saved_model_dir=str(MODEL_DIR_PATH))
serialize(model_ir,'IR/efficientdet.xml')
def transform_fn(data_item):
"""
Create an image tensor for the quantization process
Parameters:
data_item : tensorflow dataset object
Returns:
img(tf.tensor) : tensor of image in shape (1,512,512,3)
"""
data_item = pathlib.Path(data_item.numpy().decode('UTF8'))
img = preprocess_image(data_item)
return img
# creating dataset for accuracy testing
dataloader = tf.data.Dataset.list_files('coco/images/val2017/*.jpg',shuffle=False) # itterable Data Object
quantization_dataset = nncf.Dataset(dataloader, transform_fn)
# loading original openvino-model for quantization
OpenVino_model = core.read_model(model='IR/efficientdet.xml',weights='IR/efficientdet.bin')
quantized_model = nncf.quantize(OpenVino_model, quantization_dataset) Whole Error
Regards |
@KodiaqQ take a look, please |
Hello, @ashish-2005! |
Hii @KodiaqQ I have attached the model .xml file (efficientdet.zip) Regards |
Hello @ashish-2005, Thanks for provided model. We are working on the fix of the original issue. I can kindly offer to use the experimental implementation of quantization based on using OpenVINO NGraph Python API as workaround. It will replace the current implementation in the future. The following code demonstrates how to call the experimental implementation of quantization: from nncf.experimental.openvino_native.quantization.quantize import quantize_impl
ov_model = ov.Core().read_model('path_to_fp32_model')
ov_model.reshape({0: [1, 512, 512, 3]}) # model reshape is required
dataloader = tf.data.Dataset.list_files('path_to_dataset',shuffle=False)
def transform_fn(data_item):
data_item = pathlib.Path(data_item.numpy().decode('UTF8'))
img = preprocess_image(data_item)
return img
quantization_dataset = nncf.Dataset(dataloader, transform_fn)
quantized_model = quantize_impl(ov_model, quantization_dataset,
preset=nncf.QuantizationPreset.PERFORMANCE,
target_device=nncf.TargetDevice.ANY,
subset_size=300,
fast_bias_correction=True) Please, use NNCF from the source code with the following fixes #1665, #1633 and the latest OpenVINO from the master branch. |
### Changes The linear squeeze activation pattern was added ### Reason for changes Align with the OpenVINO runtime ### Related tickets #1631 ### Tests N/A
Dear @ashish-2005 , All the mentioned above fixes have been merged to recent NNCF 2.5.0 release. Have you tried it? Is your problem still valid? |
Hii @MaximProshin Thanks for reply, I haven't tried it yet but will try and inform you soon. thanks |
Hii
I am getting a
KeyError
while the quantization process of OpenVINO modelMy openVINO model is made of IR of a tensorflow model (pre-trained from tensorflow-hub)
ERROR
I have tried reinstalling nncf with tensorflow
pip install nncf[tensorflow2]
and still no luck.The text was updated successfully, but these errors were encountered: