{"id":20280570,"url":"https://github.com/kiritigowda/mivisionx-inference-tutorial","last_synced_at":"2025-04-11T06:37:06.661Z","repository":{"id":81714125,"uuid":"181787062","full_name":"kiritigowda/MIVisionX-Inference-Tutorial","owner":"kiritigowda","description":"MIVisionX toolkit is a set of comprehensive computer vision and machine intelligence libraries, utilities, and applications bundled into a single toolkit.","archived":false,"fork":false,"pushed_at":"2022-05-13T20:33:43.000Z","size":145687,"stargazers_count":9,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T04:32:44.137Z","etag":null,"topics":["amd","caffe","classification","cnn","detection","inception","inference","inference-engine","machine-learning","mivisionx","neural-network","nnef","onnx","opencv","openvx","openvx-neural-net","resnet","segmentation","tensorflow","vggnet"],"latest_commit_sha":null,"homepage":"https://kiritigowda.github.io/MIVisionX-Inference-Tutorial/","language":"C++","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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-17T00:22:53.000Z","updated_at":"2024-07-08T02:23:58.000Z","dependencies_parsed_at":null,"dependency_job_id":"72f042e5-9f2a-4c9c-89d4-b98560e237ba","html_url":"https://github.com/kiritigowda/MIVisionX-Inference-Tutorial","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiritigowda%2FMIVisionX-Inference-Tutorial","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiritigowda%2FMIVisionX-Inference-Tutorial/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiritigowda%2FMIVisionX-Inference-Tutorial/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiritigowda%2FMIVisionX-Inference-Tutorial/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kiritigowda","download_url":"https://codeload.github.com/kiritigowda/MIVisionX-Inference-Tutorial/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","caffe","classification","cnn","detection","inception","inference","inference-engine","machine-learning","mivisionx","neural-network","nnef","onnx","opencv","openvx","openvx-neural-net","resnet","segmentation","tensorflow","vggnet"],"created_at":"2024-11-14T13:35:59.472Z","updated_at":"2025-04-11T06:37:06.642Z","avatar_url":"https://github.com/kiritigowda.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"## MIVisionX Inference Tutorial \n\n\u003cp align=\"center\"\u003e\u003cimg width=\"80%\" src=\"images/modelCompilerWorkflow.png\" /\u003e\u003c/p\u003e\n\nIn this tutorial, we will learn how to run inference efficiently using [OpenVX](https://www.khronos.org/openvx/) and [OpenVX Extensions](https://www.khronos.org/registry/OpenVX/extensions/vx_khr_nn/1.2/html/index.html). The tutorial will go over each step required to convert a pre-trained neural net model into an OpenVX Graph and run this graph efficiently on any target hardware. In this tutorial, we will also learn about AMD MIVisionX which delivers open source implementation of OpenVX and OpenVX Extensions along with MIVisionX Neural Net Model Compiler \u0026 Optimizer.\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* [Usage](#usage)\n\t* [Convert Pre-Trained Models into OpenVX](#convert-pre-trained-models-into-openvx)\n\t* [Build Inference Application](#build---inference-application)\n\t* [Run Inference Application](#run)\n* [Supported Pre-Trained Model Formats](#supported-pre-trained-model-formats)\n* [Sample-1: Classification Using Pre-Trained ONNX Model](#sample-1---classification-using-pre-trained-onnx-model)\n* [Sample-2: Detection Using Pre-Trained Caffe Model](#sample-2---detection-using-pre-trained-caffe-model)\n* [Sample-3: Classification Using Pre-Trained NNEF Model](#sample-3---classification-using-pre-trained-nnef-model)\n\n[Neural Net Model Compiler \u0026 Optimizer](https://github.com/GPUOpen-ProfessionalCompute-Libraries/MIVisionX/tree/master/model_compiler#neural-net-model-compiler--optimizer) converts pre-trained neural network models to MIVisionX runtime code for optimized inference.\n\n\u003cp align=\"center\"\u003e\u003cimg width=\"100%\" src=\"images/frameworks.png\" /\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 the model compiler \u0026 optimizer. The model compiler 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 could be compiled and deployed on any targeted hardware.\n\n\u003cp align=\"center\"\u003e\u003cimg width=\"100%\" src=\"images/runtime.png\" /\u003e\u003c/p\u003e\n\n### Prerequisites\n\n* Ubuntu `18.04`/`20.04` or CentOS `7`/`8`\n* [ROCm supported hardware](https://docs.amd.com/bundle/ROCm-Installation-Guide-v5.1.1/page/Prerequisite_Actions.html) \n\t* AMD Radeon GPU or AMD APU required\n* Latest [ROCm](https://docs.amd.com/category/ROCm™%20v5.x)\n* Build \u0026 Install [MIVisionX](https://github.com/GPUOpen-ProfessionalCompute-Libraries/MIVisionX#linux-1)\n\n#### Docker for tutorial\n\nMIVisionX provides developers with [docker images](https://hub.docker.com/u/mivisionx) for [Ubuntu 18.04](https://hub.docker.com/r/mivisionx/ubuntu-18.04), [Ubuntu 20.04](https://hub.docker.com/r/mivisionx/ubuntu-20.04), [CentOS 7](https://hub.docker.com/r/mivisionx/centos-7), \u0026 [CentOS 8](https://hub.docker.com/r/mivisionx/centos-8). 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 for the tutorial\n\n* Check [docker prerequisites](https://github.com/GPUOpen-ProfessionalCompute-Libraries/MIVisionX#docker-workflow-sample-on-ubuntu-1804--2004)\n\n* Start docker with display\n````\n% sudo docker pull mivisionx/ubuntu-20.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-20.04:latest\n````\n* Test display with MIVisionX sample\n````\n% export PATH=$PATH:/opt/rocm/bin\n% export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/rocm/lib\n% runvx /opt/rocm/share/mivisionx/samples/gdf/canny.gdf\n````\n\n## Usage\n\n### Convert Pre-Trained Models into OpenVX\n\nUse MIVisionX [Neural Net Model Compiler \u0026 Optimizer](https://github.com/GPUOpen-ProfessionalCompute-Libraries/MIVisionX/tree/master/model_compiler#neural-net-model-compiler--optimizer) to generate OpenVX code from your pre-trained neural net model. The model compiler generates annmodule.cpp \u0026 annmodule.h during the OpenVX code generation. The whole process of inference from a pre-trained neural net model will be shown in 3 different samples [below](#sample-1---classification-using-pre-trained-onnx-model).\n\n1. Download or train your own `Caffe Model`/`ONNX Model`/`NNEF Model`.\n\n\u003cp align=\"center\"\u003e\u003cimg width=\"30%\" src=\"images/flow-1-model.png\" /\u003e\u003c/p\u003e\n\n2. Use [MIVisionX Model Compiler](https://github.com/GPUOpen-ProfessionalCompute-Libraries/MIVisionX/tree/master/model_compiler#neural-net-model-compiler--optimizer) to generate OpenVX C Code from the pre-trained models.\n\n\t**Note:** MIVisionX installs all the model compiler scripts in `/opt/rocm/mivisionx/model_compiler/python/` folder\n\n* Convert the pre-trained models into AMD NNIR model:\n\n\u003cp align=\"center\"\u003e\u003cimg width=\"80%\" src=\"images/flow-2-nnir.png\" /\u003e\u003c/p\u003e\n\n\n\t* Caffe Models\n\n\t````\n\t% python3 /opt/rocm/libexec/mivisionx/model_compiler/python/caffe_to_nnir.py \u003cnet.caffeModel\u003e \u003cnnirOutputFolder\u003e --input-dims \u003cn,c,h,w\u003e [--verbose \u003c0|1\u003e]\n\t````\n\t\n\t* ONNX Models\n\n\t````\n\t% python3 /opt/rocm/libexec/mivisionx/model_compiler/python/onnx_to_nnir.py \u003connxModel\u003e \u003cnnirOutputFolder\u003e [--input_dims n,c,h,w (optional)]\n\t````\n\t\n\t* NNEF Models\n\n\t````\n\t% python3 /opt/rocm/libexec/mivisionx/model_compiler/python/nnef_to_nnir.py \u003cnnefInputFolder\u003e \u003coutputFolder\u003e\n\t````\n\t\n* Convert an AMD NNIR model into OpenVX C code:\n\n\u003cp align=\"center\"\u003e\u003cimg width=\"80%\" src=\"images/flow-3-openvx-b.png\" /\u003e\u003c/p\u003e\n\n\t````\n\t% python3 /opt/rocm/libexec/mivisionx/model_compiler/python/nnir_to_openvx.py \u003cnnirModelFolder\u003e \u003cnnirModelOutputFolder\u003e\n\t````\n\n### Build - Inference Application\nClassification | Detection | Segmentation\n:-------------------------:|:-------------------------:|:-------------------------:\n\u003cimg width=\"80%\" src=\"images/app-control.png\" /\u003e | \u003cimg width=\"45%\" src=\"images/detection_legend.png\" /\u003e | \u003cimg width=\"50%\" src=\"images/segmentation_legend.png\" /\u003e\n\nOnce the OpenVX code is generated(annmodule.cpp \u0026 annmodule.h), follow the instructions below to build the project.\n\n* Clone this Project\n````\n% git clone https://github.com/kiritigowda/MIVisionX-Inference-Tutorial.git\n````\n\n* Copy the files (annmodule.cpp \u0026 annmodule.h) generated by the model compiler into this project's module_files folder.\n````\n% cp PATH/To/annmodule.h   PATH/To/MIVisionX-Inference-Tutorial/module_files/\n% cp PATH/To/annmodule.cpp PATH/To/MIVisionX-Inference-Tutorial/module_files/\n````\n\n* Build this project\n````\n% mkdir build\n% cd build\n% cmake ../MIVisionX-Inference-Tutorial\n% make\n````\n\n### Run\n\nClassification |  Detection \n:-------------------------:|:-------------------------:\n\u003cimg width=\"75%\" src=\"images/app_display.png\" /\u003e | \u003cimg width=\"75%\" src=\"images/detection_display.png\" /\u003e\n\n```\n./classifier\t--mode\t\t\t\t\u003c1/2/3 - 1:classification 2:detection 3:segmentation\u003e\t[required]\n\t\t--video/--capture/--image\t\u003cvideo file\u003e/\u003c0\u003e/\u003cimage file\u003e\t\t\t\t[required]\n\t\t--model_weights\t\t\t\u003cmodel_weights.bin\u003e\t\t\t\t\t[required]\n\t\t--label\t\t\t\t\u003clabel text\u003e\t\t\t\t\t\t[required]\n\t\t--model_input_dims\t\t\u003cc,h,w - channel,height,width\u003e\t\t\t\t[required]\n\t\t--model_output_dims\t\t\u003cc,h,w - channel,height,width\u003e\t\t\t\t[required]\n\n\t\t--model_name\t\t\t\u003cmodel name\u003e\t\t\t\t\t[optional - default:NN_ModelName]\n\t\t--add\t\t\t\t\u003cAx,Ay,Az - input preprocessing factor\u003e\t\t[optional - default:0,0,0]\n\t\t--multiply\t\t\t\u003cMx,My,Mz - input preprocessing factor\u003e\t\t[optional - default:1,1,1]\n\n\n[usage help]\t--help/--h\n\n```\n#### label \u003c path to labels file \u003e\n\nUse [Classification labels](data/sample_classification_labels.txt) or [Detection labels](data/sample_detection_labels.txt) or [Segmentation Labels](data/sample_segmentation_labels.txt) files in the data folder depending on the type of model you are converting to OpenVX\n\n#### video \u003c path to video file \u003e\n\nRun inference on pre-recorded video with this option.\n\n#### image \u003c path to image file \u003e\n\nRun inference on an image with this option.\n\n#### capture \u003c0\u003e\n\nRun inference on the live camera feed with this option.\n\n**Note:** --video/--capture/--image options are not supported concurrently\n\n# Supported Pre-Trained Model Formats\n* Caffe\n* NNEF\n* ONNX\n\n\u003cp align=\"center\"\u003e\u003cimg width=\"70%\" src=\"images/modelTrainedFrameWorks.png\" /\u003e\u003c/p\u003e\n\n## Sample 1 - Classification Using Pre-Trained ONNX Model\n\n### Run SqueezeNet on Video/Image\n\n\u003cp align=\"center\"\u003e\u003cimg width=\"50%\" src=\"images/squeezenet_legend.png\" /\u003e\u003c/p\u003e\n\n* **Step 1:** Clone MIVisionX Inference Tutorial 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-Tutorial.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\n* **Step 3:** Use MIVisionX Model Compiler to generate OpenVX files from the pre-trained ONNX model\n\n\n\t* Convert .onnx to NNIR\n\n\t````\n\t% python3 /opt/rocm/libexec/mivisionx/model_compiler/python/onnx_to_nnir.py squeezenet/model.onnx squeezenet-nnir\n\t````\n\n\t* Convert NNIR to OpenVX\n\n\t````\n\t% python3 /opt/rocm/libexec/mivisionx/model_compiler/python/nnir_to_openvx.py squeezenet-nnir/ squeezenet-openvx\n\t````\n\t**Note:** \n\t* annmodule.cpp \u0026 annmodule.h generated in squeezenet-openvx folder\n\t* weights.bin generated in squeezenet-openvx folder is used for the classifier --model_weights option\n\t\n* **Step 4:** Copy the annmodule.cpp \u0026 annmodule.h files into module_files folder. CMake and build this project\n\n\t* Copy OpenVX generated code\n\t````\n\t% cp ~/sample-1/squeezenet-openvx/annmodule.h ~/sample-1/MIVisionX-Inference-Tutorial/module_files/\n\t% cp ~/sample-1/squeezenet-openvx/annmodule.cpp ~/sample-1/MIVisionX-Inference-Tutorial/module_files/\n\t````\n\t* CMake and build\n\t````\n\t% mkdir ~/sample-1/build\n\t% cd ~/sample-1/build/\n\t% cmake ../MIVisionX-Inference-Tutorial/\n\t% make\n\t````\n\t\n\t\u003cp align=\"center\"\u003e\u003cimg width=\"50%\" src=\"images/squeezenet_display.png\" /\u003e\u003c/p\u003e\n\t\n* **Step 5:** Use the command below to run the classifier\n\n\t* View classifier usage\n\t```\n\t% ./classifier --help\n\t```\n\t\n\t* Run SqueezeNet Classifier\n\t```\n\t% ./classifier --mode 1 --video ../MIVisionX-Inference-Tutorial/data/images/img_05.JPG --model_weights ../squeezenet-openvx/weights.bin --label ../MIVisionX-Inference-Tutorial/data/sample_classification_labels.txt --model_input_dims 3,224,224 --model_output_dims 1000,1,1 --model_name SqueezeNet_ONNX\n\t```\n\n## Sample 2 - Detection Using Pre-Trained Caffe Model\n\n### Run Tiny YoloV2 on an Image/Video\n\n\u003cp align=\"center\"\u003e\u003cimg width=\"20%\" src=\"images/detection_legend.png\" /\u003e\u003c/p\u003e\n\n* **Step 1:** Clone MIVisionX Inference Tutorial 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-Tutorial.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 Tiny YoloV2 caffe model - [yoloV2Tiny20.caffemodel](https://github.com/kiritigowda/YoloV2NCS/raw/master/models/caffemodels/yoloV2Tiny20.caffemodel)\n\t````\n\t% wget https://github.com/kiritigowda/YoloV2NCS/raw/master/models/caffemodels/yoloV2Tiny20.caffemodel\n\t````\n\n* **Step 3:** Use MIVisionX Model Compiler to generate OpenVX files from the pre-trained caffe model\n\n\t* Convert .caffemodel to NNIR\n\n\t````\n\t% python3 /opt/rocm/libexec/mivisionx/model_compiler/python/caffe_to_nnir.py yoloV2Tiny20.caffemodel yoloV2-nnir --input-dims 1,3,416,416\n\t````\n\n\t* Convert NNIR to OpenVX\n\n\t````\n\t% python3 /opt/rocm/libexec/mivisionx/model_compiler/python/nnir_to_openvx.py yoloV2-nnir yoloV2-openvx\n\t````\n\t**Note:** \n\t* annmodule.cpp \u0026 annmodule.h generated in yoloV2-openvx folder\n\t* weights.bin generated in yoloV2-openvx folder is used for the classifier --model_weights option\n\t\n* **Step 4:** Copy the annmodule.cpp \u0026 annmodule.h files into module_files folder. CMake and build this project\n\n\t* Copy OpenVX generated code\n\t````\n\t% cp ~/sample-2/yoloV2-openvx/annmodule.h ~/sample-2/MIVisionX-Inference-Tutorial/module_files/\n\t% cp ~/sample-2/yoloV2-openvx/annmodule.cpp ~/sample-2/MIVisionX-Inference-Tutorial/module_files/\n\t````\n\t* CMake and build\n\t````\n\t% mkdir ~/sample-2/build\n\t% cd ~/sample-2/build/\n\t% cmake ../MIVisionX-Inference-Tutorial/\n\t% make\n\t````\n\t\n\t\u003cp align=\"center\"\u003e\u003cimg width=\"50%\" src=\"images/detection_display.png\" /\u003e\u003c/p\u003e\n\t\n* **Step 5:** Use the command below to run the classifier\n\n\t* View classifier usage\n\t```\n\t% ./classifier --help\n\t```\n\t\n\t* Run YoloV2 Classifier\n\t```\n\t% ./classifier --mode 2 --video ../MIVisionX-Inference-Tutorial/data/videos/amd_video_01.mp4 --model_weights ../yoloV2-openvx/weights.bin --label ../MIVisionX-Inference-Tutorial/data/sample_detection_labels.txt --model_input_dims 3,416,416 --model_output_dims 125,12,12 --model_name YoloV2_Caffe --multiply 0.003922,0.003922,0.003922\n\t```\t\n\t**Note:** \n\t* Tiny YoloV2 input needs to be preprocessed\n\t* Use the `--multiply` option to preprocess the input by a factor `1/255` \n\n\n## Sample 3 - Classification Using Pre-Trained NNEF Model\n\n### Run VGG 16 on a Video\n\n\u003cp align=\"center\"\u003e\u003cimg width=\"50%\" src=\"images/app-control.png\" /\u003e\u003c/p\u003e\n\n* **Step 1:** Clone MIVisionX Inference Tutorial 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-Tutorial.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% cd ~/sample-3/\n\t````\n\n* **Step 3:** Use MIVisionX Model Compiler to generate OpenVX files from the pre-trained caffe model\n\n\t* Convert .nnef to NNIR\n\n\t````\n\t% python3 /opt/rocm/libexec/mivisionx/model_compiler/python/nnef_to_nnir.py vgg16/ vgg16-nnir\n\t````\n\t\n\t* Convert NNIR to OpenVX\n\n\t````\n\t% python3 /opt/rocm/libexec/mivisionx/model_compiler/python/nnir_to_openvx.py vgg16-nnir/ vgg16-openvx\n\t````\n\t**Note:** \n\t* annmodule.cpp \u0026 annmodule.h generated in vgg16-openvx folder\n\t* weights.bin generated in vgg16-openvx folder is used for the classifier --model_weights option\n\t\n* **Step 4:** Copy the annmodule.cpp \u0026 annmodule.h files into module_files folder. CMake and build this project\n\n\t* Copy OpenVX generated code\n\t````\n\t% cp ~/sample-3/vgg16-openvx/annmodule.h ~/sample-3/MIVisionX-Inference-Tutorial/module_files/\n\t% cp ~/sample-3/vgg16-openvx/annmodule.cpp ~/sample-3/MIVisionX-Inference-Tutorial/module_files/\n\t````\n\t* CMake and build\n\t````\n\t% mkdir ~/sample-3/build\n\t% cd ~/sample-3/build/\n\t% cmake ../MIVisionX-Inference-Tutorial/\n\t% make\n\t````\n\t\n\t\u003cp align=\"center\"\u003e\u003cimg width=\"50%\" src=\"images/app_display.png\" /\u003e\u003c/p\u003e\n\t\n* **Step 5:** Use the command below to run the classifier\n\n\t* View classifier usage\n\t```\n\t% ./classifier --help\n\t```\n\t\n\t* Run VGG-16 Classifier\n\t```\n\t% ./classifier --mode 1 --video ../MIVisionX-Inference-Tutorial/data/images/img_01.JPG --model_weights ../vgg16-openvx/weights.bin --label ../MIVisionX-Inference-Tutorial/data/sample_classification_labels.txt --model_input_dims 3,224,224 --model_output_dims 1000,1,1 --model_name VGG16_NNEF\n\t```\n\t\n## Sample 4 - Classification Using Pre-Trained Caffe Model\n\n### Run VGG 16 on Live Video\n\n\u003cp align=\"center\"\u003e\u003cimg width=\"50%\" src=\"images/app-control.png\" /\u003e\u003c/p\u003e\n\n* **Step 1:** Clone MIVisionX Inference Tutorial Project\n\n\t````\n\t% cd \u0026\u0026 mkdir sample-4 \u0026\u0026 cd sample-4\n\t% git clone https://github.com/kiritigowda/MIVisionX-Inference-Tutorial.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\n* **Step 3:** Use MIVisionX Model Compiler to generate OpenVX files from the pre-trained caffe model\n\n\n\t* Convert .caffemodel to NNIR\n\n\t````\n\t% python3 /opt/rocm/libexec/mivisionx/model_compiler/python/caffe_to_nnir.py VGG_ILSVRC_16_layers.caffemodel vgg16-nnir --input-dims 1,3,224,224\n\t````\n\t\n\t* Convert NNIR to OpenVX\n\n\t````\n\t% python3 /opt/rocm/libexec/mivisionx/model_compiler/python/nnir_to_openvx.py vgg16-nnir vgg16-openvx\n\t````\n\t**Note:** \n\t* annmodule.cpp \u0026 annmodule.h generated in vgg16-openvx folder\n\t* weights.bin generated in vgg16-openvx folder is used for the classifier --model_weights option\n\t\n* **Step 4:** Copy the annmodule.cpp \u0026 annmodule.h files into module_files folder. CMake and build this project\n\n\t* Copy OpenVX generated code\n\t````\n\t% cp ~/sample-4/vgg16-openvx/annmodule.h ~/sample-4/MIVisionX-Inference-Tutorial/module_files/\n\t% cp ~/sample-4/vgg16-openvx/annmodule.cpp ~/sample-4/MIVisionX-Inference-Tutorial/module_files/\n\t````\n\t* CMake and build\n\t````\n\t% mkdir ~/sample-4/build\n\t% cd ~/sample-4/build/\n\t% cmake ../MIVisionX-Inference-Tutorial/\n\t% make\n\t````\n\t\n\t\u003cp align=\"center\"\u003e\u003cimg width=\"50%\" src=\"images/app_display.png\" /\u003e\u003c/p\u003e\n\t\n* **Step 5:** Use the command below to run the classifier\n\n\t* View classifier usage\n\t```\n\t% ./classifier --help\n\t```\n\t\n\t* Run VGG-16 Classifier\n\t```\n\t% ./classifier --mode 1 --capture 0 --model_weights ../vgg16-openvx/weights.bin --label ../MIVisionX-Inference-Tutorial/data/sample_classification_labels.txt --model_input_dims 3,224,224 --model_output_dims 1000,1,1 --model_name VGG16_Caffe\n\t```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkiritigowda%2Fmivisionx-inference-tutorial","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkiritigowda%2Fmivisionx-inference-tutorial","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkiritigowda%2Fmivisionx-inference-tutorial/lists"}