mirror of
https://github.com/opencv/opencv.git
synced 2026-07-31 08:13:04 +04:00
Merge pull request #18701 from TolyaTalamanov:at/introduce-config-for-ie-params
Expand ie::Params to support config * Add config to IE params * Add test * Remove comments from tests * Rename to pluginConfig * Add one more overloads for pluginConfig * Add more tests
This commit is contained in:
committed by
GitHub
parent
6df92b3bca
commit
2a3cdba724
@@ -403,6 +403,108 @@ TEST(TestAgeGenderIE, GenericInfer)
|
||||
normAssert(cv::gapi::ie::util::to_ocv(ie_gender), gapi_gender, "Test gender output");
|
||||
}
|
||||
|
||||
TEST(TestAgeGenderIE, InvalidConfigGeneric)
|
||||
{
|
||||
initDLDTDataPath();
|
||||
|
||||
std::string model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml");
|
||||
std::string weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin");
|
||||
std::string device_id = "CPU";
|
||||
|
||||
// Configure & run G-API
|
||||
cv::GMat in;
|
||||
GInferInputs inputs;
|
||||
inputs["data"] = in;
|
||||
|
||||
auto outputs = cv::gapi::infer<cv::gapi::Generic>("age-gender-generic", inputs);
|
||||
auto age = outputs.at("age_conv3");
|
||||
auto gender = outputs.at("prob");
|
||||
cv::GComputation comp(cv::GIn(in), cv::GOut(age, gender));
|
||||
|
||||
auto pp = cv::gapi::ie::Params<cv::gapi::Generic>{"age-gender-generic",
|
||||
model_path,
|
||||
weights_path,
|
||||
device_id}.pluginConfig({{"unsupported_config", "some_value"}});
|
||||
|
||||
EXPECT_ANY_THROW(comp.compile(cv::GMatDesc{CV_8U,3,cv::Size{320, 240}},
|
||||
cv::compile_args(cv::gapi::networks(pp))));
|
||||
}
|
||||
|
||||
TEST(TestAgeGenderIE, CPUConfigGeneric)
|
||||
{
|
||||
initDLDTDataPath();
|
||||
|
||||
std::string model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml");
|
||||
std::string weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin");
|
||||
std::string device_id = "CPU";
|
||||
|
||||
// Configure & run G-API
|
||||
cv::GMat in;
|
||||
GInferInputs inputs;
|
||||
inputs["data"] = in;
|
||||
|
||||
auto outputs = cv::gapi::infer<cv::gapi::Generic>("age-gender-generic", inputs);
|
||||
auto age = outputs.at("age_conv3");
|
||||
auto gender = outputs.at("prob");
|
||||
cv::GComputation comp(cv::GIn(in), cv::GOut(age, gender));
|
||||
|
||||
auto pp = cv::gapi::ie::Params<cv::gapi::Generic>{"age-gender-generic",
|
||||
model_path,
|
||||
weights_path,
|
||||
device_id}.pluginConfig({{"ENFORCE_BF16", "NO"}});
|
||||
|
||||
EXPECT_NO_THROW(comp.compile(cv::GMatDesc{CV_8U,3,cv::Size{320, 240}},
|
||||
cv::compile_args(cv::gapi::networks(pp))));
|
||||
}
|
||||
|
||||
TEST(TestAgeGenderIE, InvalidConfig)
|
||||
{
|
||||
initDLDTDataPath();
|
||||
|
||||
std::string model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml");
|
||||
std::string weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin");
|
||||
std::string device_id = "CPU";
|
||||
|
||||
using AGInfo = std::tuple<cv::GMat, cv::GMat>;
|
||||
G_API_NET(AgeGender, <AGInfo(cv::GMat)>, "test-age-gender");
|
||||
|
||||
cv::GMat in;
|
||||
cv::GMat age, gender;
|
||||
std::tie(age, gender) = cv::gapi::infer<AgeGender>(in);
|
||||
cv::GComputation comp(cv::GIn(in), cv::GOut(age, gender));
|
||||
|
||||
auto pp = cv::gapi::ie::Params<AgeGender> {
|
||||
model_path, weights_path, device_id
|
||||
}.cfgOutputLayers({ "age_conv3", "prob" }).pluginConfig({{"unsupported_config", "some_value"}});
|
||||
|
||||
EXPECT_ANY_THROW(comp.compile(cv::GMatDesc{CV_8U,3,cv::Size{320, 240}},
|
||||
cv::compile_args(cv::gapi::networks(pp))));
|
||||
}
|
||||
|
||||
TEST(TestAgeGenderIE, CPUConfig)
|
||||
{
|
||||
initDLDTDataPath();
|
||||
|
||||
std::string model_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml");
|
||||
std::string weights_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin");
|
||||
std::string device_id = "CPU";
|
||||
|
||||
using AGInfo = std::tuple<cv::GMat, cv::GMat>;
|
||||
G_API_NET(AgeGender, <AGInfo(cv::GMat)>, "test-age-gender");
|
||||
|
||||
cv::GMat in;
|
||||
cv::GMat age, gender;
|
||||
std::tie(age, gender) = cv::gapi::infer<AgeGender>(in);
|
||||
cv::GComputation comp(cv::GIn(in), cv::GOut(age, gender));
|
||||
|
||||
auto pp = cv::gapi::ie::Params<AgeGender> {
|
||||
model_path, weights_path, device_id
|
||||
}.cfgOutputLayers({ "age_conv3", "prob" }).pluginConfig({{"ENFORCE_BF16", "NO"}});
|
||||
|
||||
EXPECT_NO_THROW(comp.compile(cv::GMatDesc{CV_8U,3,cv::Size{320, 240}},
|
||||
cv::compile_args(cv::gapi::networks(pp))));
|
||||
}
|
||||
|
||||
} // namespace opencv_test
|
||||
|
||||
#endif // HAVE_INF_ENGINE
|
||||
|
||||
Reference in New Issue
Block a user