From 4999a7f34bb303766d5638859eafb26be9aa07f5 Mon Sep 17 00:00:00 2001 From: shamaksx Date: Thu, 27 Oct 2022 22:00:38 +0530 Subject: [PATCH] Bug fix in OVEP csharp sample (#142) * bug fix in OVEP csharp sample * Samples updated * cpp sample update * Improve the SNPE EP sample with command line option to switch SNPE backend (#120) * Improve the sample with command line option to switch SNPE backend, and set the input file path. Fix an issue for Android build, need to use libc++_shared.so from SNPE SDK. * 1. Update the API call according the API change in Ort, SessionOptionsAppendExecutionProvider_SNPE -> SessionOptionsAppendExecutionProvider 2. format update * Add table of contents to Python samples (#115) * update doc for Snpe EP to reflect the API change (#122) * update doc for snpe to reflect the API change * Set default format to QuantFormat.QDQ (#123) * Add MAUI example for mobile targets (#128) * Add short term workaround to issue with iOS publish where the CoreML frameworks is not added to the link list. Pending real fix from MAUI folks. (#131) Also update ORT to 1.12.1 which has a better Android build. * Quantization tool example bug fix (#133) In ResNet50DataReader, it uses an onnx session to obtain the model input shape. However it passes a madeup model name to the onnx session, resulting in file not found error. This change provide the original float model path to the data reader * sample notebooks for yolov4 and tiny-yoloV2 (#136) * sample notebooks for yolov4 and tiny-yoloV2 * folder restucturing for notebooks * folder restucturing for notebooks Co-authored-by: krishnendukx Co-authored-by: krishnendukx <111554749+krishnendukx@users.noreply.github.com> * Update MauiVisionSample SkiaSharp dependency version to 2.88.1. (#135) Includes this fix in SkiaSharp: https://github.com/mono/SkiaSharp/pull/2198 * add qdq debugging example (#134) Adding example run_qdq_debug.py * Adding quantization example for gpt-2 medium (#140) add gpt2 qdq example * Remove deprecated API usage (#144) Co-authored-by: nmaajidk Co-authored-by: Hector Li Co-authored-by: Nat Kershaw (MSFT) Co-authored-by: Yufeng Li Co-authored-by: Scott McKay Co-authored-by: Chen Fu <1316708+chenfucn@users.noreply.github.com> Co-authored-by: sfatimar Co-authored-by: krishnendukx Co-authored-by: krishnendukx <111554749+krishnendukx@users.noreply.github.com> Co-authored-by: Edward Chen <18449977+edgchen1@users.noreply.github.com> Co-authored-by: Dmitri Smirnov --- .../squeezenet_cpp_app.cpp | 6 +++-- .../squeezenet_cpp_app_io.cpp | 7 ++++-- .../squeezenet_cpp_app.cpp | 6 +++-- .../yolov3_object_detection/Program.cs | 23 +++++++++++-------- 4 files changed, 26 insertions(+), 16 deletions(-) diff --git a/c_cxx/OpenVINO_EP/Linux/squeezenet_classification/squeezenet_cpp_app.cpp b/c_cxx/OpenVINO_EP/Linux/squeezenet_classification/squeezenet_cpp_app.cpp index 7e0786260..18e2de6dd 100644 --- a/c_cxx/OpenVINO_EP/Linux/squeezenet_classification/squeezenet_cpp_app.cpp +++ b/c_cxx/OpenVINO_EP/Linux/squeezenet_classification/squeezenet_cpp_app.cpp @@ -230,7 +230,8 @@ int main(int argc, char* argv[]) std::cout << "Number of Input Nodes: " << numInputNodes << std::endl; std::cout << "Number of Output Nodes: " << numOutputNodes << std::endl; - const char* inputName = session.GetInputName(0, allocator); + auto inputNodeName = session.GetInputNameAllocated(0, allocator); + const char* inputName = inputNodeName.get(); std::cout << "Input Name: " << inputName << std::endl; Ort::TypeInfo inputTypeInfo = session.GetInputTypeInfo(0); @@ -242,7 +243,8 @@ int main(int argc, char* argv[]) std::vector inputDims = inputTensorInfo.GetShape(); std::cout << "Input Dimensions: " << inputDims << std::endl; - const char* outputName = session.GetOutputName(0, allocator); + auto outputNodeName = session.GetOutputNameAllocated(0, allocator); + const char* outputName = outputNodeName.get(); std::cout << "Output Name: " << outputName << std::endl; Ort::TypeInfo outputTypeInfo = session.GetOutputTypeInfo(0); diff --git a/c_cxx/OpenVINO_EP/Linux/squeezenet_classification/squeezenet_cpp_app_io.cpp b/c_cxx/OpenVINO_EP/Linux/squeezenet_classification/squeezenet_cpp_app_io.cpp index c0642d03f..ec84669d6 100644 --- a/c_cxx/OpenVINO_EP/Linux/squeezenet_classification/squeezenet_cpp_app_io.cpp +++ b/c_cxx/OpenVINO_EP/Linux/squeezenet_classification/squeezenet_cpp_app_io.cpp @@ -1,6 +1,7 @@ /* Copyright (C) 2021, Intel Corporation SPDX-License-Identifier: Apache-2.0 + Portions of this software are copyright of their respective authors and released under the MIT license: - ONNX-Runtime-Inference, Copyright 2020 Lei Mao. For licensing see https://github.com/leimao/ONNX-Runtime-Inference/blob/main/LICENSE.md */ @@ -260,7 +261,8 @@ int main(int argc, char* argv[]) std::cout << "Number of Input Nodes: " << numInputNodes << std::endl; std::cout << "Number of Output Nodes: " << numOutputNodes << std::endl; - const char* inputName = session.GetInputName(0, allocator); + auto inputNodeName = session.GetInputNameAllocated(0, allocator); + const char* inputName = inputNodeName.get(); std::cout << "Input Name: " << inputName << std::endl; Ort::TypeInfo inputTypeInfo = session.GetInputTypeInfo(0); @@ -272,7 +274,8 @@ int main(int argc, char* argv[]) std::vector inputDims = inputTensorInfo.GetShape(); std::cout << "Input Dimensions: " << inputDims << std::endl; - const char* outputName = session.GetOutputName(0, allocator); + auto outputNodeName = session.GetOutputNameAllocated(0, allocator); + const char* outputName = outputNodeName.get(); std::cout << "Output Name: " << outputName << std::endl; Ort::TypeInfo outputTypeInfo = session.GetOutputTypeInfo(0); diff --git a/c_cxx/OpenVINO_EP/Windows/squeezenet_classification/squeezenet_cpp_app.cpp b/c_cxx/OpenVINO_EP/Windows/squeezenet_classification/squeezenet_cpp_app.cpp index fe1a70a66..3349494ca 100644 --- a/c_cxx/OpenVINO_EP/Windows/squeezenet_classification/squeezenet_cpp_app.cpp +++ b/c_cxx/OpenVINO_EP/Windows/squeezenet_classification/squeezenet_cpp_app.cpp @@ -235,7 +235,8 @@ int main(int argc, char* argv[]) std::cout << "Number of Input Nodes: " << numInputNodes << std::endl; std::cout << "Number of Output Nodes: " << numOutputNodes << std::endl; - const char* inputName = session.GetInputName(0, allocator); + auto inputNodeName = session.GetInputNameAllocated(0, allocator); + const char* inputName = inputNodeName.get(); std::cout << "Input Name: " << inputName << std::endl; Ort::TypeInfo inputTypeInfo = session.GetInputTypeInfo(0); @@ -247,7 +248,8 @@ int main(int argc, char* argv[]) std::vector inputDims = inputTensorInfo.GetShape(); std::cout << "Input Dimensions: " << inputDims << std::endl; - const char* outputName = session.GetOutputName(0, allocator); + auto outputNodeName = session.GetOutputNameAllocated(0, allocator); + const char* outputName = outputNodeName.get(); std::cout << "Output Name: " << outputName << std::endl; Ort::TypeInfo outputTypeInfo = session.GetOutputTypeInfo(0); diff --git a/c_sharp/OpenVINO_EP/yolov3_object_detection/Program.cs b/c_sharp/OpenVINO_EP/yolov3_object_detection/Program.cs index 8ac757e1c..cdddc5628 100644 --- a/c_sharp/OpenVINO_EP/yolov3_object_detection/Program.cs +++ b/c_sharp/OpenVINO_EP/yolov3_object_detection/Program.cs @@ -133,17 +133,20 @@ static void Main(string[] args) for (int i = 0; i < indices.Length; i = i + 3) { out_classes[count] = indices[i + 1]; - out_scores[count] = scores[indices[i], indices[i + 1], indices[i + 2]]; - predictions.Add(new Prediction + if (indices[i + 1] > -1) { - Box = new Box(boxes[indices[i], indices[i + 2], 1], - boxes[indices[i], indices[i + 2], 0], - boxes[indices[i], indices[i + 2], 3], - boxes[indices[i], indices[i + 2], 2]), - Class = LabelMap.Labels[out_classes[count]], - Score = out_scores[count] - }); - count++; + out_scores[count] = scores[indices[i], indices[i + 1], indices[i + 2]]; + predictions.Add(new Prediction + { + Box = new Box(boxes[indices[i], indices[i + 2], 1], + boxes[indices[i], indices[i + 2], 0], + boxes[indices[i], indices[i + 2], 3], + boxes[indices[i], indices[i + 2], 2]), + Class = LabelMap.Labels[out_classes[count]], + Score = out_scores[count] + }); + count++; + } } // Put boxes, labels and confidence on image and save for viewing