From 57f04d365c8cf5efd8547ed3450f74632c29300e Mon Sep 17 00:00:00 2001 From: Rafal Sapala Date: Mon, 11 Mar 2024 11:31:04 +0100 Subject: [PATCH] Tag to name tests (#63) * Tag to name tests * Update mediapipe/calculators/ovms/openvinoinferencecalculator_test.cc --- .gitignore | 2 + mediapipe/calculators/ovms/BUILD | 32 +- .../ovms/openvinoinferencecalculator.cc | 156 ++---- .../ovms/openvinoinferencecalculator_test.cc | 511 +++++++++++++++++- .../openvinoinferencecalculatoroptions.cc | 212 ++++++++ .../ovms/openvinoinferencecalculatoroptions.h | 44 ++ .../ovms/openvinoinferenceutils.cc | 60 ++ .../calculators/ovms/openvinoinferenceutils.h | 29 + ...object_detection_desktop_ovms1_graph.pbtxt | 12 - ...object_detection_desktop_ovms2_graph.pbtxt | 14 +- .../object_detection_desktop_ovms_graph.pbtxt | 12 - .../face_detection/face_detection.pbtxt | 13 +- .../face_landmark/face_landmark_cpu.pbtxt | 13 +- .../hand_landmark/hand_landmark_cpu.pbtxt | 9 +- .../hand_recrop_by_roi_cpu.pbtxt | 10 +- .../iris_landmark/iris_landmark_cpu.pbtxt | 13 +- .../ovms_modules/object_detection_ovms.pbtxt | 12 - .../pose_detection/pose_detection_cpu.pbtxt | 9 +- .../pose_landmark_by_roi_cpu.pbtxt | 9 +- 19 files changed, 929 insertions(+), 243 deletions(-) create mode 100644 mediapipe/calculators/ovms/openvinoinferencecalculatoroptions.cc create mode 100644 mediapipe/calculators/ovms/openvinoinferencecalculatoroptions.h create mode 100644 mediapipe/calculators/ovms/openvinoinferenceutils.cc create mode 100644 mediapipe/calculators/ovms/openvinoinferenceutils.h diff --git a/.gitignore b/.gitignore index bdecd24034..517b10d148 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ bazel-* build +flatbuffers/ mediapipe.egg-info mediapipe/__pycache__/ mediapipe/MediaPipe.xcodeproj @@ -17,6 +18,7 @@ mediapipe/models/ssdlite_object_detection_labelmap.txt mediapipe/provisioning_profile.mobileprovision mediapipe/python/__pycache__/ node_modules/ +schema.fbs .configure.bazelrc .user.bazelrc .vscode/ diff --git a/mediapipe/calculators/ovms/BUILD b/mediapipe/calculators/ovms/BUILD index 5822afc3e5..ab058e508c 100644 --- a/mediapipe/calculators/ovms/BUILD +++ b/mediapipe/calculators/ovms/BUILD @@ -55,15 +55,43 @@ cc_library( copts = ["-Iexternal/ovms/src","-Isrc"], ) +cc_library( + name = "openvinoinferenceutils", + srcs = [ + "openvinoinferenceutils.cc" + ], + hdrs = [ + "openvinoinferenceutils.h" + ], + alwayslink = 1, +) + +cc_library( + name = "openvinoinferencecalculatoroptions", + srcs = [ + "openvinoinferencecalculatoroptions.cc" + ], + hdrs = [ + "openvinoinferencecalculatoroptions.h" + ], + deps = [ + ":openvinoinferencecalculator_cc_proto", + ":openvinoinferenceutils", + "//mediapipe/framework:calculator_framework", + ], + alwayslink = 1, +) + cc_library( name = "openvinoinferencecalculator", srcs = [ - "openvinoinferencecalculator.cc" + "openvinoinferencecalculator.cc", ], hdrs = [ - "openvinoinferencecalculator.h" + "openvinoinferencecalculator.h", ], deps = [ + "openvinoinferencecalculatoroptions", ":modelapiovmsadapter", ":openvinoinferencecalculator_cc_proto", "//mediapipe/framework:calculator_framework", diff --git a/mediapipe/calculators/ovms/openvinoinferencecalculator.cc b/mediapipe/calculators/ovms/openvinoinferencecalculator.cc index 4af8f23d9d..10d5b7bc17 100644 --- a/mediapipe/calculators/ovms/openvinoinferencecalculator.cc +++ b/mediapipe/calculators/ovms/openvinoinferencecalculator.cc @@ -32,6 +32,8 @@ #include "mediapipe/framework/port/canonical_errors.h" #include "mediapipe/framework/formats/tensor.h" #include "mediapipe/calculators/ovms/openvinoinferencecalculator.pb.h" +#include "mediapipe/calculators/ovms/openvinoinferencecalculatoroptions.h" +#include "mediapipe/calculators/ovms/openvinoinferenceutils.h" #include "tensorflow/lite/c/common.h" #pragma GCC diagnostic pop #pragma GCC diagnostic push @@ -69,33 +71,8 @@ namespace { } // namespace -const std::string SESSION_TAG{"SESSION"}; -const std::string OVTENSOR_TAG{"OVTENSOR"}; -const std::string OVTENSORS_TAG{"OVTENSORS"}; -const std::string TFTENSOR_TAG{"TFTENSOR"}; -const std::string TFTENSORS_TAG{"TFTENSORS"}; -const std::string MPTENSOR_TAG{"TENSOR"}; -const std::string MPTENSORS_TAG{"TENSORS"}; -const std::string TFLITE_TENSOR_TAG{"TFLITE_TENSOR"}; -const std::string TFLITE_TENSORS_TAG{"TFLITE_TENSORS"}; - using TFSDataType = tensorflow::DataType; -// Function from ovms/src/string_utils.h -bool startsWith(const std::string& str, const std::string& prefix) { - auto it = prefix.begin(); - bool sizeCheck = (str.size() >= prefix.size()); - if (!sizeCheck) { - return false; - } - bool allOf = std::all_of(str.begin(), - std::next(str.begin(), prefix.size()), - [&it](const char& c) { - return c == *(it++); - }); - return allOf; -} - TFSDataType getPrecisionAsDataType(ov::element::Type_t precision) { static std::unordered_map precisionMap{ {ov::element::Type_t::f32, TFSDataType::DT_FLOAT}, @@ -339,6 +316,8 @@ class OpenVINOInferenceCalculator : public CalculatorBase { RET_CHECK(!cc->Inputs().GetTags().empty()); RET_CHECK(!cc->Outputs().GetTags().empty()); RET_CHECK(cc->InputSidePackets().HasTag(SESSION_TAG)); + RET_CHECK(ValidateCalculatorSettings(cc)); + for (const std::string& tag : cc->Inputs().GetTags()) { // could be replaced with absl::StartsWith when migrated to MP if (startsWith(tag, OVTENSORS_TAG)) { @@ -409,6 +388,7 @@ class OpenVINOInferenceCalculator : public CalculatorBase { LOG(INFO) << "OpenVINOInferenceCalculator Close"; return absl::OkStatus(); } + absl::Status Open(CalculatorContext* cc) final { LOG(INFO) << "OpenVINOInferenceCalculator Open start"; session = cc->InputSidePackets() @@ -472,20 +452,17 @@ class OpenVINOInferenceCalculator : public CalculatorBase { } else { realInputName = it->second.c_str(); } -#define DESERIALIZE_TENSORS(TYPE, DESERIALIZE_FUN) \ - auto& packet = cc->Inputs().Tag(tag).Get>(); \ - if ( packet.size() > 1 && input_order_list.size() != packet.size()) { \ - LOG(INFO) << "input_order_list not set properly in options for multiple inputs."; \ - RET_CHECK(false); \ - } \ - if (this->input_order_list.size() > 0){ \ - for (size_t i = 0; i < this->input_order_list.size(); i++) { \ - auto& tensor = packet[i]; \ - input[this->input_order_list[i]] = DESERIALIZE_FUN(tensor); \ - } \ - } else if (packet.size() == 1) { \ - input[realInputName] = DESERIALIZE_FUN(packet[0]); \ - } +#define DESERIALIZE_TENSORS(TYPE, DESERIALIZE_FUN) \ + auto& packet = cc->Inputs().Tag(tag).Get>(); \ + if (packet.size() != this->input_order_list.size()) { \ + LOG(INFO) << "input_order_list size does not match the input vector size."; \ + RET_CHECK(false); \ + } \ + for (size_t i = 0; i < this->input_order_list.size(); i++) { \ + auto& tensor = packet[i]; \ + input[this->input_order_list[i]] = DESERIALIZE_FUN(tensor); \ + } \ + try { if (startsWith(tag, OVTENSORS_TAG)) { DESERIALIZE_TENSORS(ov::Tensor,); @@ -532,72 +509,57 @@ class OpenVINOInferenceCalculator : public CalculatorBase { for (const auto& tag : cc->Outputs().GetTags()) { LOG(INFO) << "Processing tag: " << tag; std::string tensorName; - auto it = options.tag_to_output_tensor_names().find(tag); - if (it == options.tag_to_output_tensor_names().end()) { - tensorName = tag; - } else { - tensorName = it->second; - } - auto tensorIt = output.find(tensorName); - if (tensorIt == output.end()) { - LOG(INFO) << "Could not find: " << tensorName << " in inference output"; - RET_CHECK(false); + auto tensorIt = output.begin(); + + // Check if supported vector tag was not used + if (!IsVectorTag(tag)) { + auto it = options.tag_to_output_tensor_names().find(tag); + if (it == options.tag_to_output_tensor_names().end()) { + tensorName = tag; + } else { + tensorName = it->second; + } + tensorIt = output.find(tensorName); + if (tensorIt == output.end()) { + LOG(INFO) << "Could not find: " << tensorName << " in inference output"; + RET_CHECK(false); + } } + try { +#define SERIALIZE_TENSORS(TYPE, SESERIALIZE_FUN) \ + auto tensors = std::make_unique>(); \ + if ( output.size() > 1 && this->output_order_list.size() != this->output_order_list.size()) \ + { \ + LOG(INFO) << "output_order_list not set properly in options for multiple outputs."; \ + RET_CHECK(false); \ + } \ + if (this->output_order_list.size() > 0) { \ + for (const auto& tensorName : this->output_order_list) { \ + tensorIt = output.find(tensorName); \ + if (tensorIt == output.end()) { \ + LOG(INFO) << "Could not find: " << tensorName << " in inference output"; \ + RET_CHECK(false); \ + } \ + tensors->emplace_back(SESERIALIZE_FUN(tensorIt->second)); \ + } \ + } else { \ + for (auto& [name,tensor] : output) { \ + tensors->emplace_back(SESERIALIZE_FUN(tensor)); \ + } \ + } \ + cc->Outputs().Tag(tag).Add( \ + tensors.release(), \ + cc->InputTimestamp()); \ + if (startsWith(tag, OVTENSORS_TAG)) { LOG(INFO) << "OVMS calculator will process vector"; - auto tensors = std::make_unique>(); - if ( output.size() > 1 && this->output_order_list.size() != this->output_order_list.size()) - { - LOG(INFO) << "output_order_list not set properly in options for multiple outputs."; - RET_CHECK(false); - } - if (this->output_order_list.size() > 0) { - for (size_t i = 0; i < this->output_order_list.size(); i++) { - tensorName = this->output_order_list[i]; - tensorIt = output.find(tensorName); - if (tensorIt == output.end()) { - LOG(INFO) << "Could not find: " << tensorName << " in inference output"; - RET_CHECK(false); - } - tensors->emplace_back(tensorIt->second); - } - } else { - for (auto& [name,tensor] : output) { - tensors->emplace_back(tensor); - } - } - cc->Outputs().Tag(tag).Add( - tensors.release(), - cc->InputTimestamp()); + SERIALIZE_TENSORS(ov::Tensor, ) // no need to break since we only have one tag // create concatenator calc } else if (startsWith(tag, MPTENSORS_TAG)) { LOG(INFO) << "OVMS calculator will process vector"; - auto tensors = std::make_unique>(); - if ( output.size() > 1 && this->output_order_list.size() != this->output_order_list.size()) - { - LOG(INFO) << "output_order_list not set properly in options for multiple outputs."; - RET_CHECK(false); - } - if (this->output_order_list.size() > 0) { - for (size_t i = 0; i < this->output_order_list.size(); i++) { - tensorName = this->output_order_list[i]; - tensorIt = output.find(tensorName); - if (tensorIt == output.end()) { - LOG(INFO) << "Could not find: " << tensorName << " in inference output"; - RET_CHECK(false); - } - tensors->emplace_back(convertOVTensor2MPTensor(tensorIt->second)); - } - } else { - for (auto& [name,tensor] : output) { - tensors->emplace_back(convertOVTensor2MPTensor(tensor)); - } - } - cc->Outputs().Tag(tag).Add( - tensors.release(), - cc->InputTimestamp()); + SERIALIZE_TENSORS(Tensor, convertOVTensor2MPTensor) // no need to break since we only have one tag // create concatenator calc } else if (startsWith(tag, TFLITE_TENSORS_TAG)) { diff --git a/mediapipe/calculators/ovms/openvinoinferencecalculator_test.cc b/mediapipe/calculators/ovms/openvinoinferencecalculator_test.cc index feb4502b6d..6af6ded82f 100644 --- a/mediapipe/calculators/ovms/openvinoinferencecalculator_test.cc +++ b/mediapipe/calculators/ovms/openvinoinferencecalculator_test.cc @@ -78,6 +78,11 @@ TEST_F(OpenVINOInferenceCalculatorTest, VerifySupportedTags) { output_stream: "MPTENSORS:output" output_stream: "TFTENSORS:output" output_stream: "TFLITE_TENSORS:output" + node_options: { + [type.googleapis.com / mediapipe.OpenVINOInferenceCalculatorOptions]: { + output_order_list :["raw_outputs/box_encodings","raw_outputs/class_predictions","3","4"] + } + } )pb"); auto cc = absl::make_unique(); cc->Initialize(calculator); @@ -117,6 +122,37 @@ TEST_F(OpenVINOInferenceCalculatorTest, VerifyNotAllowedSideOutputPacket) { auto abslStatus = mediapipe::OpenVINOInferenceCalculator::GetContract(cc.get()); EXPECT_EQ(abslStatus.code(), absl::StatusCode::kInternal) << abslStatus.message(); } + +void runDummyInference(std::string& graph_proto) { + CalculatorGraphConfig graph_config = + ParseTextProtoOrDie(graph_proto); + const std::string inputStreamName = "input"; + const std::string outputStreamName = "output"; + // avoid creating pollers, retreiving packets etc. + std::vector output_packets; + mediapipe::tool::AddVectorSink(outputStreamName, &graph_config, &output_packets); + CalculatorGraph graph(graph_config); + MP_ASSERT_OK(graph.StartRun({})); + auto datatype = ov::element::Type_t::f32; + ov::Shape shape{1,10}; + std::vector data{0,1,2,3,4,5,6,7,8,9}; + auto inputTensor = std::make_unique(datatype, shape, data.data()); + MP_ASSERT_OK(graph.AddPacketToInputStream( + inputStreamName, Adopt(inputTensor.release()).At(Timestamp(0)))); + MP_ASSERT_OK(graph.CloseInputStream(inputStreamName)); + MP_ASSERT_OK(graph.WaitUntilIdle()); + ASSERT_EQ(1, output_packets.size()); + const ov::Tensor& outputTensor = + output_packets[0].Get(); + MP_ASSERT_OK(graph.WaitUntilDone()); + EXPECT_EQ(datatype, outputTensor.get_element_type()); + EXPECT_THAT(outputTensor.get_shape(), testing::ElementsAre(1,10)); + const void* outputData = outputTensor.data(); + for (size_t i = 0; i < data.size(); ++i) { + EXPECT_EQ(data[i] + 1, *(reinterpret_cast(outputData) + i)) << i; + } +} + TEST_F(OpenVINOInferenceCalculatorTest, BasicDummyInference) { std::string graph_proto = R"( input_stream: "input" @@ -138,7 +174,6 @@ TEST_F(OpenVINOInferenceCalculatorTest, BasicDummyInference) { output_stream: "OVTENSOR:output" node_options: { [type.googleapis.com / mediapipe.OpenVINOInferenceCalculatorOptions]: { - output_order_list: ["Identity:0", "Identity_1:0"] tag_to_input_tensor_names { key: "OVTENSOR" value: "b" @@ -151,33 +186,42 @@ TEST_F(OpenVINOInferenceCalculatorTest, BasicDummyInference) { } } )"; - CalculatorGraphConfig graph_config = - ParseTextProtoOrDie(graph_proto); - const std::string inputStreamName = "input"; - const std::string outputStreamName = "output"; - // avoid creating pollers, retreiving packets etc. - std::vector output_packets; - mediapipe::tool::AddVectorSink(outputStreamName, &graph_config, &output_packets); - CalculatorGraph graph(graph_config); - MP_ASSERT_OK(graph.StartRun({})); - auto datatype = ov::element::Type_t::f32; - ov::Shape shape{1,10}; - std::vector data{0,1,2,3,4,5,6,7,8,9}; - auto inputTensor = std::make_unique(datatype, shape, data.data()); - MP_ASSERT_OK(graph.AddPacketToInputStream( - inputStreamName, Adopt(inputTensor.release()).At(Timestamp(0)))); - MP_ASSERT_OK(graph.CloseInputStream(inputStreamName)); - MP_ASSERT_OK(graph.WaitUntilIdle()); - ASSERT_EQ(1, output_packets.size()); - const ov::Tensor& outputTensor = - output_packets[0].Get(); - MP_ASSERT_OK(graph.WaitUntilDone()); - EXPECT_EQ(datatype, outputTensor.get_element_type()); - EXPECT_THAT(outputTensor.get_shape(), testing::ElementsAre(1,10)); - const void* outputData = outputTensor.data(); - for (size_t i = 0; i < data.size(); ++i) { - EXPECT_EQ(data[i] + 1, *(reinterpret_cast(outputData) + i)) << i; - } + runDummyInference(graph_proto); +} +TEST_F(OpenVINOInferenceCalculatorTest, BasicDummyInferenceEmptyKey) { + std::string graph_proto = R"( + input_stream: "input" + output_stream: "output" + node { + calculator: "OpenVINOModelServerSessionCalculator" + output_side_packet: "SESSION:session" + node_options: { + [type.googleapis.com / mediapipe.OpenVINOModelServerSessionCalculatorOptions]: { + servable_name: "dummy" + server_config: "/mediapipe/mediapipe/calculators/ovms/test_data/config.json" + } + } + } + node { + calculator: "OpenVINOInferenceCalculator" + input_side_packet: "SESSION:session" + input_stream: "input" + output_stream: "output" + node_options: { + [type.googleapis.com / mediapipe.OpenVINOInferenceCalculatorOptions]: { + tag_to_input_tensor_names { + key: "" + value: "b" + } + tag_to_output_tensor_names { + key: "" + value: "a" + } + } + } + } + )"; + runDummyInference(graph_proto); } TEST_F(OpenVINOInferenceCalculatorTest, HandleEmptyPackets) { std::string graph_proto = R"( @@ -318,3 +362,414 @@ TEST_F(OpenVINOInferenceCalculatorTest, DISABLED_HandleEmptyPacketsWithSyncSet) ASSERT_EQ(0, output_packets.size()); } +void verifyGetContract(const std::string& pbtxtContent, absl::StatusCode expectedStatusCode) { + auto calculator = mediapipe::ParseTextProtoOrDie(pbtxtContent); + auto cc = absl::make_unique(); + cc->Initialize(calculator); + auto abslStatus = mediapipe::OpenVINOInferenceCalculator::GetContract(cc.get()); + EXPECT_EQ(abslStatus.code(), expectedStatusCode) << abslStatus.message(); +} + +TEST_F(OpenVINOInferenceCalculatorTest, VerifyTagToInputNames) { + // Test passes with OVTENSORS1 in tag_to_output_tensor_names because we support and check the basic type match - OVTENSORS in this case + std::string calculator_proto = + R"pb( + calculator: "OpenVINOInferenceCalculator" + input_side_packet: "SESSION:session" + input_stream: "OVTENSOR:image_tensor" + output_stream: "OVTENSOR:detection_tensors" + node_options: { + [type.googleapis.com / mediapipe.OpenVINOInferenceCalculatorOptions]: { + tag_to_input_tensor_names { + key: "OVTENSOR" + value: "normalized_input_image_tensor" + } + tag_to_output_tensor_names { + key: "OVTENSOR1" + value: "raw_outputs/box_encodings" + } + tag_to_output_tensor_names { + key: "OVTENSOR2" + value: "raw_outputs/class_predictions" + } + } + } + )pb"; + + verifyGetContract(calculator_proto, absl::StatusCode::kOk); +} + +TEST_F(OpenVINOInferenceCalculatorTest, VerifyOptionsInputFail) { + std::string calculator_proto = + R"pb( + calculator: "OpenVINOInferenceCalculator" + input_side_packet: "SESSION:session" + input_stream: "OVTENSOR:image_tensor" + output_stream: "OVTENSORS:detection_tensors" + node_options: { + [type.googleapis.com / mediapipe.OpenVINOInferenceCalculatorOptions]: { + input_order_list :["normalized_input_image_tensor"] + output_order_list :["raw_outputs/box_encodings","raw_outputs/class_predictions"] + tag_to_input_tensor_names { + key: "OVTENSOR" + value: "normalized_input_image_tensor" + } + } + } + )pb"; + verifyGetContract(calculator_proto, absl::StatusCode::kInternal); +} + +TEST_F(OpenVINOInferenceCalculatorTest, VerifyOptionsOutputFail) { + std::string calculator_proto = + R"pb( + calculator: "OpenVINOInferenceCalculator" + input_side_packet: "SESSION:session" + input_stream: "OVTENSOR:image_tensor" + output_stream: "OVTENSORS:detection_tensors" + node_options: { + [type.googleapis.com / mediapipe.OpenVINOInferenceCalculatorOptions]: { + input_order_list :["normalized_input_image_tensor"] + output_order_list :["raw_outputs/box_encodings","raw_outputs/class_predictions"] + tag_to_output_tensor_names { + key: "OVTENSOR1" + value: "raw_outputs/box_encodings" + } + tag_to_output_tensor_names { + key: "OVTENSOR2" + value: "raw_outputs/class_predictions" + } + } + } + )pb"; + verifyGetContract(calculator_proto, absl::StatusCode::kInternal); +} + +TEST_F(OpenVINOInferenceCalculatorTest, VerifyOptionsInputFailSingleType) { + std::string calculator_proto = + R"pb( + calculator: "OpenVINOInferenceCalculator" + input_side_packet: "SESSION:session" + input_stream: "OVTENSOR:image_tensor" + output_stream: "OVTENSORS:detection_tensors" + node_options: { + [type.googleapis.com / mediapipe.OpenVINOInferenceCalculatorOptions]: { + input_order_list :["normalized_input_image_tensor"] + output_order_list :["raw_outputs/box_encodings","raw_outputs/class_predictions"] + } + } + )pb"; + verifyGetContract(calculator_proto, absl::StatusCode::kInternal); +} + +TEST_F(OpenVINOInferenceCalculatorTest, VerifyOptionsOutputFailSingleType) { + std::string calculator_proto = + R"pb( + calculator: "OpenVINOInferenceCalculator" + input_side_packet: "SESSION:session" + input_stream: "OVTENSORS:image_tensor" + output_stream: "OVTENSOR:detection_tensors" + node_options: { + [type.googleapis.com / mediapipe.OpenVINOInferenceCalculatorOptions]: { + input_order_list :["normalized_input_image_tensor"] + output_order_list :["raw_outputs/box_encodings","raw_outputs/class_predictions"] + } + } + )pb"; + verifyGetContract(calculator_proto, absl::StatusCode::kInternal); +} + +TEST_F(OpenVINOInferenceCalculatorTest, VerifyOptionsInput) { + std::string calculator_proto = + R"pb( + calculator: "OpenVINOInferenceCalculator" + input_side_packet: "SESSION:session" + input_stream: "OVTENSORS:image_tensor" + output_stream: "OVTENSOR2:detection_tensors" + node_options: { + [type.googleapis.com / mediapipe.OpenVINOInferenceCalculatorOptions]: { + input_order_list :["normalized_input_image_tensor"] + tag_to_output_tensor_names { + key: "OVTENSOR1" + value: "raw_outputs/box_encodings" + } + tag_to_output_tensor_names { + key: "OVTENSOR2" + value: "raw_outputs/class_predictions" + } + } + } + )pb"; + verifyGetContract(calculator_proto, absl::StatusCode::kOk); +} + +TEST_F(OpenVINOInferenceCalculatorTest, VerifyOptionsOutput) { + std::string calculator_proto = + R"pb( + calculator: "OpenVINOInferenceCalculator" + input_side_packet: "SESSION:session" + input_stream: "OVTENSOR:image_tensor" + output_stream: "OVTENSORS2:detection_tensors" + node_options: { + [type.googleapis.com / mediapipe.OpenVINOInferenceCalculatorOptions]: { + output_order_list :["raw_outputs/box_encodings","raw_outputs/class_predictions"] + tag_to_input_tensor_names { + key: "OVTENSOR" + value: "normalized_input_image_tensor" + } + } + } + )pb"; + verifyGetContract(calculator_proto, absl::StatusCode::kOk); +} + +TEST_F(OpenVINOInferenceCalculatorTest, WrongTagToOutputNames) { + std::string calculator_proto = + R"pb( + calculator: "OpenVINOInferenceCalculator" + input_side_packet: "SESSION:session" + input_stream: "OVTENSOR:image_tensor" + output_stream: "OVTENSOR2:detection_tensors" + node_options: { + [type.googleapis.com / mediapipe.OpenVINOInferenceCalculatorOptions]: { + tag_to_input_tensor_names { + key: "OVTENSOR" + value: "normalized_input_image_tensor" + } + tag_to_output_tensor_names { + key: "RROVTENSOR2" + value: "raw_outputs/class_predictions" + } + } + } + )pb"; + verifyGetContract(calculator_proto, absl::StatusCode::kInternal); +} + +TEST_F(OpenVINOInferenceCalculatorTest, WrongTagToInputNames) { + std::string calculator_proto = + R"pb( + calculator: "OpenVINOInferenceCalculator" + input_side_packet: "SESSION:session" + input_stream: "OVTENSOR:image_tensor" + output_stream: "OVTENSOR2:detection_tensors" + node_options: { + [type.googleapis.com / mediapipe.OpenVINOInferenceCalculatorOptions]: { + tag_to_input_tensor_names { + key: "OVTENSORS" + value: "normalized_input_image_tensor" + } + tag_to_output_tensor_names { + key: "OVTENSOR2" + value: "raw_outputs/class_predictions" + } + } + } + )pb"; + verifyGetContract(calculator_proto, absl::StatusCode::kInternal); +} + +TEST_F(OpenVINOInferenceCalculatorTest, WrongTagToInputNamesNoVector) { + std::string calculator_proto = + R"pb( + calculator: "OpenVINOInferenceCalculator" + input_side_packet: "SESSION:session" + input_stream: "OVTENSOR:image_tensor" + output_stream: "OVTENSOR2:detection_tensors" + node_options: { + [type.googleapis.com / mediapipe.OpenVINOInferenceCalculatorOptions]: { + tag_to_input_tensor_names { + key: "OVTENSORS" + value: "normalized_input_image_tensor" + } + tag_to_output_tensor_names { + key: "OVTENSOR1" + value: "raw_outputs/box_encodings" + } + tag_to_output_tensor_names { + key: "OVTENSOR2" + value: "raw_outputs/class_predictions" + } + } + } + )pb"; + verifyGetContract(calculator_proto, absl::StatusCode::kInternal); +} + +TEST_F(OpenVINOInferenceCalculatorTest, WrongTagToInputNamesNoTypeSpecifiedWithMatch) { + std::string calculator_proto = + R"pb( + calculator: "OpenVINOInferenceCalculator" + input_side_packet: "SESSION:session" + input_stream: "image_tensor" + output_stream: "detection_tensors" + node_options: { + [type.googleapis.com / mediapipe.OpenVINOInferenceCalculatorOptions]: { + tag_to_input_tensor_names { + key: "" + value: "normalized_input_image_tensor" + } + tag_to_output_tensor_names { + key: "" + value: "raw_outputs/box_encodings" + } + } + } + )pb"; + verifyGetContract(calculator_proto, absl::StatusCode::kOk); +} + +TEST_F(OpenVINOInferenceCalculatorTest, WrongTagToOutputNamesNoTypeSpecifiedWithoutMatch) { + std::string calculator_proto = + R"pb( + calculator: "OpenVINOInferenceCalculator" + input_side_packet: "SESSION:session" + input_stream: "image_tensor" + output_stream: "detection_tensors" + node_options: { + [type.googleapis.com / mediapipe.OpenVINOInferenceCalculatorOptions]: { + tag_to_input_tensor_names { + key: "image_tensor" + value: "normalized_input_image_tensor" + } + tag_to_output_tensor_names { + key: "BAD_detection_tensors1" + value: "raw_outputs/box_encodings" + } + tag_to_output_tensor_names { + key: "detection_tensors2" + value: "raw_outputs/class_predictions" + } + } + } + )pb"; + verifyGetContract(calculator_proto, absl::StatusCode::kInternal); +} + +TEST_F(OpenVINOInferenceCalculatorTest, WrongTagToInputNamesNoTypeSpecifiedWithoutMatch) { + std::string calculator_proto = + R"pb( + calculator: "OpenVINOInferenceCalculator" + input_side_packet: "SESSION:session" + input_stream: "image_tensor" + output_stream: "detection_tensors" + node_options: { + [type.googleapis.com / mediapipe.OpenVINOInferenceCalculatorOptions]: { + tag_to_input_tensor_names { + key: "image_tensor" + value: "BAD_normalized_input_image_tensor" + } + tag_to_output_tensor_names { + key: "detection_tensors1" + value: "raw_outputs/box_encodings" + } + tag_to_output_tensor_names { + key: "detection_tensors2" + value: "raw_outputs/class_predictions" + } + } + } + )pb"; + verifyGetContract(calculator_proto, absl::StatusCode::kInternal); +} + +TEST_F(OpenVINOInferenceCalculatorTest, NoTagToInputNames) { + std::string calculator_proto = + R"pb( + calculator: "OpenVINOInferenceCalculator" + input_side_packet: "SESSION:session" + input_stream: "OVTENSORS:image_tensor" + output_stream: "OVTENSORS2:detection_tensors" + node_options: { + [type.googleapis.com / mediapipe.OpenVINOInferenceCalculatorOptions]: { + input_order_list :["normalized_input_image_tensor"] + output_order_list :["raw_outputs/box_encodings","raw_outputs/class_predictions"] + } + } + )pb"; + verifyGetContract(calculator_proto, absl::StatusCode::kOk); +} + +TEST_F(OpenVINOInferenceCalculatorTest, UnsupportedTypeTagToInputNamesMatch) { + std::string calculator_proto = + R"pb( + calculator: "OpenVINOInferenceCalculator" + input_side_packet: "SESSION:session" + input_stream: "INPUT1:in1" + input_stream: "INPUT2:in2" + output_stream: "SUM:out" + node_options: { + [type.googleapis.com / mediapipe.OpenVINOInferenceCalculatorOptions]: { + tag_to_input_tensor_names { + key: "INPUT1" + value: "input1" + } + tag_to_input_tensor_names { + key: "INPUT2" + value: "input2" + } + tag_to_output_tensor_names { + key: "SUM" + value: "sum" + } + } + } + )pb"; + verifyGetContract(calculator_proto, absl::StatusCode::kOk); +} + +TEST_F(OpenVINOInferenceCalculatorTest, UnsupportedTypeTagToInputNamesOutputMismatch) { + std::string calculator_proto = + R"pb( + calculator: "OpenVINOInferenceCalculator" + input_side_packet: "SESSION:session" + input_stream: "INPUT1:in1" + input_stream: "INPUT2:in2" + output_stream: "SUM:out" + node_options: { + [type.googleapis.com / mediapipe.OpenVINOInferenceCalculatorOptions]: { + tag_to_input_tensor_names { + key: "INPUT1" + value: "input1" + } + tag_to_input_tensor_names { + key: "INPUT2" + value: "input2" + } + tag_to_output_tensor_names { + key: "SUM1" + value: "sum" + } + } + } + )pb"; + verifyGetContract(calculator_proto, absl::StatusCode::kInternal); +} + +TEST_F(OpenVINOInferenceCalculatorTest, UnsupportedTypeTagToInputNamesInputMismatch) { + std::string calculator_proto = + R"pb( + calculator: "OpenVINOInferenceCalculator" + input_side_packet: "SESSION:session" + input_stream: "INPUT1:in1" + input_stream: "INPUT2:in2" + output_stream: "SUM:out" + node_options: { + [type.googleapis.com / mediapipe.OpenVINOInferenceCalculatorOptions]: { + tag_to_input_tensor_names { + key: "INPUT3" + value: "input1" + } + tag_to_input_tensor_names { + key: "INPUT2" + value: "input2" + } + tag_to_output_tensor_names { + key: "SUM" + value: "sum" + } + } + } + )pb"; + verifyGetContract(calculator_proto, absl::StatusCode::kInternal); +} diff --git a/mediapipe/calculators/ovms/openvinoinferencecalculatoroptions.cc b/mediapipe/calculators/ovms/openvinoinferencecalculatoroptions.cc new file mode 100644 index 0000000000..8f476d29d9 --- /dev/null +++ b/mediapipe/calculators/ovms/openvinoinferencecalculatoroptions.cc @@ -0,0 +1,212 @@ +//***************************************************************************** +// Copyright 2023 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** +#include + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#include "mediapipe/framework/calculator_contract.h" +#include "mediapipe/calculators/ovms/openvinoinferencecalculator.pb.h" +#pragma GCC diagnostic pop +#include "mediapipe/calculators/ovms/openvinoinferencecalculatoroptions.h" +#include "mediapipe/calculators/ovms/openvinoinferenceutils.h" + +namespace mediapipe { + +static bool ValidateOrderLists(std::set calculatorTags, const google::protobuf::RepeatedPtrField& order_list) { + // Get output_stream types defined in the graph + std::vector inputTypes; + for (const std::string& tag : calculatorTags) { + std::vector tokens = tokenize(tag, ':'); + if (tokens.size() > 0) { + std::string inputType = tokens[0]; + + // Check if supported vector tag was used + for (const auto& supportedVectorTag : supportedVectorTags) { + if ( startsWith(inputType, supportedVectorTag)){ + if (order_list.size() < 1) + { + LOG(ERROR) << "OpenVINOInferenceCalculator GetContract error. Order list is requiered for vector types: " << inputType; + return false; + } + } + } + } + } + + return true; +} + +static bool ValidateOrderListsForNonVector(std::set calculatorTags, const google::protobuf::RepeatedPtrField& order_list) { + // Get output_stream types defined in the graph + std::vector inputTypes; + bool vectorTypeExists = false; + for (const std::string& tag : calculatorTags) { + std::vector tokens = tokenize(tag, ':'); + if (tokens.size() > 0) { + std::string inputType = tokens[0]; + if (IsVectorTag(inputType)){ + vectorTypeExists = true; + } + } + } + if (!vectorTypeExists && order_list.size() > 0) { + LOG(ERROR) << "OpenVINOInferenceCalculator GetContract error. Using odrer_list for non vector type. " << order_list[0]; + return false; + } + + return true; +} + +bool IsVectorTag(const std::string& tag) { + bool isVectorType = false; + // Check if supported vector tag was used + for (const auto& supportedVectorTag : supportedVectorTags) { + if (startsWith(tag, supportedVectorTag)) { + return true; + } + } + + return false; +} + +static bool ValidateTagToNames(std::set calculatorTags, const google::protobuf::Map& tags_to_names) { + // Get output_stream types defined in the graph + std::vector inputTypes; + for (const std::string& tag : calculatorTags) { + std::vector tokens = tokenize(tag, ':'); + if (tokens.size() > 0) { + inputTypes.push_back(tokens[0]); + } else { + inputTypes.push_back(tag); + } + } + + for (const auto& [key, value] : tags_to_names) { + bool nameMatch = false; + + // Check if supported tag was used + for (const auto& supportedTag : supportedTags) { + if ( startsWith(key, supportedTag)){ + if (endsWith(key, "S") && !endsWith(supportedTag, "S")) + continue; + + // Check if used tag is defined in the input_stream + for (const auto& graphInput : inputTypes) { + if (startsWith(graphInput, supportedTag)) { + if (endsWith(graphInput, "S") && !endsWith(supportedTag, "S")) + continue; + nameMatch = true; + break; + } + } + } + + // Check if empty tag used - OV:Tensor default type + if ( tokenize(key, ':').size() == 0) { + // Check if used tag is defined in the input_stream + for (const auto& graphInput : inputTypes) { + // Check if empty tag used - OV:Tensor default type + if (key == graphInput) { + nameMatch = true; + break; + } + } + } + + // Type used in tag_to__tensor_names does match input_stream type + if (nameMatch){ + break; + } + } + + // Check if no supported tag used - OV:Tensor default type + for (const auto& graphInput : inputTypes) { + // Full match required + if (key == graphInput) { + nameMatch = true; + break; + } + } + + // Type used in tag_to__tensor_names does not match outputstream type + if (!nameMatch) + { + LOG(ERROR) << "OpenVINOInferenceCalculator GetContract error. Stream names mismatch for tag_to__tensor_names name key " << key; + return false; + } + } + + return true; +} + +static bool ValidateOptions(CalculatorContract* cc) { + const auto& options = cc->Options(); + + if (options.tag_to_output_tensor_names().size() > 0 && options.output_order_list().size() > 0) { + LOG(ERROR) << "OpenVINOInferenceCalculator GetContract error. Use tag_to_output_tensor_names or output_order_list not both at once."; + return false; + } + + if (options.tag_to_input_tensor_names().size() > 0 && options.input_order_list().size() > 0) { + LOG(ERROR) << "OpenVINOInferenceCalculator GetContract error. Use tag_to_input_tensor_names or input_order_list not both at once."; + return false; + } + + return true; +} + +bool ValidateCalculatorSettings(CalculatorContract* cc) +{ + if (!ValidateOptions(cc)) + { + LOG(INFO) << "OpenVINOInferenceCalculator ValidateOptions failed."; + return false; + } + + const auto& options = cc->Options(); + + if (!ValidateOrderListsForNonVector(cc->Inputs().GetTags(), options.input_order_list())) { + LOG(INFO) << "OpenVINOInferenceCalculator ValidateOrderListsForNonVector for inputs failed."; + return false; + } + if (!ValidateOrderListsForNonVector(cc->Outputs().GetTags(), options.output_order_list())) { + LOG(INFO) << "OpenVINOInferenceCalculator ValidateOrderListsForNonVector for outputs failed."; + return false; + } + + if (!ValidateOrderLists(cc->Inputs().GetTags(), options.input_order_list())) { + LOG(INFO) << "OpenVINOInferenceCalculator ValidateOrderLists for inputs failed."; + return false; + } + if (!ValidateOrderLists(cc->Outputs().GetTags(), options.output_order_list())) { + LOG(INFO) << "OpenVINOInferenceCalculator ValidateOrderLists for outputs failed."; + return false; + } + + if (!ValidateTagToNames(cc->Inputs().GetTags(), options.tag_to_input_tensor_names())) { + LOG(INFO) << "OpenVINOInferenceCalculator ValidateInputTagToNames failed."; + return false; + } + if (!ValidateTagToNames(cc->Outputs().GetTags(), options.tag_to_output_tensor_names())) { + LOG(INFO) << "OpenVINOInferenceCalculator ValidateOutputTagToNames failed."; + return false; + } + + LOG(INFO) << "OpenVINOInferenceCalculator ValidateCalculatorSettings passed."; + return true; +} + +} // namespace mediapipe diff --git a/mediapipe/calculators/ovms/openvinoinferencecalculatoroptions.h b/mediapipe/calculators/ovms/openvinoinferencecalculatoroptions.h new file mode 100644 index 0000000000..e9e10d7a86 --- /dev/null +++ b/mediapipe/calculators/ovms/openvinoinferencecalculatoroptions.h @@ -0,0 +1,44 @@ +//***************************************************************************** +// Copyright 2023 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** +#include + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#include "mediapipe/framework/calculator_contract.h" +#include "mediapipe/calculators/ovms/openvinoinferencecalculator.pb.h" +#pragma GCC diagnostic pop + +const std::string SESSION_TAG{"SESSION"}; +const std::string OVTENSOR_TAG{"OVTENSOR"}; +const std::string OVTENSORS_TAG{"OVTENSORS"}; +const std::string TFTENSOR_TAG{"TFTENSOR"}; +const std::string TFTENSORS_TAG{"TFTENSORS"}; +const std::string MPTENSOR_TAG{"TENSOR"}; +const std::string MPTENSORS_TAG{"TENSORS"}; +const std::string TFLITE_TENSOR_TAG{"TFLITE_TENSOR"}; +const std::string TFLITE_TENSORS_TAG{"TFLITE_TENSORS"}; + +const std::vector supportedTags = {SESSION_TAG, OVTENSOR_TAG, OVTENSORS_TAG, TFTENSOR_TAG, TFTENSORS_TAG, MPTENSOR_TAG, MPTENSORS_TAG, TFLITE_TENSOR_TAG, TFLITE_TENSORS_TAG}; + +const std::vector supportedVectorTags = {OVTENSORS_TAG, TFTENSORS_TAG, MPTENSORS_TAG, TFLITE_TENSORS_TAG}; + +namespace mediapipe { + +bool IsVectorTag(const std::string& tag); + +bool ValidateCalculatorSettings(CalculatorContract* cc); + +} // namespace mediapipe diff --git a/mediapipe/calculators/ovms/openvinoinferenceutils.cc b/mediapipe/calculators/ovms/openvinoinferenceutils.cc new file mode 100644 index 0000000000..0557d8aba5 --- /dev/null +++ b/mediapipe/calculators/ovms/openvinoinferenceutils.cc @@ -0,0 +1,60 @@ +//***************************************************************************** +// Copyright 2023 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** +#include +#include +#include +#include +#include + +namespace mediapipe { + +// Function from ovms/src/string_utils.h +bool startsWith(const std::string& str, const std::string& prefix) { + auto it = prefix.begin(); + bool sizeCheck = (str.size() >= prefix.size()); + if (!sizeCheck) { + return false; + } + bool allOf = std::all_of(str.begin(), + std::next(str.begin(), prefix.size()), + [&it](const char& c) { + return c == *(it++); + }); + return allOf; +} + +// Function from ovms/src/string_utils.h +std::vector tokenize(const std::string& str, const char delimiter) { + std::vector tokens; + std::string token; + std::istringstream iss(str); + while (std::getline(iss, token, delimiter)) { + tokens.push_back(token); + } + + return tokens; +} + +// Function from ovms/src/string_utils.h +bool endsWith(const std::string& str, const std::string& match) { + auto it = match.begin(); + return str.size() >= match.size() && + std::all_of(std::next(str.begin(), str.size() - match.size()), str.end(), [&it](const char& c) { + return ::tolower(c) == ::tolower(*(it++)); + }); +} + +} // namespace mediapipe diff --git a/mediapipe/calculators/ovms/openvinoinferenceutils.h b/mediapipe/calculators/ovms/openvinoinferenceutils.h new file mode 100644 index 0000000000..9607d5dcd0 --- /dev/null +++ b/mediapipe/calculators/ovms/openvinoinferenceutils.h @@ -0,0 +1,29 @@ +//***************************************************************************** +// Copyright 2023 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** +#include +#include +namespace mediapipe { + +// Function from ovms/src/string_utils.h +bool startsWith(const std::string& str, const std::string& prefix); + +// Function from ovms/src/string_utils.h +std::vector tokenize(const std::string& str, const char delimiter); + +// Function from ovms/src/string_utils.h +bool endsWith(const std::string& str, const std::string& match); + +} // namespace mediapipe diff --git a/mediapipe/graphs/object_detection/object_detection_desktop_ovms1_graph.pbtxt b/mediapipe/graphs/object_detection/object_detection_desktop_ovms1_graph.pbtxt index 2a460913e0..028f88d2ff 100644 --- a/mediapipe/graphs/object_detection/object_detection_desktop_ovms1_graph.pbtxt +++ b/mediapipe/graphs/object_detection/object_detection_desktop_ovms1_graph.pbtxt @@ -71,18 +71,6 @@ node { [type.googleapis.com / mediapipe.OpenVINOInferenceCalculatorOptions]: { input_order_list :["normalized_input_image_tensor"] output_order_list :["raw_outputs/box_encodings","raw_outputs/class_predictions"] - tag_to_input_tensor_names { - key: "OVTENSORS" - value: "normalized_input_image_tensor" - } - tag_to_output_tensor_names { - key: "OVTENSORS1" - value: "raw_outputs/box_encodings" - } - tag_to_output_tensor_names { - key: "OVTENSORS2" - value: "raw_outputs/class_predictions" - } } } } diff --git a/mediapipe/graphs/object_detection/object_detection_desktop_ovms2_graph.pbtxt b/mediapipe/graphs/object_detection/object_detection_desktop_ovms2_graph.pbtxt index 488a7ca306..ca04c53560 100644 --- a/mediapipe/graphs/object_detection/object_detection_desktop_ovms2_graph.pbtxt +++ b/mediapipe/graphs/object_detection/object_detection_desktop_ovms2_graph.pbtxt @@ -92,18 +92,8 @@ node { output_stream: "TFLITE_TENSORS2:detection_tensors" node_options: { [type.googleapis.com / mediapipe.OpenVINOInferenceCalculatorOptions]: { - tag_to_input_tensor_names { - key: "TFLITE_TENSORS" - value: "normalized_input_image_tensor" - } - tag_to_output_tensor_names { - key: "TFLITE_TENSORS1" - value: "raw_outputs/box_encodings" - } - tag_to_output_tensor_names { - key: "TFLITE_TENSORS2" - value: "raw_outputs/class_predictions" - } + input_order_list: ["normalized_input_image_tensor"] + output_order_list: ["raw_outputs/box_encodings", "raw_outputs/class_predictions"] } } } diff --git a/mediapipe/graphs/object_detection/object_detection_desktop_ovms_graph.pbtxt b/mediapipe/graphs/object_detection/object_detection_desktop_ovms_graph.pbtxt index b95a06ab87..88536308ef 100644 --- a/mediapipe/graphs/object_detection/object_detection_desktop_ovms_graph.pbtxt +++ b/mediapipe/graphs/object_detection/object_detection_desktop_ovms_graph.pbtxt @@ -64,18 +64,6 @@ node { [type.googleapis.com / mediapipe.OpenVINOInferenceCalculatorOptions]: { input_order_list :["normalized_input_image_tensor"] output_order_list :["raw_outputs/box_encodings","raw_outputs/class_predictions"] - tag_to_input_tensor_names { - key: "OVTENSORS" - value: "normalized_input_image_tensor" - } - tag_to_output_tensor_names { - key: "OVTENSORS1" - value: "raw_outputs/box_encodings" - } - tag_to_output_tensor_names { - key: "OVTENSORS2" - value: "raw_outputs/class_predictions" - } } } } diff --git a/mediapipe/modules/face_detection/face_detection.pbtxt b/mediapipe/modules/face_detection/face_detection.pbtxt index a6af98bbf1..a555786493 100644 --- a/mediapipe/modules/face_detection/face_detection.pbtxt +++ b/mediapipe/modules/face_detection/face_detection.pbtxt @@ -91,18 +91,7 @@ node { node_options: { [type.googleapis.com / mediapipe.OpenVINOInferenceCalculatorOptions]: { output_order_list: ["regressors", "classificators"] - tag_to_input_tensor_names { - key: "TENSORS" - value: "input" - } - tag_to_output_tensor_names { - key: "TENSORS" - value: "regressors" - } - tag_to_output_tensor_names { - key: "TENSORS" - value: "classificators" - } + input_order_list: ["input"] } } } diff --git a/mediapipe/modules/face_landmark/face_landmark_cpu.pbtxt b/mediapipe/modules/face_landmark/face_landmark_cpu.pbtxt index 0d3a009a0f..4eae5e6f4d 100644 --- a/mediapipe/modules/face_landmark/face_landmark_cpu.pbtxt +++ b/mediapipe/modules/face_landmark/face_landmark_cpu.pbtxt @@ -109,18 +109,7 @@ node { node_options: { [type.googleapis.com / mediapipe.OpenVINOInferenceCalculatorOptions]: { output_order_list: ["conv2d_21", "conv2d_31"] - tag_to_input_tensor_names { - key: "TENSORS" - value: "input_1" - } - tag_to_output_tensor_names { - key: "TENSORS" - value: "conv2d_21" - } - tag_to_output_tensor_names { - key: "TENSORS" - value: "conv2d_31" - } + input_order_list: ["input_1"] } } } diff --git a/mediapipe/modules/hand_landmark/hand_landmark_cpu.pbtxt b/mediapipe/modules/hand_landmark/hand_landmark_cpu.pbtxt index 7a6eaef2ae..f37b04bdb0 100644 --- a/mediapipe/modules/hand_landmark/hand_landmark_cpu.pbtxt +++ b/mediapipe/modules/hand_landmark/hand_landmark_cpu.pbtxt @@ -97,14 +97,7 @@ node { node_options: { [type.googleapis.com / mediapipe.OpenVINOInferenceCalculatorOptions]: { output_order_list: ["Identity","Identity_1","Identity_2","Identity_3"] - tag_to_input_tensor_names { - key: "TENSORS" - value: "input_1" - } - tag_to_output_tensor_names { # not tagging other outputs due to hardcode - key: "TENSORS" - value: "Identity" - } + input_order_list: ["input_1"] } } } diff --git a/mediapipe/modules/holistic_landmark/hand_recrop_by_roi_cpu.pbtxt b/mediapipe/modules/holistic_landmark/hand_recrop_by_roi_cpu.pbtxt index f2871dc67b..024badadf0 100644 --- a/mediapipe/modules/holistic_landmark/hand_recrop_by_roi_cpu.pbtxt +++ b/mediapipe/modules/holistic_landmark/hand_recrop_by_roi_cpu.pbtxt @@ -65,14 +65,8 @@ node { output_stream: "TENSORS:landmark_tensors" node_options: { [type.googleapis.com / mediapipe.OpenVINOInferenceCalculatorOptions]: { - tag_to_input_tensor_names { - key: "TENSORS" - value: "input_1" - } - tag_to_output_tensor_names { - key: "TENSORS" - value: "output_crop" - } + input_order_list: ["input_1"] + output_order_list: ["output_crop"] } } } diff --git a/mediapipe/modules/iris_landmark/iris_landmark_cpu.pbtxt b/mediapipe/modules/iris_landmark/iris_landmark_cpu.pbtxt index b177a2acd8..9ee18a1973 100644 --- a/mediapipe/modules/iris_landmark/iris_landmark_cpu.pbtxt +++ b/mediapipe/modules/iris_landmark/iris_landmark_cpu.pbtxt @@ -106,18 +106,7 @@ node { node_options: { [type.googleapis.com / mediapipe.OpenVINOInferenceCalculatorOptions]: { output_order_list: ["output_eyes_contours_and_brows", "output_iris"] - tag_to_input_tensor_names { - key: "TFLITE_TENSORS" - value: "input_1" - } - tag_to_output_tensor_names { - key: "TFLITE_TENSORS" - value: "output_eyes_contours_and_brows" - } - tag_to_output_tensor_names { - key: "TFLITE_TENSORS" - value: "output_iris" - } + input_order_list: ["input_1"] } } } diff --git a/mediapipe/modules/ovms_modules/object_detection_ovms.pbtxt b/mediapipe/modules/ovms_modules/object_detection_ovms.pbtxt index fd3acb6598..9467725744 100644 --- a/mediapipe/modules/ovms_modules/object_detection_ovms.pbtxt +++ b/mediapipe/modules/ovms_modules/object_detection_ovms.pbtxt @@ -71,18 +71,6 @@ node { [type.googleapis.com / mediapipe.OpenVINOInferenceCalculatorOptions]: { input_order_list :["normalized_input_image_tensor"] output_order_list :["raw_outputs/box_encodings","raw_outputs/class_predictions"] - tag_to_input_tensor_names { - key: "OVTENSORS" - value: "normalized_input_image_tensor" - } - tag_to_output_tensor_names { - key: "OVTENSORS1" - value: "raw_outputs/box_encodings" - } - tag_to_output_tensor_names { - key: "OVTENSORS2" - value: "raw_outputs/class_predictions" - } } } } diff --git a/mediapipe/modules/pose_detection/pose_detection_cpu.pbtxt b/mediapipe/modules/pose_detection/pose_detection_cpu.pbtxt index 972ac155d9..7385388edf 100644 --- a/mediapipe/modules/pose_detection/pose_detection_cpu.pbtxt +++ b/mediapipe/modules/pose_detection/pose_detection_cpu.pbtxt @@ -97,14 +97,7 @@ node { node_options: { [type.googleapis.com / mediapipe.OpenVINOInferenceCalculatorOptions]: { output_order_list: ["Identity:0", "Identity_1:0"] - tag_to_input_tensor_names { - key: "TENSORS" - value: "input_1:0" - } - tag_to_output_tensor_names { - key: "TENSORS" - value: "Identity:0" - } + input_order_list: ["input_1:0"] } } } diff --git a/mediapipe/modules/pose_landmark/pose_landmark_by_roi_cpu.pbtxt b/mediapipe/modules/pose_landmark/pose_landmark_by_roi_cpu.pbtxt index 3e7753a564..0be7869164 100644 --- a/mediapipe/modules/pose_landmark/pose_landmark_by_roi_cpu.pbtxt +++ b/mediapipe/modules/pose_landmark/pose_landmark_by_roi_cpu.pbtxt @@ -164,14 +164,7 @@ node { node_options: { [type.googleapis.com / mediapipe.OpenVINOInferenceCalculatorOptions]: { output_order_list: ["Identity","Identity_1","Identity_2","Identity_3","Identity_4"] - tag_to_input_tensor_names { - key: "TENSORS" - value: "input_1" - } - tag_to_output_tensor_names { - key: "TENSORS" - value: "Identity" - } + input_order_list: ["input_1"] } } }