{"id":20280565,"url":"https://github.com/kiritigowda/mivisionx-inference-analyzer","last_synced_at":"2025-04-11T06:36:44.275Z","repository":{"id":56264006,"uuid":"197285416","full_name":"kiritigowda/mivisionx-inference-analyzer","owner":"kiritigowda","description":"MIVisionX Python Inference Analyzer uses pre-trained ONNX/NNEF/Caffe models to analyze inference results and summarize individual image results","archived":false,"fork":false,"pushed_at":"2020-11-17T22:33:55.000Z","size":12302,"stargazers_count":2,"open_issues_count":1,"forks_count":3,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-25T04:32:36.604Z","etag":null,"topics":["amd","amdgpu","caffe","docker-images","inceptionv4","inference","inference-engine","inference-optimization","mivisionx","mivisionx-inference-analyzer","nnef","nnir","onnx","opencl","openvx","resnet","resnet-50","rocm","squeezenet","vgg"],"latest_commit_sha":null,"homepage":"https://kiritigowda.com/mivisionx-inference-analyzer/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kiritigowda.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":"2019-07-17T00:22:21.000Z","updated_at":"2023-08-10T15:29:00.000Z","dependencies_parsed_at":"2022-08-15T15:40:32.554Z","dependency_job_id":null,"html_url":"https://github.com/kiritigowda/mivisionx-inference-analyzer","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiritigowda%2Fmivisionx-inference-analyzer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiritigowda%2Fmivisionx-inference-analyzer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiritigowda%2Fmivisionx-inference-analyzer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiritigowda%2Fmivisionx-inference-analyzer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kiritigowda","download_url":"https://codeload.github.com/kiritigowda/mivisionx-inference-analyzer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248358533,"owners_count":21090400,"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":["amd","amdgpu","caffe","docker-images","inceptionv4","inference","inference-engine","inference-optimization","mivisionx","mivisionx-inference-analyzer","nnef","nnir","onnx","opencl","openvx","resnet","resnet-50","rocm","squeezenet","vgg"],"created_at":"2024-11-14T13:35:57.884Z","updated_at":"2025-04-11T06:36:44.226Z","avatar_url":"https://github.com/kiritigowda.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n[![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/kiritigowda/MIVisionX-inference-analyzer.svg?logo=lgtm\u0026logoWidth=18)](https://lgtm.com/projects/g/kiritigowda/MIVisionX-inference-analyzer/context:python)\n\n# MIVisionX Python Inference Analyzer\n\n[MIVisionX](https://gpuopen-professionalcompute-libraries.github.io/MIVisionX/) Inference Analyzer Application uses pre-trained `ONNX`/`NNEF`/`Caffe` models to analyze inference results and summarize images.\n\n\u003cp align=\"center\"\u003e\u003cimg width=\"60%\" src=\"data/images/inference_analyzer.gif\" /\u003e\u003c/p\u003e\n\nPre-trained models in [ONNX](https://onnx.ai/), [NNEF](https://www.khronos.org/nnef), \u0026 [Caffe](http://caffe.berkeleyvision.org/) formats are supported by MIVisionX. The app first converts the pre-trained models to AMD Neural Net Intermediate Representation (NNIR), once the model has been translated into AMD NNIR (AMD's internal open format), the Optimizer goes through the NNIR and applies various optimizations which would allow the model to be deployed on to target hardware most efficiently. Finally, AMD NNIR is converted into OpenVX C code, which is compiled and wrapped with a python API to run on any targeted hardware.\n\n* MIVisionX Inference Analyzer - Processing Images\n\u003cp align=\"center\"\u003e\u003cimg width=\"60%\" src=\"data/images/analyzer-1.png\" /\u003e\u003c/p\u003e\n\n* MIVisionX Inference Analyzer - Processing Images Complete\n\u003cp align=\"center\"\u003e\u003cimg width=\"40%\" src=\"data/images/analyzer-2.png\" /\u003e\u003c/p\u003e\n\n* MIVisionX Inference Analyzer - Results\n\u003cp align=\"center\"\u003e\u003cimg width=\"100%\" src=\"data/images/analyzer-3.png\" /\u003e\u003c/p\u003e\n\n## Analyzer Index\n\n* [MIVisionX Model Compiler \u0026 Optimizer](https://github.com/GPUOpen-ProfessionalCompute-Libraries/MIVisionX/tree/master/model_compiler#neural-net-model-compiler--optimizer)\n* [Prerequisites](#prerequisites)\n\t* [Docker for MIVisionX Inference Analyzer](#use-mivisionx-docker)\n* [Usage](#usage)\n\t* [Usage help](#usage-help)\n* [Supported Pre-Trained Model Formats](#supported-pre-trained-model-formats)\n* [Samples](#samples)\n\t* [Sample-1: Using Pre-Trained ONNX Model](#sample-1---using-pre-trained-onnx-model)\n\t* [Sample-2: Using Pre-Trained Caffe Model](#sample-2---using-pre-trained-caffe-model)\n\t* [Sample-3: Using Pre-Trained NNEF Model](#sample-3---using-pre-trained-nnef-model)\n\n## Prerequisites\n\n* Ubuntu `16.04`/`18.04` or CentOS `7.5`/`7.6`\n* [ROCm supported hardware](https://rocm.github.io/ROCmInstall.html#hardware-support) \n\t* AMD Radeon GPU or AMD APU required\n* Latest [ROCm](https://github.com/RadeonOpenCompute/ROCm#installing-from-amd-rocm-repositories)\n* Build \u0026 Install [MIVisionX](https://github.com/GPUOpen-ProfessionalCompute-Libraries/MIVisionX#linux-1)\n\n### Use MIVisionX Docker\n\nMIVisionX provides developers with [docker images](https://hub.docker.com/u/mivisionx) for [Ubuntu 16.04](https://hub.docker.com/r/mivisionx/ubuntu-16.04), [Ubuntu 18.04](https://hub.docker.com/r/mivisionx/ubuntu-18.04), [CentOS 7.5](https://hub.docker.com/r/mivisionx/centos-7.5), \u0026 [CentOS 7.6](https://hub.docker.com/r/mivisionx/centos-7.5). Using docker images developers can quickly prototype and build applications without having to be locked into a single system setup or lose valuable time figuring out the dependencies of the underlying software.\n\n#### Docker with display option\n\n* Check [docker prerequisites](https://github.com/GPUOpen-ProfessionalCompute-Libraries/MIVisionX#docker-workflow-sample-on-ubuntu-1604)\n\n* Start docker with display\n````\n% sudo docker pull mivisionx/ubuntu-16.04:latest\n% xhost +local:root\n% sudo docker run -it --device=/dev/kfd --device=/dev/dri --cap-add=SYS_RAWIO --device=/dev/mem --group-add video --network host --env DISPLAY=unix$DISPLAY --privileged --volume $XAUTH:/root/.Xauthority --volume /tmp/.X11-unix/:/tmp/.X11-unix mivisionx/ubuntu-16.04:latest\n````\n* Test display with MIVisionX sample\n````\n% export PATH=$PATH:/opt/rocm/mivisionx/bin\n% export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/rocm/mivisionx/lib\n% runvx /opt/rocm/mivisionx/samples/gdf/canny.gdf\n````\n* Run [Samples](#samples)\n\n## Usage\n### Command Line Interface (CLI)\n````\nusage: python mivisionx_inference_analyzer.py \t[-h/--help] \n                             \t       \t\t--model_format MODEL_FORMAT \n                                       \t\t--model_name MODEL_NAME \n                                       \t\t--model MODEL \n                                       \t\t--model_input_dims MODEL_INPUT_DIMS \n                                       \t\t--model_output_dims MODEL_OUTPUT_DIMS \n                                       \t\t--label LABEL \n                                       \t\t--output_dir OUTPUT_DIR \n                                       \t\t--image_dir IMAGE_DIR\n                                       \t\t[--image_val IMAGE_VAL] \n                                       \t\t[--hierarchy HIERARCHY]\n                                       \t\t[--add ADD] \n                                       \t\t[--multiply MULTIPLY]\n\t\t\t\t       \t\t[--fp16 FP16]\n\t\t\t\t\t\t[--resize_option RESIZE_OPTION]\n\t\t\t\t\t\t[--display_option DISPLAY_OPTION]\n                                       \t\t[--replace REPLACE] \n                                       \t\t[--verbose VERBOSE]\n\n````\n#### Usage help\n\n```\n  -h, --help            show this help message and exit\n  --model_format        pre-trained model format, options:caffe/onnx/nnef [required]\n  --model_name          model name                                        [required]\n  --model               pre_trained model file/folder                     [required]\n  --model_input_dims    c,h,w - channel,height,width                      [required]\n  --model_output_dims   c,h,w - channel,height,width                      [required]\n  --label               labels text file                                  [required]\n  --output_dir          output dir to store ADAT results                  [required]\n  --image_dir           image directory for analysis                      [required]\n  --image_val           image list with ground truth                      [optional]\n  --hierarchy           AMD proprietary hierarchical file                 [optional]\n  --add                 input preprocessing factor      [optional - default:[0,0,0]]\n  --multiply            input preprocessing factor      [optional - default:[1,1,1]]\n  --fp16                quantize model to FP16 \t\t     [optional - default:no]\n  --resize_option       image resize interpolation [optional - default:0 range[0-5]]\n  --display_option      application display option [optional - default:1 range[0-2]]\n  --replace             replace/overwrite model              [optional - default:no]\n  --verbose             verbose                              [optional - default:no]\n\n```\n#### Input Image Resize Interpolation Options\n```\n0: INTER_LINEAR \t- Default CV Resize Interpolation\n1: INTER_NEAREST \t– a nearest-neighbor interpolation\n2: INTER_LINEAR \t– a bilinear interpolation (used by default)\n3: INTER_AREA \t\t– a resampling using pixel area relation. \n\t\t\t  It may be a preferred method for image decimation, \n\t\t\t  as it gives moire’-free results. But when the image is zoomed, \n\t\t\t  it is similar to the INTER_NEAREST method.\n4: INTER_CUBIC \t\t– a bicubic interpolation over 4×4 pixel neighborhood\n5: INTER_LANCZOS4 \t– a Lanczos interpolation over 8×8 pixel neighborhood\n```\n#### Display Option\n```\n0: OFF \t- Application Display Turn Off\n1: MIN \t– Display Progress Window\n2: ALL \t– Display Input Image, Image Results, \u0026 Progress Window\n```\n\n### Graphical User Interface (GUI)\n````\nusage: python mivisionx_inference_analyzer.py\n````\n\u003cp align=\"center\"\u003e\u003cimg width=\"75%\" src=\"data/images/analyzer-4.png\" /\u003e\u003c/p\u003e\n\n## Supported Pre-Trained Model Formats\n\n\u003cp align=\"center\"\u003e\u003cimg width=\"50%\" src=\"https://raw.githubusercontent.com/GPUOpen-ProfessionalCompute-Libraries/MIVisionX/master/docs/images/modelCompilerFrameWorks.png\" /\u003e\u003c/p\u003e\n\n* Caffe\n* NNEF\n* ONNX\n\n## Samples\n\n### Sample 1 - Using Pre-Trained ONNX Model\n\n#### Run SqueezeNet on sample images\n\n\u003cp align=\"center\"\u003e\u003cimg width=\"40%\" src=\"data/images/sample-1-1.png\" /\u003e\u003c/p\u003e\n\n* **Step 1:** Clone MIVisionX Inference Analyzer Project\n\n\t````\n\t% cd \u0026\u0026 mkdir sample-1 \u0026\u0026 cd sample-1\n\t% git clone https://github.com/kiritigowda/MIVisionX-inference-analyzer.git\n\t````\n\n\t**Note:**\n\t* MIVisionX needs to be pre-installed\n\t* MIVisionX Model Compiler \u0026 Optimizer scripts are at `/opt/rocm/mivisionx/model_compiler/python/`\n\t* ONNX model conversion requires ONNX install using `pip install onnx`\t\n\n* **Step 2:** Download pre-trained SqueezeNet ONNX model from [ONNX Model Zoo](https://github.com/onnx/models#open-neural-network-exchange-onnx-model-zoo) - [SqueezeNet Model](https://s3.amazonaws.com/download.onnx/models/opset_8/squeezenet.tar.gz)\n\t````\n\t% wget https://s3.amazonaws.com/download.onnx/models/opset_8/squeezenet.tar.gz\n\t% tar -xvf squeezenet.tar.gz\n\t````\n\t**Note:** pre-trained model - `squeezenet/model.onnx` \n\t\n\u003cp align=\"center\"\u003e\u003cimg width=\"100%\" src=\"data/images/sample-1-3.png\" /\u003e\u003c/p\u003e\n\n* **Step 3:** Use the command below to run the inference analyzer\n\n\t* View inference analyzer usage\n\t```\n\t% cd ~/sample-1/MIVisionX-inference-analyzer/\n\t% python mivisionx_inference_analyzer.py -h\n\t```\n\t\n\t* Run SqueezeNet Inference Analyzer\n\t```\n\t% python mivisionx_inference_analyzer.py --model_format onnx --model_name SqueezeNet --model ~/sample-1/squeezenet/model.onnx --model_input_dims 3,224,224 --model_output_dims 1000,1,1 --label ./sample/labels.txt --output_dir ~/sample-1/ --image_dir ./sample/AMD-tinyDataSet --image_val ./sample/AMD-tinyDataSet-val.txt --hierarchy ./sample/hierarchy.csv --replace yes\n\t```\n\u003cp align=\"center\"\u003e\u003cimg width=\"100%\" src=\"data/images/sample-1-4.png\" /\u003e\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\u003cimg width=\"100%\" src=\"data/images/sample-1-5.png\" /\u003e\u003c/p\u003e\n\n### Sample 2 - Using Pre-Trained Caffe Model\n\n### Run VGG 16 on sample images\n\n\u003cp align=\"center\"\u003e\u003cimg width=\"40%\" src=\"data/images/sample-2-1.png\" /\u003e\u003c/p\u003e\n\n* **Step 1:** Clone MIVisionX Inference Analyzer Project\n\n\t````\n\t% cd \u0026\u0026 mkdir sample-2 \u0026\u0026 cd sample-2\n\t% git clone https://github.com/kiritigowda/MIVisionX-inference-analyzer.git\n\t````\n\n\t**Note:**\n\t* MIVisionX needs to be pre-installed\n\t* MIVisionX Model Compiler \u0026 Optimizer scripts are at `/opt/rocm/mivisionx/model_compiler/python/`\n\n* **Step 2:** Download pre-trained VGG 16 caffe model - [VGG_ILSVRC_16_layers.caffemodel](http://www.robots.ox.ac.uk/~vgg/software/very_deep/caffe/VGG_ILSVRC_16_layers.caffemodel)\n\t````\n\t% wget http://www.robots.ox.ac.uk/~vgg/software/very_deep/caffe/VGG_ILSVRC_16_layers.caffemodel\n\t````\n* **Step 3:** Use the command below to run the inference analyzer\n\n\t* View inference analyzer usage\n\t```\n\t% cd ~/sample-2/MIVisionX-inference-analyzer/\n\t% python mivisionx_inference_analyzer.py -h\n\t```\n\t\n\t* Run VGGNet-16 Inference Analyzer\n\t```\n\t% python mivisionx_inference_analyzer.py --model_format caffe --model_name VggNet-16-Caffe --model ~/sample-2/VGG_ILSVRC_16_layers.caffemodel --model_input_dims 3,224,224 --model_output_dims 1000,1,1 --label ./sample/labels.txt --output_dir ~/sample-2/ --image_dir ./sample/AMD-tinyDataSet --image_val ./sample/AMD-tinyDataSet-val.txt --hierarchy ./sample/hierarchy.csv --replace yes\n\t```\n\u003cp align=\"center\"\u003e\u003cimg width=\"100%\" src=\"data/images/sample-2-2.png\" /\u003e\u003c/p\u003e\n\n## Sample 3 - Using Pre-Trained NNEF Model\n\n### Run VGG 16 on sample images\n\n\u003cp align=\"center\"\u003e\u003cimg width=\"40%\" src=\"data/images/sample-3-1.png\" /\u003e\u003c/p\u003e\n\n* **Step 1:** Clone MIVisionX Inference Analyzer Project\n\n\t````\n\t% cd \u0026\u0026 mkdir sample-3 \u0026\u0026 cd sample-3\n\t% git clone https://github.com/kiritigowda/MIVisionX-inference-analyzer.git\n\t````\n\n\t**Note:**\n\t* MIVisionX needs to be pre-installed\n\t* MIVisionX Model Compiler \u0026 Optimizer scripts are at `/opt/rocm/mivisionx/model_compiler/python/`\n\t* NNEF model conversion requires [NNEF python parser](https://github.com/KhronosGroup/NNEF-Tools/tree/master/parser#nnef-parser-project) installed\n\n* **Step 2:** Download pre-trained VGG 16 NNEF model\n\t````\n\t% mkdir ~/sample-3/vgg16\n\t% cd ~/sample-3/vgg16\n\t% wget https://sfo2.digitaloceanspaces.com/nnef-public/vgg16.onnx.nnef.tgz\n\t% tar -xvf vgg16.onnx.nnef.tgz\n\t````\n* **Step 3:** Use the command below to run the inference analyzer\n\n\t* View inference analyzer usage\n\t```\n\t% cd ~/sample-3/MIVisionX-inference-analyzer/\n\t% python mivisionx_inference_analyzer.py -h\n\t```\n\t\n\t* Run VGGNet-16 Inference Analyzer\n\t```\n\t% python mivisionx_inference_analyzer.py --model_format nnef --model_name VggNet-16-NNEF --model ~/sample-3/vgg16/ --model_input_dims 3,224,224 --model_output_dims 1000,1,1 --label ./sample/labels.txt --output_dir ~/sample-3/ --image_dir ./sample/AMD-tinyDataSet --image_val ./sample/AMD-tinyDataSet-val.txt --hierarchy ./sample/hierarchy.csv --replace yes\n\t```\n* **Preprocessing the model:** Use the --add/--multiply option to preprocess the input images\n\n\t\t% python mivisionx_inference_analyzer.py --model_format nnef --model_name VggNet-16-NNEF --model ~/sample-3/vgg16/ --model_input_dims 3,224,224 --model_output_dims 1000,1,1 --label ./sample/labels.txt --output_dir ~/sample-3/ --image_dir ./sample/AMD-tinyDataSet --image_val ./sample/AMD-tinyDataSet-val.txt --hierarchy ./sample/hierarchy.csv --replace yes --add [-2.1179,-2.0357,-1.8044] --multiply [0.0171,0.0175,0.0174]\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkiritigowda%2Fmivisionx-inference-analyzer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkiritigowda%2Fmivisionx-inference-analyzer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkiritigowda%2Fmivisionx-inference-analyzer/lists"}