OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
Add --blob_name_prefix parameter support in Single Image Test (#37597)
Jakub Pala7fc3e90c522
diff --git a/src/plugins/intel_npu/tools/single-image-test/README.md b/src/plugins/intel_npu/tools/single-image-test/README.mdindex cedeadf14e1..acc03bc26b5 100644--- a/src/plugins/intel_npu/tools/single-image-test/README.md+++ b/src/plugins/intel_npu/tools/single-image-test/README.md@@ -77,6 +77,9 @@ single-image-test.exe: Usage: Release\single-image-test.exe[<options>]default: "BGR"-compiled_blob (Output compiled network file (compiled result blob))type: string default: ""+ -blob_name_prefix (Optional prefix overriding model-derived blob file+ naming for auto-generated input/reference/output blobs. Explicit+ --ref_results paths are not modified.) type: string default: ""-confidence_threshold (Confidence threshold for Detection mode. Can be asingle value or per-layer: 'layer1:0.5;layer2:0.3') type: stringdefault: "0.000100"@@ -238,6 +241,7 @@ For example, to run inference with mobilenet-v2 model on Intel® Core™ Ultra NNetwork file: mobilenet-v2.xmlInput file(s): validation-set/224x224/watch.bmpOutput compiled network file:+ Blob name prefix override:Color format: RGBInput precision: FP16Output precision: FP16@@ -316,6 +320,7 @@ For example, to run inference with mobilenet-v2 model on Intel® Core™ Ultra NNetwork file: mobilenet-v2.blobInput file(s): validation-set/224x224/watch.bmpOutput compiled network file:+ Blob name prefix override:Color format: RGBInput precision: FP16Output precision: FP16diff --git a/src/plugins/intel_npu/tools/single-image-test/argument_parse_helpers.cpp b/src/plugins/intel_npu/tools/single-image-test/argument_parse_helpers.cppindex a82a5aaf14d..6daa008868c 100644--- a/src/plugins/intel_npu/tools/single-image-test/argument_parse_helpers.cpp+++ b/src/plugins/intel_npu/tools/single-image-test/argument_parse_helpers.cpp@@ -20,6 +20,9 @@ std::vector<std::string> camVid12 = {"Sky", "Building", "Pole", "Road",DEFINE_string(network, "", "Network file (either XML or pre-compiled blob)");DEFINE_string(input, "", "Input file(s)");DEFINE_string(compiled_blob, "", "Output compiled network file (compiled result blob)");+DEFINE_string(blob_name_prefix, "",+ "Optional prefix overriding model-derived blob file naming for auto-generated input/reference/output blobs. "+ "Explicit --ref_results paths are not modified.");DEFINE_uint32(override_model_batch_size, 1, "Enforce a model to be compiled for batch size");DEFINE_string(device, "", "Device to use");DEFINE_string(config, "", "Path to the configuration file (optional)");@@ -166,6 +169,7 @@ void utils::parseCommandLine(int argc, char* argv[]) {std::cout << " Network file: " << FLAGS_network << std::endl;std::cout << " Input file(s): " << FLAGS_input << std::endl;std::cout << " Output compiled network file: " << FLAGS_compiled_blob << std::endl;+ std::cout << " Blob name prefix override: " << FLAGS_blob_name_prefix << std::endl;std::cout << " Color format: " << FLAGS_color_format << std::endl;std::cout << " Input precision: " << FLAGS_ip << std::endl;std::cout << " Output precision: " << FLAGS_op << std::endl;diff --git a/src/plugins/intel_npu/tools/single-image-test/argument_parse_helpers.hpp b/src/plugins/intel_npu/tools/single-image-test/argument_parse_helpers.hppindex 43a6e6ee1f1..3c565c36656 100644--- a/src/plugins/intel_npu/tools/single-image-test/argument_parse_helpers.hpp+++ b/src/plugins/intel_npu/tools/single-image-test/argument_parse_helpers.hpp@@ -57,6 +57,7 @@ extern std::vector<std::string> camVid12;DECLARE_string(network);DECLARE_string(input);DECLARE_string(compiled_blob);+DECLARE_string(blob_name_prefix);DECLARE_uint32(override_model_batch_size);DECLARE_string(device);DECLARE_string(config);diff --git a/src/plugins/intel_npu/tools/single-image-test/main.cpp b/src/plugins/intel_npu/tools/single-image-test/main.cppindex 4b146a8049e..dc093953903 100644--- a/src/plugins/intel_npu/tools/single-image-test/main.cpp+++ b/src/plugins/intel_npu/tools/single-image-test/main.cpp@@ -663,14 +663,14 @@ bool hasLoadableExt(const std::string& network_path) {});}-std::string cleanName(std::string&& name) {+std::string cleanName(std::string name) {std::replace_if(name.begin(), name.end(),[](unsigned char c) {return !std::isalnum(c);},'_');- return std::move(name);+ return name;}ov::Tensor loadImages(const ov::element::Type& precision, const ov::Shape& shape, const ov::Layout& layout,@@ -2430,7 +2430,7 @@ static ov::Shape parseDataShape(const std::string& dataShapeStr) {return ov::Shape(dataShape);}-std::string getRefBlobFilePath(const std::string& netFileName, const std::vector<std::string>& refFiles,+std::string getRefBlobFilePath(const std::string& blobNamePrefix, const std::vector<std::string>& refFiles,size_t numberOfTestCase, size_t outputInd) {std::string blobFileFullPath;if (!refFiles.empty() && !FLAGS_ref_dir.empty()) {@@ -2444,7 +2444,7 @@ std::string getRefBlobFilePath(const std::string& netFileName, const std::vector} else {// Case 3: Reference directory provided onlystd::ostringstream ostr;- ostr << netFileName << "_ref_out_" << outputInd << "_case_" << numberOfTestCase << ".blob";+ ostr << blobNamePrefix << "_ref_out_" << outputInd << "_case_" << numberOfTestCase << ".blob";const auto blobFileName = ostr.str();std::filesystem::path fullPath = FLAGS_ref_dir;@@ -2759,6 +2759,9 @@ static int runSingleImageTest() {netFileName = cleanName(FLAGS_network.substr(startPos, endPos - startPos));}+ const std::string blobNamePrefix =+ FLAGS_blob_name_prefix.empty() ? netFileName : cleanName(FLAGS_blob_name_prefix);+for (size_t numberOfTestCase = 0; numberOfTestCase < inputFilesPerCase.size(); ++numberOfTestCase) {const auto inputsInfo = compiledModel.inputs();const auto outputsInfo = compiledModel.outputs();@@ -2814,7 +2817,7 @@ static int runSingleImageTest() {: loadInput(precision, dataShape, inputLayout, inputFiles[inputInd], FLAGS_color_format,inputBinPrecisionForOneInfer[numberOfTestCase][inputInd]);std::ostringstream ostr;- ostr << netFileName << "_input_" << inputInd << "_case_" << numberOfTestCase << ".blob";+ ostr << blobNamePrefix << "_input_" << inputInd << "_case_" << numberOfTestCase << ".blob";const auto blobFileName = ostr.str();std::cout << "Dump input #" << inputInd << "_case_" << numberOfTestCase << " to " << blobFileName@@ -2851,7 +2854,7 @@ static int runSingleImageTest() {const ov::Shape& shape = tensor.get_shape();std::string blobFileFullPath =- getRefBlobFilePath(netFileName, refFiles, numberOfTestCase, outputInd);+ getRefBlobFilePath(blobNamePrefix, refFiles, numberOfTestCase, outputInd);std::cout << "Load reference output #" << outputInd << " from " << blobFileFullPath << " as "<< precision << std::endl;@@ -2872,7 +2875,7 @@ static int runSingleImageTest() {for (const auto& out : compiledModel.outputs()) {const auto& tensor = outputTensors.at(out.get_any_name());std::ostringstream ostr;- ostr << netFileName << "_kmb_out_" << outputInd << "_case_" << numberOfTestCase << ".blob";+ ostr << blobNamePrefix << "_kmb_out_" << outputInd << "_case_" << numberOfTestCase << ".blob";const auto blobFileName = ostr.str();std::cout << "Dump device output #" << outputInd << "_case_" << numberOfTestCase << " to "@@ -3006,7 +3009,7 @@ static int runSingleImageTest() {for (const auto& out : compiledModel.outputs()) {const auto& tensor = outputTensors.at(out.get_any_name());std::ostringstream ostr;- ostr << netFileName << "_ref_out_" << outputInd << "_case_" << numberOfTestCase << ".blob";+ ostr << blobNamePrefix << "_ref_out_" << outputInd << "_case_" << numberOfTestCase << ".blob";const auto blobFileName = ostr.str();std::cout << "Dump reference output #" << outputInd << " to " << blobFileName << std::endl;