{"id":20685466,"url":"https://github.com/yas-sim/openvino-wrapper","last_synced_at":"2025-04-22T13:40:46.120Z","repository":{"id":185235200,"uuid":"255824950","full_name":"yas-sim/openvino-wrapper","owner":"yas-sim","description":"This is a tiny Python class library to wrap and abstract the OpenVINO Inference Engine.","archived":false,"fork":false,"pushed_at":"2020-05-30T03:32:50.000Z","size":13192,"stargazers_count":9,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-29T15:34:51.789Z","etag":null,"topics":["class-library","deep-learning","face-detection","face-landmark-detection","gaze-estimation","heatmap","image-classification","inference","inference-engine","intel","object-detection","object-tracking","openvino","openvino-inference-engine","openvino-toolkit","python"],"latest_commit_sha":null,"homepage":null,"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,"governance":null}},"created_at":"2020-04-15T06:25:40.000Z","updated_at":"2022-12-04T14:59:12.000Z","dependencies_parsed_at":"2023-08-01T07:09:27.899Z","dependency_job_id":null,"html_url":"https://github.com/yas-sim/openvino-wrapper","commit_stats":null,"previous_names":["yas-sim/openvino-wrapper"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yas-sim%2Fopenvino-wrapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yas-sim%2Fopenvino-wrapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yas-sim%2Fopenvino-wrapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yas-sim%2Fopenvino-wrapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yas-sim","download_url":"https://codeload.github.com/yas-sim/openvino-wrapper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250250242,"owners_count":21399597,"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":["class-library","deep-learning","face-detection","face-landmark-detection","gaze-estimation","heatmap","image-classification","inference","inference-engine","intel","object-detection","object-tracking","openvino","openvino-inference-engine","openvino-toolkit","python"],"created_at":"2024-11-16T22:27:28.625Z","updated_at":"2025-04-22T13:40:46.061Z","avatar_url":"https://github.com/yas-sim.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Overview\r\nThis is a tiny Python class library to wrap and abstract the OpenVINO Inference Engine. With this library, user can write a deep-leaning inferencing program easily.  \r\nこれはOpenVINOのInference EngineのラッパーライブラリでPythonで書かれています。これを使うことによってディープラーニング推論プログラムを数行で書くことが可能です。\r\n\r\n## Description\r\nThis library conceals common initialization and processing for OpenVINO Inference Engine. User can write a few lines of code to run deep-learning inferencing with this.  \r\nThis library works with Intel Distribution of OpenVINO toolkit. Please make sure that you have installed and setup OpenVINO before try this.   \r\nこのライブラリはOpenVINOのInference Engineの共通の初期化処理やデータ処理をまとめてクラス化したものです。ユーザーは数行のコードを書くだけでディープラーニングの推論を行うことが可能です。  \r\nこのライブラリはIntel Distribution of OpenVINO toolkit用のライブラリです。OpenVINOをダウンロードしてセットアップをすることが必要になります。\r\n\r\n[Intel distribution of OpenVINO toolkit](https://software.intel.com/en-us/openvino-toolkit).\r\n\r\n## How easy it is\r\nYou can write a simple image classification program like this.  \r\n簡単な画像分類プログラムならこんな感じで記述できます。  \r\n~~~python\r\nimport iewrap\r\nimport cv2\r\nimport numpy as np\r\n\r\nlabel = open('synset_words.txt').readlines()    # Read class label text file\r\nimg = cv2.imread('car.png')                     # Read an image to infer\r\n\r\nie = iewrap.ieWrapper('public/googlenet-v1/FP16/googlenet-v1.xml', 'CPU')  # Create an Inference Engine object\r\n\r\noutput = ie.blockInfer(img).reshape((1000,))    # Do infer\r\n\r\n# Sort class probabilities and display top 5 classes\r\nidx = np.argsort(output)[::-1]\r\nfor i in range(5):\r\n    print(idx[i]+1, output[idx[i]], label[idx[i]][:-1])\r\n~~~\r\n\r\n## How to use\r\nSample programs are provided with this library. You can try them to learn how to use this library.\r\nBefore you start, you need to install and setup OpenVINO.  \r\nサンプルプログラムが付属しています。これらを実行する前にOpenVINOのインストールとセットアップが必要です。  \r\n\r\n1. Go to Intel distribution of OpenVINO toolkit [web page](https://software.intel.com/en-us/openvino-toolkit) and download an OpenVINO package suitable for your operating system\r\n2. Install OpenVINO and setup support tools and accelerators (optional) by following the instruction in ['Get Started'](https://software.intel.com/en-us/openvino-toolkit/documentation/get-started) page\r\n3. Open a command terminal\r\n4. Clone repository to your system\r\n~~~shell\r\n$ git clone https://github.com/yas-sim/openvino-wrapper\r\n~~~\r\n5. Set up environment variables for OpenVINO\r\n~~~\r\nLinux $ source /opt/intel/openvino/bin/setupvars.sh  \r\n~~~\r\n~~~\r\nWindows \u003e call \"Program Files (x86)\\IntelSWTools\\OpenVINO\\bin\\setupvars.bat\"\r\n~~~\r\n\r\n6. Download images, class label text files, and deep-learning models using a script (`prep.sh`, or `prep.bat`)\r\n7. Run sample programs  \r\n\r\n**`iewrap_classification.py` sample app**  \r\n![iewrap_classification.py](./resources/classification.png)\r\n\r\n**`iewrap_object_detection.py` sample app**  \r\n![iewrap_object_detection.py](./resources/objdet.png)  \r\n\r\n**`iewrap_gaze_estimation.py` sample app**  \r\n![iewrap_gaze_estimation.py](./resources/gaze.png)  \r\n\r\n**`iewrap_object_tracking.py` sample app**  \r\n![iewrap_object_tracking.py](./resources/tracking.gif)  \r\n\r\n**`iewrap_heatmap.py` sample app**  \r\n![iewrap_heatmap.py](./resources/heatmap.gif)  \r\n\r\n\r\n## Document\r\n\r\nThis library supports both blocking (synchronous) inferencing and asynchronous inferencing.  \r\n\r\n1. How to import this library\r\n~~~python\r\nimport iewrap\r\n~~~\r\n\r\n2. API\r\n\r\n~~~python\r\nieWrapper(modelFile=None, device='CPU', numRequest=4)\r\n~~~\r\n- *Description*\r\n - This function creates a `ieWrapper` object.\r\n- *Input*\r\n - `modelFile`: Path to an OpenVINO IR format deep-learning model topology file (`.xml`). A weight file (`.bin`) with the same base file name wil be automatically loaded.\r\n - `device`: Device to run inference. E.g. `CPU`, `GPU`, `MYRIAD`, `HDDL`, `HETERO:FPGA,CPU`. Please refer to the official OpenVINO document for details.\r\n - `numRequest`: Maximum number of simultaneous inferencing. If you specify 4, you can run 4 inferencing task on the device at a time.  \r\n- *Return*\r\n - None\r\n\r\n~~~python\r\nreadModel(xmlFile, binFile, device='CPU', numRequest=4)\r\n~~~\r\n- *Description*\r\n - This function reads an OpenVINO IR model data. User does not need to use this function when you have read the model data in the constructor (`ieWrapper()`).  \r\n- *Input*\r\n - `xmlFile`: Path to an OpenVINO IR format deep-learning model topology file (.xml).\r\n - `binFile`: Path to an OpenVINO IR format deep-learning model weight file (.xml).\r\n - `device`: Device to run inference. E.g. `CPU`, `GPU`, `MYRIAD`, `HDDL`, `HETERO:FPGA,CPU`. Please refer to the official [OpenVINO document](https://docs.openvinotoolkit.org/latest/_docs_IE_DG_supported_plugins_Supported_Devices.html) for details.\r\n - `numRequest`: Maximum number of simultaneous inferencing. If you specify 4, you can run 4 inferencing task on the device at a time.  \r\n- *Return*\r\n - None\r\n\r\n~~~python\r\nsetInputType(blobName, blobType)\r\n~~~\r\n- *Description*\r\n - Set the type of a input blob. The default type is `'image'`. If the data you supply is a non-image data, you need to set the blob type to other one such as `'vec'`. The type is just a string and this library just cares if it's `'image'` or not. If the type is `'image'`, the blob data will go through image preprocess before inferencing (resize and transform).\r\n- *Input*\r\n - `blobName`: Name of the blob to set the type\r\n - `blobType`: A string. `image` or others\r\n- *Output*\r\n - None   \r\n\r\n~~~python\r\n1. outBlob = blockInfer(ocvImg)     # for single input model\r\n2. outBlob = blockInfer(inputDict)  # for multiple input model\r\n~~~\r\n- *Description*\r\n - Start blocking (synchronous) inferencing. The control won't back until the inference task is completed. You can immediately start processing the result after this function call. Blocking inferencing is easy to use but not efficient in terms of computer resource utilization.\r\n- *Input*\r\n - `ocvimg`: OpenCV image data to infer. The image will be resized and transformed to fit to the input blob of the model. The library doesn't swap color channels (such as BGR to RGB). You can use this style of API when your model has single input.\r\n - `inputDict`: Input blob data in `{'blobname':blobData}` style dictionary.   \r\n   - The default blob type is `'image'`. You must set appropriate blob type before you start inferencing with `setInputType()` API. If the blob type is `'image'`, the blob data is considered as an OpenCV image data and go through image preprocessing before inferencing (resize and transform), otherwise the blob data will be just passed to the Inference Engine without any preprocessing.\r\n   - You must use this style of API when your model has multiple inputs. \r\n   - e.g. `{ 'data' : data, 'data1' : data1 }`\r\n- *Return*\r\n - `outBlob`: Output result of the inferencing\r\n  - Single output model: `outBlob` contains the data of the output blob.\r\n  - Multiple output model: `outBlob` contains a dictionary which contains the outputs of the model.\r\n    - Key: The name of an output blob\r\n    - Value: The contents of an output blob\r\n    - e.g. `{ 'prob' : data }`\r\n\r\n~~~python\r\n1. infID = asyncInfer(ocvimg)     # for single input model\r\n2. infID = asyncInfer(inputDict)  # for multiple input model\r\n~~~\r\n- *Description*\r\n - Start asynchronous inferencing. Set a callback function before you call this function or the inferencing result will be wasted.\r\n- *Input*\r\n - `ocvimg`: OpenCV image data to infer. The image will be resized and transformed to fit to the input blob of the model. The library doesn't swap color channels (such as BGR to RGB). You can use this style of API when your model has single input.\r\n - `inputDict`: Input blob data in `{'blobname':blobData}` style dictionary.   \r\n   - The default blob type is `'image'`. You must set appropriate blob type before you start inferencing with `setInputType()` API. If the blob type is `'image'`, the blob data is considered as an OpenCV image data and go through image preprocessing before inferencing (resize and transform), otherwise the blob data in will be just passed to the Inference Engine without any preprocessing.\r\n   - You must use this style of API when your model has multiple inputs. \r\n   - e.g. `{ 'data' : data, 'data1' : data1 }`\r\n- *Return*\r\n - `infID`: ID number of the requested inferencing task\r\n\r\n~~~python\r\nsetCallback(callback)\r\n~~~\r\n- *Description*\r\n - Set a callback function which will be called after completion of each asynchronous inferencing.\r\n- *Input*\r\n - `callback`: Name of the callback function. The callback function will receive 1 tuple parameter. The tuple consists of `infID` and `outBlob` `(infID, outBlob)`. You can check the inference result with `outBlob` and identify the reuslt is for which inference request by the `infID`.\r\n  - The contents of the `outBlob` varies depend on the number of outputs of the model.\r\n    - Single output model: The `outBlob` contains the contents of the output Blob.\r\n    - Multiple output model: `outBlob` contains a dictionary which contains the outputs of the model.\r\n      - Key: The name of an output blob\r\n      - Value: The contents of an output blob\r\n    - e.g. `{ 'prob' : data }`\r\n- *Return*\r\n - None\r\n \r\n~~~python\r\ndict = getInputs()\r\n~~~\r\n- *Description*\r\n - Return a dictionary which represents the input of the model you have loaded.\r\n- *Input*\r\n - None\r\n- *Output*\r\n - Information of the input blobs of the loaded model in a dictionary.\r\n - The dict format is: `{ blobName : { 'data':blobData, 'shape':blobShape, 'type':blobType }, ... }`.\r\n   - `blobType` is a string. The value can be `image`, or others. If the type is `image`, the `blobData` will go through image preprocess before inferencing.\r\n\r\n~~~python\r\ndict = getOutputs()\r\n~~~\r\n- *Description*\r\n - Return a list of dictionary which represents the output of the model you have loaded.\r\n- *Input*\r\n - None\r\n- *Output*\r\n - Information of the output blobs of the loaded model in a dictionary.\r\n - The dict format is: `{ blobName : { 'shape':blobShape }, ... }`.   \r\n\r\n## Requirement\r\nThis workshop requires [Intel distribution of OpenVINO toolkit](https://software.intel.com/en-us/openvino-toolkit).\r\n\r\n## Contribution\r\n\r\n## Licence\r\n\r\n[Apache2](http://www.apache.org/licenses/LICENSE-2.0.txt)\r\n\r\n## Author\r\n\r\n[Yasunori Shimura](https://github.com/yassim-intel)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyas-sim%2Fopenvino-wrapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyas-sim%2Fopenvino-wrapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyas-sim%2Fopenvino-wrapper/lists"}