{"id":20685498,"url":"https://github.com/yas-sim/openvino-ir-utility","last_synced_at":"2025-04-22T13:40:18.796Z","repository":{"id":41039124,"uuid":"266482351","full_name":"yas-sim/openvino-ir-utility","owner":"yas-sim","description":"Utility tool for Intel(r) OpenVINO(tm) IR models. The tool can display detailed model information, layer information and can check compatibility. The tool also can extract weight data and feature map from the IR model.","archived":false,"fork":false,"pushed_at":"2022-06-28T02:48:00.000Z","size":299,"stargazers_count":11,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-29T15:34:43.704Z","etag":null,"topics":["deep-learning","deep-learning-models","feature-map","intel","model-weights","openvino","openvino-toolkit","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yas-sim.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-24T06:19:28.000Z","updated_at":"2025-01-22T18:43:50.000Z","dependencies_parsed_at":"2022-09-01T19:30:56.118Z","dependency_job_id":null,"html_url":"https://github.com/yas-sim/openvino-ir-utility","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yas-sim%2Fopenvino-ir-utility","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yas-sim%2Fopenvino-ir-utility/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yas-sim%2Fopenvino-ir-utility/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yas-sim%2Fopenvino-ir-utility/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yas-sim","download_url":"https://codeload.github.com/yas-sim/openvino-ir-utility/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250250232,"owners_count":21399593,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deep-learning","deep-learning-models","feature-map","intel","model-weights","openvino","openvino-toolkit","python"],"created_at":"2024-11-16T22:27:34.668Z","updated_at":"2025-04-22T13:40:18.744Z","avatar_url":"https://github.com/yas-sim.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Intel(r) OpenVINO(tm) IR model utility tool\r\nThis is a utility tool for OpenVINO IR model file. This tool has following functions:\r\n\r\nUpdate on 02-APR-2022 : Add IRv11 and OpenVINO 2022.1 API2.0 Support.\r\n\r\n1. Display IR model summary information (`ir-summary.py`)  \r\n  Displays IR version, Input/Output blob names and shapes\r\n\r\n2. Weight data extraction (`ir_weight_extractor.py`)  \r\n  Extract weight data from an IR model and ganerates a pickle file\r\n\r\n3. Extract the feature map (intermediate buffer between layers) from an IR model (`ir_featuremap_extractor.py`)  \r\n  Run an IR model and extract the feature map data of all layers and generates a pickle file\r\n\r\n4. Compare the feature map data files (`compare_feature_maps.py`)  \r\n  Compare two feature map files and check the difference. This tool might be helpful for finding a problem point in accuracy problem between different type of OpenVINO plugins.  \r\n\r\n5. Calculate individual output blob size of an OpenVINO IR model (`ir_output_blob_size_calculator.py`)  \r\n  The tool calculates the output blob size of layers in an IR model and summarize it. You can use it to identify the memory hungry layers in the model.  \r\n\r\n6. Separate the header (XML), weight (.bin), and graph (.xml) from a compiled model for CPU (`exported_model_disassembler.py`)  \r\n  The tool will split the compiled model into 3 files for further analysis or study.  \r\n\r\n\r\nOpenVINOのIRモデル用のユーティリティーツールプログラムです。このツールは下記の機能を持っています。\r\n1. IRモデルのサマリー情報表示 (`ir-summary.py`)  \r\n  IRバージョン、input / output blob名、shape\r\n2. IRモデルの重みデータ抜き出し  (`ir_weight_extractor.py`)  \r\n　重みデータを抜き出し、Python pickleファイルを作成します\r\n3. 特徴マップデータ抜き取り (`ir_featuremap_extractor.py`)  \r\n　IRモデルを実行しながら中間バッファから特徴マップデータを抜き出し、Python pickleファイルを作成します\r\n4. 特徴マップデータ比較ツール (`compare_feature_maps.py`)  \r\n  ２つの特徴マップデータを比較し差異を表示。異なるOpenVINOプラグイン間での精度問題のチェックなどに使えるかもしれない。\r\n5. IRモデル中のレイヤーごとのoutput blobのサイズとそのトータルを求める (`ir_output_blob_sie_calculator.py`)  \r\n  モデル内のどのレイヤーがメモリを多く使うのかなどの調査に利用可能\r\n6. CPU用コンパイル済みモデルをXMLヘッダ、ウェイト(.bin)、グラフ(.xml)の３つのファイルに分解します (`exported_model_disassembler.py`)  \r\n  コンパイル済みモデルがどうなったかを調べたりするのに便利かもしれません。  \r\n\r\n## How to Run\r\n\r\nAll tool are Python scripts. Just run them.\r\n\r\n1. `ir-summary.py`  \r\n*Options:*  \r\n    `-m`, `--model` : Input IR model path  \r\n    `-d`, `--dir`   : Input IR model directory  \r\n\r\n2. `ir_weight_extractor.py`  \r\n  `model_wgt.pickle` file will be generated *at the same directory as the input model* when the input model file name is `model.xml`.  \r\n*Options:*  \r\n    `-m`, `--model` : Input IR model path  \r\n*Output pickle file format:*  \r\nDictionary `{ blobName0 : [ precStr0, shape0, weightBuf0 ], blobName1 : [ precStr1, shape1, weightBuf1 ], ... }`  precStr='FP32', 'FP16', 'I32', ...\r\n\r\n3. `ir_featuremap_extractor.py`  \r\n  `model_featmap.pickle` file will be generated at the same directory as the script file when the input model file name is `model.xml`.  \r\n*IMPORTANT NOTICE:*  \r\nThis program reads `image.jpg` and supply it to the 1st input blob as default. In case your model requires special input data (multiple input blobs, non-image input, etc), you need to modify `prepareInputs()` function to meet the requirements.  \r\n*Options:*  \r\n    `-m`, `--model` : Input IR model path  \r\n    `-i`, `--input` : Input image file path (default=`image.jpg`)  \r\n*Output pickle file format:*  \r\nDictionary `{ blobName0 : [ precStr0, shape0, featMap0 ], blobName1 : [ precStr1, shape1, featMap1 ], ... }`  precStr='FP32', 'FP16', 'I32', ...\r\n\r\n4. `compare_feature_maps.py`  \r\n This program takes 2 extracted feature map files generated by `ir_featuremap_extractor.py` and compare them.  \r\n You may find some hint to resolve accuracy problem of DL models, hopefully :-)  \r\n*Options:*  \r\n  `-r`, `--reference_feature` : input feature map pickle file (.pickle)  \r\n  `-f`, `--feature`           : input feature map pickle file to compare with the reference feature map data (.pickle)  \r\n  `-e`, `--error`             : error tolerance (%). default=10  \r\n  `-v`, `--verbose`           : display error values  \r\n  `-t`, `--top`               : # of error values to display (per layer, with -v option)  \r\n\r\n5. `ir_output_blob_size_calculator.py`  \r\n This program calculates the output blob size of layers in an OpenVINO IR model. The program reads .xml file, parse it and calculate the output blob size. This tool will give you certain level of idea which layer in the model is memory hungry and how much memory might be required to run the model.  \r\n *Options:*  \r\n  `-m`     : input IR model file name (.xml)\r\n\r\n6. `exported_model_disassembler.py`  \r\n This program breaks an compiled model file for CPU into 3 files. The compiled model can be created with `model.export_model()` API and the generated model data consists with multiple part, XML header, binary weight data (.bin portion), and XML graph (.xml portion).  \r\n This program will generate `foo_hdr.xml`, `foo_.bin`, and `foo_.xml` from input file `foo.model`.  \r\n The program takes only the file name as the command line parameter. No flags are available.\r\n ```sh\r\n python exported_model_disassembler.py compiled.model\r\n ```\r\n\r\n------------------\r\n\r\n### Example of visualized weight and feature map which is obtained by `ir_weight_extractor.py` and `ir_featuremap_extractor.py`.  \r\n*Note:* The code to visualize the data is not included in this project.  \r\n**Weight data for convolution**  \r\n![weight](./resources/wgt.png)  \r\n**Feature map generated by a convolution layer**  \r\n![feature](./resources/feat.png)  \r\n\r\n## How to read and use Python pickled data\r\n```python\r\nimport pickle\r\nwith open('foo.pickle', 'rb') as f:\r\n    data = pickle.load(f)     # the pickled data will be loaded to `data`\r\n\r\na = data['conv1']\r\n```\r\n\r\n## Examples of command output\r\n\r\n### Model summary - single input file (IR version, input / output blob name and shape)\r\n```sh\r\npython ir-summary.py -m ..\\..\\public\\googlenet-v1\\FP16\\googlenet-v1.xml\r\nModel: ..\\..\\public\\googlenet-v1\\FP16\\googlenet-v1\r\nIR version:10\r\nInput Blob(s):\r\n  BlobName:data, Shape:[1, 3, 224, 224], Precision:FP32\r\nOutput Blob(s):\r\n  BlobName:prob, Shape:[1, 1000], Precision:FP32\r\n```\r\n\r\n### Model summary - multiple input files (IR version, input / output blob name and shape)\r\n```sh\r\n\u003e python ir-summary.py -d ..\\..\\public\r\nModel: ..\\..\\public\\googlenet-v1\\FP16\\googlenet-v1\r\nIR version:10\r\nInput Blob(s):\r\n  BlobName:data, Shape:[1, 3, 224, 224], Precision:FP32\r\nOutput Blob(s):\r\n  BlobName:prob, Shape:[1, 1000], Precision:FP32\r\n\r\nModel: ..\\..\\public\\googlenet-v1\\FP32\\googlenet-v1\r\nIR version:10\r\nInput Blob(s):\r\n  BlobName:data, Shape:[1, 3, 224, 224], Precision:FP32\r\nOutput Blob(s):\r\n  BlobName:prob, Shape:[1, 1000], Precision:FP32\r\n  :\r\n```\r\n\r\n### IR model weight extraction - `ir_weight_extractor.py`\r\n```sh\r\npython ir_weight_extractor.py -m public\\googlenet-v1\\FP16\\googlenet-v1.xml\r\n*** OpenVINO IR model weight data extractor\r\n    size : nodeName\r\n       6 : data_add_/copy_const\r\n   18816 : 175/Output_0/Data__const\r\n     128 : conv1/7x7_s2/Dims2528/copy_const\r\n       8 : pool1/norm16956/value6958_const\r\n      :\r\n     256 : inception_5b/pool_proj/Dims2558/copy_const\r\n      16 : loss3/classifier/flatten_fc_input/Cast_18765_const\r\n 2048000 : loss3/classifier/WithoutBiases/1_port_transpose6482_const\r\n    2000 : 238/Output_0/Data_/copy_const\r\n\r\npublic\\googlenet-v1\\FP16\\googlenet-v1_wgt.pickle is generated\r\n```\r\n\r\n### Feature map extraction - `ir_featuremap_extractor.py`\r\n```sh\r\npython ir_featuremap_checker.py -m googlenet-v1.xml -i car_1.bmp\r\n*** OpenVINO feature map extractor\r\n@@@ This program takes 'image.jpg' and supply to the 1st input blob as default.\r\n@@@ In case your model requires special data input, you need to modify 'prepareInputs()' function to meet the requirements.\r\nnode# : nodeName\r\n0 : data\r\n2 : Add_\r\n4 : conv1/7x7_s2/WithoutBiases\r\n6 : conv1/7x7_s2\r\n :      :\r\n318 : loss3/classifier/WithoutBiases\r\n320 : loss3/classifier\r\n321 : prob\r\n\r\nFeature maps are output to 'googlenet-v1_featmap.pickle'\r\n```\r\n### Feature map comparison - `compare_feature_maps.py`\r\n```sh\r\n\u003epython compare_feature_maps.py -f googlenet-v1_featmap_cpu.pickle -r googlenet-v1_featmap_gpu.pickle -e 10\r\n*** OpenVINO feature map comparator\r\nError tolerance : 10%\r\nPASS:150528, ERROR:     0, E-Rate:  0.00%, NaN:     0, Inf:     0 - data\r\nPASS:150528, ERROR:     0, E-Rate:  0.00%, NaN:     0, Inf:     0 - Add_\r\nPASS:768060, ERROR: 34756, E-Rate:  4.33%, NaN:     0, Inf:     0 - conv1/7x7_s2/WithoutBiases\r\nPASS:768917, ERROR: 33899, E-Rate:  4.22%, NaN:     0, Inf:     0 - conv1/7x7_s2\r\nPASS:784953, ERROR: 17863, E-Rate:  2.23%, NaN:     0, Inf:     0 - conv1/relu_7x7\r\n  :     :      :       :\r\nPASS: 49824, ERROR:   352, E-Rate:  0.70%, NaN:     0, Inf:     0 - inception_5b/output\r\nPASS:   998, ERROR:    26, E-Rate:  2.54%, NaN:     0, Inf:     0 - pool5/7x7_s1\r\nPASS:   998, ERROR:    26, E-Rate:  2.54%, NaN:     0, Inf:     0 - loss3/classifier/flatten_fc_input\r\nPASS:   977, ERROR:    23, E-Rate:  2.30%, NaN:     0, Inf:     0 - loss3/classifier/WithoutBiases\r\nPASS:   974, ERROR:    26, E-Rate:  2.60%, NaN:     0, Inf:     0 - loss3/classifier\r\nPASS:   957, ERROR:    43, E-Rate:  4.30%, NaN:     0, Inf:     0 - prob\r\n```\r\n\r\n### Output blob size calculation - `ir_output_blob_size_calculator.py`  \r\n```sh\r\n\u003e python ir_output_blob_size_calculator.py -m googlenet-v1.xml\r\n*** OpenVINO IR model output blob size calculator\r\nlayer name, layer type, port num, precision, oblob_size, [dims...]\r\ndata,Parameter,0,FP16,301056,1,3,224,224\r\ndata_add_/copy_const,Const,1,FP16,6,1,3,1,1\r\nAdd_,Add,2,FP16,301056,1,3,224,224\r\n231/Output_0/Data__const,Const,1,FP16,18816,64,3,7,7\r\nconv1/7x7_s2/WithoutBiases,Convolution,2,FP16,1605632,1,64,112,112\r\n :\r\nloss3/classifier/WithoutBiases,MatMul,2,FP16,2000,1,1000\r\n246/Output_0/Data_/copy_const,Const,1,FP16,2000,1,1000\r\nloss3/classifier,Add,2,FP16,2000,1,1000\r\nprob,SoftMax,1,FP16,2000,1,1000\r\nTotal output blob size : 40,878,054B / 38.98MB\r\n```\r\n\r\n## Test environment\r\n- Windows 10\r\n- Intel(r) Distribution of OpenVINO(tm) toolkit 2021.3\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyas-sim%2Fopenvino-ir-utility","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyas-sim%2Fopenvino-ir-utility","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyas-sim%2Fopenvino-ir-utility/lists"}