Intel® Distribution of OpenVINO™ Toolkit
Community assistance about the Intel® Distribution of OpenVINO™ toolkit, OpenCV, and all aspects of computer vision-related on Intel® platforms.
6403 Discussions

Extracting model weights after loading model

sovit
Beginner
824 Views

Hello, I am trying to extract/print the model weight values after loading the network using ie.read_network().

I am using OpenVINO 2021.3 and loading Tiny YOLO4 weights. I have already tried these two methods as proposed in the Intel community forum.

1. https://community.intel.com/t5/Intel-Distribution-of-OpenVINO/Quantized-weight-extraction/m-p/1226110

2. https://community.intel.com/t5/Intel-Distribution-of-OpenVINO/Extract-Weights-from-Binary-files/m-p/1140013

 

But in both cases I am getting the following error:

AttributeError: 'openvino.inference_engine.ie_api.IENetwork' object has no attribute 'layers'

Any help regarding this is appreciated. 

Thanks.

0 Kudos
4 Replies
Iffa_Intel
Moderator
803 Views

Hi,


Usually, that kind of error means that you didn't properly link OpenVINO library/packages or that particular library mentioned actually does not exist(you didn't install).


The setupvars should link all required library for OpenVINO. That is why it is required to be run before running anything in the OpenVINO package.


The error could also mean that you didn't call a certain library/ function properly (especially if you are creating your own custom code).


This example is the simplest that could be used as a test: https://docs.openvinotoolkit.org/latest/openvino_inference_engine_ie_bridges_python_sample_hello_classification_README.html


You may study how this application is built and apply it to yours.





Sincerely,

Iffa


0 Kudos
sovit
Beginner
795 Views

Thanks for the response. But when I remove that particular line where I am trying to print the layers' weights, then the entire code runs fine along with the inference. So, I am not sure what causes that issue.

Also, the two links I mentioned, use different methods for extracting the layers. Can you please point out which is the correct method as of version 2021.3? It will help me to figure some of my next steps a bit faster.

 

Thanks,

Sovit

0 Kudos
Iffa_Intel
Moderator
783 Views

Definitely your "print the layers' weights" function has something wrong. Probably you are calling a variable/function that does not exist or could be something else. Anyway, the error that you get is related to the library linking as I had said previously.

 

Maybe the program tried to find the non-existent variable/function in the library and couldn't find it, thus giving out the error.

 

If you are trying to follow the link that you gave, at least you should be able to see the values as what that guy tried:

https://community.intel.com/t5/Intel-Distribution-of-OpenVINO/Quantized-weight-extraction/m-p/1226110

 

If yours is related to Quantization as the above link (which you gave previously), this is what you should study:

https://docs.openvinotoolkit.org/latest/pot_compression_algorithms_quantization_README.html

 

 

Sincerely,

Iffa

 

 

 

0 Kudos
Iffa_Intel
Moderator
751 Views

Greetings,


Intel will no longer monitor this thread since we have provided a solution. If you need any additional information from Intel, please submit a new question. 



Sincerely,

Iffa


0 Kudos
Reply