Expand modeling tool to support infer_mode

This commit is contained in:
TolyaTalamanov 2022-10-03 11:08:15 +00:00
parent aafb7567c1
commit 0cd4396180
2 changed files with 17 additions and 1 deletions

View File

@ -175,6 +175,17 @@ static PLMode strToPLMode(const std::string& mode_str) {
}
}
static cv::gapi::ie::InferMode strToInferMode(const std::string& infer_mode) {
if (infer_mode == "async") {
return cv::gapi::ie::InferMode::Async;
} else if (infer_mode == "sync") {
return cv::gapi::ie::InferMode::Sync;
} else {
throw std::logic_error("Unsupported Infer mode: " + infer_mode +
"\nPlease chose between: async and sync");
}
}
template <>
CallParams read<CallParams>(const cv::FileNode& fn) {
auto name =
@ -282,7 +293,8 @@ int main(int argc, char* argv[]) {
"{ drop_frames | false | Drop frames if they come earlier than pipeline is completed. }"
"{ exec_list | | A comma-separated list of pipelines that"
" will be executed. Spaces around commas"
" are prohibited. }";
" are prohibited. }"
"{ infer_mode | async | OpenVINO inference mode (async/sync). }";
cv::CommandLineParser cmd(argc, argv, keys);
if (cmd.has("help")) {
@ -298,6 +310,7 @@ int main(int argc, char* argv[]) {
const auto qc = cmd.get<int>("qc");
const auto app_mode = strToAppMode(cmd.get<std::string>("app_mode"));
const auto exec_str = cmd.get<std::string>("exec_list");
const auto infer_mode = strToInferMode(cmd.get<std::string>("infer_mode"));
const auto drop_frames = cmd.get<bool>("drop_frames");
cv::FileStorage fs;
@ -388,6 +401,7 @@ int main(int argc, char* argv[]) {
<< call_params.name << std::endl << e.what();
throw std::logic_error(ss.str());
}
infer_params.mode = infer_mode;
builder.addInfer(call_params, infer_params);
} else {
throw std::logic_error("Unsupported node type: " + node_type);

View File

@ -258,6 +258,7 @@ struct InferParams {
std::vector<std::string> input_layers;
std::vector<std::string> output_layers;
std::map<std::string, std::string> config;
cv::gapi::ie::InferMode mode;
};
class PipelineBuilder {
@ -362,6 +363,7 @@ void PipelineBuilder::addInfer(const CallParams& call_params,
}
pp->pluginConfig(infer_params.config);
pp->cfgInferMode(infer_params.mode);
m_state->networks += cv::gapi::networks(*pp);
addCall(call_params,