mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 15:23:05 +04:00
Merge branch 4.x
This commit is contained in:
@@ -62,6 +62,11 @@ public:
|
||||
return cv::MediaFrame::View(std::move(pp), std::move(ss), Cb{m_cb});
|
||||
}
|
||||
cv::util::any blobParams() const override {
|
||||
#if INF_ENGINE_RELEASE > 2023000000
|
||||
// NB: blobParams() shouldn't be used in tests
|
||||
// if OpenVINO versions is higher than 2023.0
|
||||
GAPI_Assert(false && "NV12 feature has been deprecated in OpenVINO 1.0 API.");
|
||||
#else
|
||||
return std::make_pair<InferenceEngine::TensorDesc,
|
||||
InferenceEngine::ParamMap>({IE::Precision::U8,
|
||||
{1, 3, 300, 300},
|
||||
@@ -69,6 +74,7 @@ public:
|
||||
{{"HELLO", 42},
|
||||
{"COLOR_FORMAT",
|
||||
InferenceEngine::ColorFormat::NV12}});
|
||||
#endif // INF_ENGINE_RELEASE > 2023000000
|
||||
}
|
||||
};
|
||||
|
||||
@@ -138,7 +144,13 @@ void setNetParameters(IE::CNNNetwork& net, bool is_nv12 = false) {
|
||||
ii->setPrecision(IE::Precision::U8);
|
||||
ii->getPreProcess().setResizeAlgorithm(IE::RESIZE_BILINEAR);
|
||||
if (is_nv12) {
|
||||
#if INF_ENGINE_RELEASE > 2023000000
|
||||
// NB: NV12 feature shouldn't be used in tests
|
||||
// if OpenVINO versions is higher than 2023.0
|
||||
GAPI_Assert(false && "NV12 feature has been deprecated in OpenVINO 1.0 API.");
|
||||
#else
|
||||
ii->getPreProcess().setColorFormat(IE::ColorFormat::NV12);
|
||||
#endif // INF_ENGINE_RELEASE > 2023000000
|
||||
}
|
||||
}
|
||||
|
||||
@@ -392,10 +404,14 @@ struct InferWithReshapeNV12: public InferWithReshape {
|
||||
cv::randu(m_in_y, 0, 255);
|
||||
m_in_uv = cv::Mat{sz / 2, CV_8UC2};
|
||||
cv::randu(m_in_uv, 0, 255);
|
||||
// NB: NV12 feature shouldn't be used in tests
|
||||
// if OpenVINO versions is higher than 2023.0
|
||||
#if INF_ENGINE_RELEASE <= 2023000000
|
||||
setNetParameters(net, true);
|
||||
net.reshape({{"data", reshape_dims}});
|
||||
auto frame_blob = cv::gapi::ie::util::to_ie(m_in_y, m_in_uv);
|
||||
inferROIs(frame_blob);
|
||||
#endif // INF_ENGINE_RELEASE <= 2023000000
|
||||
}
|
||||
};
|
||||
|
||||
@@ -505,8 +521,11 @@ struct ROIListNV12: public ::testing::Test {
|
||||
cv::Rect(cv::Point{50, 32}, cv::Size{128, 160}),
|
||||
};
|
||||
|
||||
// Load & run IE network
|
||||
// NB: NV12 feature shouldn't be used in tests
|
||||
// if OpenVINO versions is higher than 2023.0
|
||||
#if INF_ENGINE_RELEASE <= 2023000000
|
||||
{
|
||||
// Load & run IE network
|
||||
auto plugin = cv::gimpl::ie::wrap::getPlugin(params);
|
||||
auto net = cv::gimpl::ie::wrap::readNetwork(params);
|
||||
setNetParameters(net, true);
|
||||
@@ -530,9 +549,11 @@ struct ROIListNV12: public ::testing::Test {
|
||||
m_out_ie_genders.push_back(to_ocv(infer_request.GetBlob("prob")).clone());
|
||||
}
|
||||
} // namespace IE = ..
|
||||
#endif // INF_ENGINE_RELEASE <= 2023000000
|
||||
} // ROIList()
|
||||
|
||||
void validate() {
|
||||
#if INF_ENGINE_RELEASE <= 2023000000
|
||||
// Validate with IE itself (avoid DNN module dependency here)
|
||||
ASSERT_EQ(2u, m_out_ie_ages.size());
|
||||
ASSERT_EQ(2u, m_out_ie_genders.size());
|
||||
@@ -543,6 +564,10 @@ struct ROIListNV12: public ::testing::Test {
|
||||
normAssert(m_out_ie_genders[0], m_out_gapi_genders[0], "0: Test gender output");
|
||||
normAssert(m_out_ie_ages [1], m_out_gapi_ages [1], "1: Test age output");
|
||||
normAssert(m_out_ie_genders[1], m_out_gapi_genders[1], "1: Test gender output");
|
||||
#else
|
||||
GAPI_Assert(false && "Reference hasn't been calculated because"
|
||||
" NV12 feature has been deprecated.");
|
||||
#endif // INF_ENGINE_RELEASE <= 2023000000
|
||||
}
|
||||
};
|
||||
|
||||
@@ -631,6 +656,9 @@ struct SingleROINV12: public ::testing::Test {
|
||||
|
||||
m_roi = cv::Rect(cv::Point{64, 60}, cv::Size{96, 96});
|
||||
|
||||
// NB: NV12 feature shouldn't be used in tests
|
||||
// if OpenVINO versions is higher than 2023.0
|
||||
#if INF_ENGINE_RELEASE <= 2023000000
|
||||
// Load & run IE network
|
||||
IE::Blob::Ptr ie_age, ie_gender;
|
||||
{
|
||||
@@ -657,12 +685,18 @@ struct SingleROINV12: public ::testing::Test {
|
||||
m_out_ie_age = to_ocv(infer_request.GetBlob("age_conv3")).clone();
|
||||
m_out_ie_gender = to_ocv(infer_request.GetBlob("prob")).clone();
|
||||
}
|
||||
#endif // INF_ENGINE_RELEASE <= 2023000000
|
||||
}
|
||||
|
||||
void validate() {
|
||||
#if INF_ENGINE_RELEASE <= 2023000000
|
||||
// Validate with IE itself (avoid DNN module dependency here)
|
||||
normAssert(m_out_ie_age , m_out_gapi_age , "Test age output");
|
||||
normAssert(m_out_ie_gender, m_out_gapi_gender, "Test gender output");
|
||||
#else
|
||||
GAPI_Assert(false && "Reference hasn't been calculated because"
|
||||
" NV12 feature has been deprecated.");
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
@@ -962,11 +996,20 @@ TEST_F(ROIListNV12, MediaInputNV12)
|
||||
auto pp = cv::gapi::ie::Params<AgeGender> {
|
||||
params.model_path, params.weights_path, params.device_id
|
||||
}.cfgOutputLayers({ "age_conv3", "prob" });
|
||||
|
||||
// NB: NV12 feature has been deprecated in OpenVINO versions higher
|
||||
// than 2023.0 so G-API must throw error in that case.
|
||||
#if INF_ENGINE_RELEASE <= 2023000000
|
||||
comp.apply(cv::gin(frame, m_roi_list),
|
||||
cv::gout(m_out_gapi_ages, m_out_gapi_genders),
|
||||
cv::compile_args(cv::gapi::networks(pp)));
|
||||
|
||||
validate();
|
||||
#else
|
||||
EXPECT_ANY_THROW(comp.apply(cv::gin(frame, m_roi_list),
|
||||
cv::gout(m_out_gapi_ages, m_out_gapi_genders),
|
||||
cv::compile_args(cv::gapi::networks(pp))));
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(TestAgeGenderIE, MediaInputNV12)
|
||||
@@ -986,6 +1029,9 @@ TEST(TestAgeGenderIE, MediaInputNV12)
|
||||
|
||||
cv::Mat gapi_age, gapi_gender;
|
||||
|
||||
// NB: NV12 feature shouldn't be used in tests
|
||||
// if OpenVINO versions is higher than 2023.0
|
||||
#if INF_ENGINE_RELEASE <= 2023000000
|
||||
// Load & run IE network
|
||||
IE::Blob::Ptr ie_age, ie_gender;
|
||||
{
|
||||
@@ -999,6 +1045,7 @@ TEST(TestAgeGenderIE, MediaInputNV12)
|
||||
ie_age = infer_request.GetBlob("age_conv3");
|
||||
ie_gender = infer_request.GetBlob("prob");
|
||||
}
|
||||
#endif
|
||||
|
||||
// Configure & run G-API
|
||||
using AGInfo = std::tuple<cv::GMat, cv::GMat>;
|
||||
@@ -1014,13 +1061,20 @@ TEST(TestAgeGenderIE, MediaInputNV12)
|
||||
auto pp = cv::gapi::ie::Params<AgeGender> {
|
||||
params.model_path, params.weights_path, params.device_id
|
||||
}.cfgOutputLayers({ "age_conv3", "prob" });
|
||||
|
||||
// NB: NV12 feature has been deprecated in OpenVINO versions higher
|
||||
// than 2023.0 so G-API must throw error in that case.
|
||||
#if INF_ENGINE_RELEASE <= 2023000000
|
||||
comp.apply(cv::gin(frame), cv::gout(gapi_age, gapi_gender),
|
||||
cv::compile_args(cv::gapi::networks(pp)));
|
||||
|
||||
|
||||
// Validate with IE itself (avoid DNN module dependency here)
|
||||
normAssert(cv::gapi::ie::util::to_ocv(ie_age), gapi_age, "Test age output" );
|
||||
normAssert(cv::gapi::ie::util::to_ocv(ie_gender), gapi_gender, "Test gender output");
|
||||
#else
|
||||
EXPECT_ANY_THROW(comp.apply(cv::gin(frame), cv::gout(gapi_age, gapi_gender),
|
||||
cv::compile_args(cv::gapi::networks(pp))));
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(TestAgeGenderIE, MediaInputBGR)
|
||||
@@ -1155,6 +1209,9 @@ TEST(InferROI, MediaInputNV12)
|
||||
cv::Mat gapi_age, gapi_gender;
|
||||
cv::Rect rect(cv::Point{64, 60}, cv::Size{96, 96});
|
||||
|
||||
// NB: NV12 feature shouldn't be used in tests
|
||||
// if OpenVINO versions is higher than 2023.0
|
||||
#if INF_ENGINE_RELEASE <= 2023000000
|
||||
// Load & run IE network
|
||||
IE::Blob::Ptr ie_age, ie_gender;
|
||||
{
|
||||
@@ -1176,6 +1233,7 @@ TEST(InferROI, MediaInputNV12)
|
||||
ie_age = infer_request.GetBlob("age_conv3");
|
||||
ie_gender = infer_request.GetBlob("prob");
|
||||
}
|
||||
#endif
|
||||
|
||||
// Configure & run G-API
|
||||
using AGInfo = std::tuple<cv::GMat, cv::GMat>;
|
||||
@@ -1192,13 +1250,20 @@ TEST(InferROI, MediaInputNV12)
|
||||
auto pp = cv::gapi::ie::Params<AgeGender> {
|
||||
params.model_path, params.weights_path, params.device_id
|
||||
}.cfgOutputLayers({ "age_conv3", "prob" });
|
||||
|
||||
// NB: NV12 feature has been deprecated in OpenVINO versions higher
|
||||
// than 2023.0 so G-API must throw error in that case.
|
||||
#if INF_ENGINE_RELEASE <= 2023000000
|
||||
comp.apply(cv::gin(frame, rect), cv::gout(gapi_age, gapi_gender),
|
||||
cv::compile_args(cv::gapi::networks(pp)));
|
||||
|
||||
|
||||
// Validate with IE itself (avoid DNN module dependency here)
|
||||
normAssert(cv::gapi::ie::util::to_ocv(ie_age), gapi_age, "Test age output" );
|
||||
normAssert(cv::gapi::ie::util::to_ocv(ie_gender), gapi_gender, "Test gender output");
|
||||
#else
|
||||
EXPECT_ANY_THROW(comp.apply(cv::gin(frame, rect), cv::gout(gapi_age, gapi_gender),
|
||||
cv::compile_args(cv::gapi::networks(pp))));
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST_F(ROIList, Infer2MediaInputBGR)
|
||||
@@ -1233,10 +1298,20 @@ TEST_F(ROIListNV12, Infer2MediaInputNV12)
|
||||
auto pp = cv::gapi::ie::Params<AgeGender> {
|
||||
params.model_path, params.weights_path, params.device_id
|
||||
}.cfgOutputLayers({ "age_conv3", "prob" });
|
||||
|
||||
// NB: NV12 feature has been deprecated in OpenVINO versions higher
|
||||
// than 2023.0 so G-API must throw error in that case.
|
||||
#if INF_ENGINE_RELEASE <= 2023000000
|
||||
comp.apply(cv::gin(frame, m_roi_list),
|
||||
cv::gout(m_out_gapi_ages, m_out_gapi_genders),
|
||||
cv::compile_args(cv::gapi::networks(pp)));
|
||||
|
||||
validate();
|
||||
#else
|
||||
EXPECT_ANY_THROW(comp.apply(cv::gin(frame, m_roi_list),
|
||||
cv::gout(m_out_gapi_ages, m_out_gapi_genders),
|
||||
cv::compile_args(cv::gapi::networks(pp))));
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST_F(SingleROI, GenericInfer)
|
||||
@@ -1310,10 +1385,19 @@ TEST_F(SingleROINV12, GenericInferMediaNV12)
|
||||
pp.cfgNumRequests(2u);
|
||||
|
||||
auto frame = MediaFrame::Create<TestMediaNV12>(m_in_y, m_in_uv);
|
||||
|
||||
// NB: NV12 feature has been deprecated in OpenVINO versions higher
|
||||
// than 2023.0 so G-API must throw error in that case.
|
||||
#if INF_ENGINE_RELEASE <= 2023000000
|
||||
comp.apply(cv::gin(frame, m_roi), cv::gout(m_out_gapi_age, m_out_gapi_gender),
|
||||
cv::compile_args(cv::gapi::networks(pp)));
|
||||
|
||||
validate();
|
||||
#else
|
||||
EXPECT_ANY_THROW(comp.apply(cv::gin(frame, m_roi),
|
||||
cv::gout(m_out_gapi_age, m_out_gapi_gender),
|
||||
cv::compile_args(cv::gapi::networks(pp))));
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST_F(ROIList, GenericInfer)
|
||||
@@ -1386,11 +1470,20 @@ TEST_F(ROIListNV12, GenericInferMediaNV12)
|
||||
pp.cfgNumRequests(2u);
|
||||
|
||||
auto frame = MediaFrame::Create<TestMediaNV12>(m_in_y, m_in_uv);
|
||||
|
||||
// NB: NV12 feature has been deprecated in OpenVINO versions higher
|
||||
// than 2023.0 so G-API must throw error in that case.
|
||||
#if INF_ENGINE_RELEASE <= 2023000000
|
||||
comp.apply(cv::gin(frame, m_roi_list),
|
||||
cv::gout(m_out_gapi_ages, m_out_gapi_genders),
|
||||
cv::compile_args(cv::gapi::networks(pp)));
|
||||
cv::gout(m_out_gapi_ages, m_out_gapi_genders),
|
||||
cv::compile_args(cv::gapi::networks(pp)));
|
||||
|
||||
validate();
|
||||
#else
|
||||
EXPECT_ANY_THROW(comp.apply(cv::gin(frame, m_roi_list),
|
||||
cv::gout(m_out_gapi_ages, m_out_gapi_genders),
|
||||
cv::compile_args(cv::gapi::networks(pp))));
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST_F(ROIList, GenericInfer2)
|
||||
@@ -1461,10 +1554,20 @@ TEST_F(ROIListNV12, GenericInfer2MediaInputNV12)
|
||||
pp.cfgNumRequests(2u);
|
||||
|
||||
auto frame = MediaFrame::Create<TestMediaNV12>(m_in_y, m_in_uv);
|
||||
|
||||
// NB: NV12 feature has been deprecated in OpenVINO versions higher
|
||||
// than 2023.0 so G-API must throw error in that case.
|
||||
#if INF_ENGINE_RELEASE <= 2023000000
|
||||
comp.apply(cv::gin(frame, m_roi_list),
|
||||
cv::gout(m_out_gapi_ages, m_out_gapi_genders),
|
||||
cv::compile_args(cv::gapi::networks(pp)));
|
||||
cv::gout(m_out_gapi_ages, m_out_gapi_genders),
|
||||
cv::compile_args(cv::gapi::networks(pp)));
|
||||
|
||||
validate();
|
||||
#else
|
||||
EXPECT_ANY_THROW(comp.apply(cv::gin(frame, m_roi_list),
|
||||
cv::gout(m_out_gapi_ages, m_out_gapi_genders),
|
||||
cv::compile_args(cv::gapi::networks(pp))));
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(Infer, SetInvalidNumberOfRequests)
|
||||
@@ -2050,11 +2153,20 @@ TEST_F(InferWithReshapeNV12, TestInferListYUV)
|
||||
auto pp = cv::gapi::ie::Params<AgeGender> {
|
||||
params.model_path, params.weights_path, params.device_id
|
||||
}.cfgOutputLayers({ "age_conv3", "prob" }).cfgInputReshape({{"data", reshape_dims}});
|
||||
|
||||
// NB: NV12 feature has been deprecated in OpenVINO versions higher
|
||||
// than 2023.0 so G-API must throw error in that case.
|
||||
#if INF_ENGINE_RELEASE <= 2023000000
|
||||
comp.apply(cv::gin(frame, m_roi_list),
|
||||
cv::gout(m_out_gapi_ages, m_out_gapi_genders),
|
||||
cv::compile_args(cv::gapi::networks(pp)));
|
||||
// Validate
|
||||
validate();
|
||||
#else
|
||||
EXPECT_ANY_THROW(comp.apply(cv::gin(frame, m_roi_list),
|
||||
cv::gout(m_out_gapi_ages, m_out_gapi_genders),
|
||||
cv::compile_args(cv::gapi::networks(pp))));
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST_F(ROIList, CallInferMultipleTimes)
|
||||
@@ -2079,6 +2191,7 @@ TEST_F(ROIList, CallInferMultipleTimes)
|
||||
validate();
|
||||
}
|
||||
|
||||
#if INF_ENGINE_RELEASE <= 2023000000
|
||||
TEST(IEFrameAdapter, blobParams)
|
||||
{
|
||||
cv::Mat bgr = cv::Mat::eye(240, 320, CV_8UC3);
|
||||
@@ -2093,6 +2206,7 @@ TEST(IEFrameAdapter, blobParams)
|
||||
|
||||
EXPECT_EQ(expected, actual);
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -2281,6 +2395,10 @@ TEST(TestAgeGenderIE, InferWithBatch)
|
||||
normAssert(cv::gapi::ie::util::to_ocv(ie_gender), gapi_gender, "Test gender output");
|
||||
}
|
||||
|
||||
// NB: All tests below use preprocessing for "Import" networks
|
||||
// passed as the last argument to SetBLob. This overload has
|
||||
// been deprecated in OpenVINO 1.0 API.
|
||||
#if INF_ENGINE_RELEASE <= 2023000000
|
||||
TEST(ImportNetwork, Infer)
|
||||
{
|
||||
const std::string device = "MYRIAD";
|
||||
@@ -2820,6 +2938,7 @@ TEST(ImportNetwork, InferList2NV12)
|
||||
normAssert(out_ie_genders[i], out_gapi_genders[i], "Test gender output");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST(TestAgeGender, ThrowBlobAndInputPrecisionMismatch)
|
||||
{
|
||||
|
||||
@@ -41,20 +41,6 @@ void initDLDTDataPath()
|
||||
|
||||
static const std::string SUBDIR = "intel/age-gender-recognition-retail-0013/FP32/";
|
||||
|
||||
void copyFromOV(ov::Tensor &tensor, cv::Mat &mat) {
|
||||
GAPI_Assert(tensor.get_byte_size() == mat.total() * mat.elemSize());
|
||||
std::copy_n(reinterpret_cast<uint8_t*>(tensor.data()),
|
||||
tensor.get_byte_size(),
|
||||
mat.ptr<uint8_t>());
|
||||
}
|
||||
|
||||
void copyToOV(const cv::Mat &mat, ov::Tensor &tensor) {
|
||||
GAPI_Assert(tensor.get_byte_size() == mat.total() * mat.elemSize());
|
||||
std::copy_n(mat.ptr<uint8_t>(),
|
||||
tensor.get_byte_size(),
|
||||
reinterpret_cast<uint8_t*>(tensor.data()));
|
||||
}
|
||||
|
||||
// FIXME: taken from the DNN module
|
||||
void normAssert(cv::InputArray ref, cv::InputArray test,
|
||||
const char *comment /*= ""*/,
|
||||
@@ -66,15 +52,10 @@ void normAssert(cv::InputArray ref, cv::InputArray test,
|
||||
EXPECT_LE(normInf, lInf) << comment;
|
||||
}
|
||||
|
||||
ov::Core getCore() {
|
||||
static ov::Core core;
|
||||
return core;
|
||||
}
|
||||
|
||||
// TODO: AGNetGenComp, AGNetTypedComp, AGNetOVComp, AGNetOVCompiled
|
||||
// can be generalized to work with any model and used as parameters for tests.
|
||||
|
||||
struct AGNetGenComp {
|
||||
struct AGNetGenParams {
|
||||
static constexpr const char* tag = "age-gender-generic";
|
||||
using Params = cv::gapi::ov::Params<cv::gapi::Generic>;
|
||||
|
||||
@@ -88,19 +69,9 @@ struct AGNetGenComp {
|
||||
const std::string &device) {
|
||||
return {tag, blob_path, device};
|
||||
}
|
||||
|
||||
static cv::GComputation create() {
|
||||
cv::GMat in;
|
||||
GInferInputs inputs;
|
||||
inputs["data"] = in;
|
||||
auto outputs = cv::gapi::infer<cv::gapi::Generic>(tag, inputs);
|
||||
auto age = outputs.at("age_conv3");
|
||||
auto gender = outputs.at("prob");
|
||||
return cv::GComputation{cv::GIn(in), cv::GOut(age, gender)};
|
||||
}
|
||||
};
|
||||
|
||||
struct AGNetTypedComp {
|
||||
struct AGNetTypedParams {
|
||||
using AGInfo = std::tuple<cv::GMat, cv::GMat>;
|
||||
G_API_NET(AgeGender, <AGInfo(cv::GMat)>, "typed-age-gender");
|
||||
using Params = cv::gapi::ov::Params<AgeGender>;
|
||||
@@ -112,7 +83,9 @@ struct AGNetTypedComp {
|
||||
xml_path, bin_path, device
|
||||
}.cfgOutputLayers({ "age_conv3", "prob" });
|
||||
}
|
||||
};
|
||||
|
||||
struct AGNetTypedComp : AGNetTypedParams {
|
||||
static cv::GComputation create() {
|
||||
cv::GMat in;
|
||||
cv::GMat age, gender;
|
||||
@@ -121,30 +94,104 @@ struct AGNetTypedComp {
|
||||
}
|
||||
};
|
||||
|
||||
struct AGNetGenComp : public AGNetGenParams {
|
||||
static cv::GComputation create() {
|
||||
cv::GMat in;
|
||||
GInferInputs inputs;
|
||||
inputs["data"] = in;
|
||||
auto outputs = cv::gapi::infer<cv::gapi::Generic>(tag, inputs);
|
||||
auto age = outputs.at("age_conv3");
|
||||
auto gender = outputs.at("prob");
|
||||
return cv::GComputation{cv::GIn(in), cv::GOut(age, gender)};
|
||||
}
|
||||
};
|
||||
|
||||
struct AGNetROIGenComp : AGNetGenParams {
|
||||
static cv::GComputation create() {
|
||||
cv::GMat in;
|
||||
cv::GOpaque<cv::Rect> roi;
|
||||
GInferInputs inputs;
|
||||
inputs["data"] = in;
|
||||
auto outputs = cv::gapi::infer<cv::gapi::Generic>(tag, roi, inputs);
|
||||
auto age = outputs.at("age_conv3");
|
||||
auto gender = outputs.at("prob");
|
||||
return cv::GComputation{cv::GIn(in, roi), cv::GOut(age, gender)};
|
||||
}
|
||||
};
|
||||
|
||||
struct AGNetListGenComp : AGNetGenParams {
|
||||
static cv::GComputation create() {
|
||||
cv::GMat in;
|
||||
cv::GArray<cv::Rect> rois;
|
||||
GInferInputs inputs;
|
||||
inputs["data"] = in;
|
||||
auto outputs = cv::gapi::infer<cv::gapi::Generic>(tag, rois, inputs);
|
||||
auto age = outputs.at("age_conv3");
|
||||
auto gender = outputs.at("prob");
|
||||
return cv::GComputation{cv::GIn(in, rois), cv::GOut(age, gender)};
|
||||
}
|
||||
};
|
||||
|
||||
struct AGNetList2GenComp : AGNetGenParams {
|
||||
static cv::GComputation create() {
|
||||
cv::GMat in;
|
||||
cv::GArray<cv::Rect> rois;
|
||||
GInferListInputs list;
|
||||
list["data"] = rois;
|
||||
auto outputs = cv::gapi::infer2<cv::gapi::Generic>(tag, in, list);
|
||||
auto age = outputs.at("age_conv3");
|
||||
auto gender = outputs.at("prob");
|
||||
return cv::GComputation{cv::GIn(in, rois), cv::GOut(age, gender)};
|
||||
}
|
||||
};
|
||||
|
||||
class AGNetOVCompiled {
|
||||
public:
|
||||
AGNetOVCompiled(ov::CompiledModel &&compiled_model)
|
||||
: m_compiled_model(std::move(compiled_model)) {
|
||||
: m_compiled_model(std::move(compiled_model)),
|
||||
m_infer_request(m_compiled_model.create_infer_request()) {
|
||||
}
|
||||
|
||||
void operator()(const cv::Mat &in_mat,
|
||||
const cv::Rect &roi,
|
||||
cv::Mat &age_mat,
|
||||
cv::Mat &gender_mat) {
|
||||
// FIXME: W & H could be extracted from model shape
|
||||
// but it's anyway used only for Age Gender model.
|
||||
// (Well won't work in case of reshape)
|
||||
const int W = 62;
|
||||
const int H = 62;
|
||||
cv::Mat resized_roi;
|
||||
cv::resize(in_mat(roi), resized_roi, cv::Size(W, H));
|
||||
(*this)(resized_roi, age_mat, gender_mat);
|
||||
}
|
||||
|
||||
void operator()(const cv::Mat &in_mat,
|
||||
const std::vector<cv::Rect> &rois,
|
||||
std::vector<cv::Mat> &age_mats,
|
||||
std::vector<cv::Mat> &gender_mats) {
|
||||
for (size_t i = 0; i < rois.size(); ++i) {
|
||||
(*this)(in_mat, rois[i], age_mats[i], gender_mats[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void operator()(const cv::Mat &in_mat,
|
||||
cv::Mat &age_mat,
|
||||
cv::Mat &gender_mat) {
|
||||
auto infer_request = m_compiled_model.create_infer_request();
|
||||
auto input_tensor = infer_request.get_input_tensor();
|
||||
copyToOV(in_mat, input_tensor);
|
||||
auto input_tensor = m_infer_request.get_input_tensor();
|
||||
cv::gapi::ov::util::to_ov(in_mat, input_tensor);
|
||||
|
||||
infer_request.infer();
|
||||
m_infer_request.infer();
|
||||
|
||||
auto age_tensor = infer_request.get_tensor("age_conv3");
|
||||
auto age_tensor = m_infer_request.get_tensor("age_conv3");
|
||||
age_mat.create(cv::gapi::ov::util::to_ocv(age_tensor.get_shape()),
|
||||
cv::gapi::ov::util::to_ocv(age_tensor.get_element_type()));
|
||||
copyFromOV(age_tensor, age_mat);
|
||||
cv::gapi::ov::util::to_ocv(age_tensor, age_mat);
|
||||
|
||||
auto gender_tensor = infer_request.get_tensor("prob");
|
||||
auto gender_tensor = m_infer_request.get_tensor("prob");
|
||||
gender_mat.create(cv::gapi::ov::util::to_ocv(gender_tensor.get_shape()),
|
||||
cv::gapi::ov::util::to_ocv(gender_tensor.get_element_type()));
|
||||
copyFromOV(gender_tensor, gender_mat);
|
||||
cv::gapi::ov::util::to_ocv(gender_tensor, gender_mat);
|
||||
}
|
||||
|
||||
void export_model(const std::string &outpath) {
|
||||
@@ -155,6 +202,7 @@ public:
|
||||
|
||||
private:
|
||||
ov::CompiledModel m_compiled_model;
|
||||
ov::InferRequest m_infer_request;
|
||||
};
|
||||
|
||||
struct ImageInputPreproc {
|
||||
@@ -175,7 +223,8 @@ public:
|
||||
const std::string &bin_path,
|
||||
const std::string &device)
|
||||
: m_device(device) {
|
||||
m_model = getCore().read_model(xml_path, bin_path);
|
||||
m_model = cv::gapi::ov::wrap::getCore()
|
||||
.read_model(xml_path, bin_path);
|
||||
}
|
||||
|
||||
using PrePostProcessF = std::function<void(ov::preprocess::PrePostProcessor&)>;
|
||||
@@ -187,7 +236,8 @@ public:
|
||||
}
|
||||
|
||||
AGNetOVCompiled compile() {
|
||||
auto compiled_model = getCore().compile_model(m_model, m_device);
|
||||
auto compiled_model = cv::gapi::ov::wrap::getCore()
|
||||
.compile_model(m_model, m_device);
|
||||
return {std::move(compiled_model)};
|
||||
}
|
||||
|
||||
@@ -202,19 +252,78 @@ private:
|
||||
std::shared_ptr<ov::Model> m_model;
|
||||
};
|
||||
|
||||
struct BaseAgeGenderOV: public ::testing::Test {
|
||||
BaseAgeGenderOV() {
|
||||
initDLDTDataPath();
|
||||
xml_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml");
|
||||
bin_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin");
|
||||
device = "CPU";
|
||||
blob_path = "age-gender-recognition-retail-0013.blob";
|
||||
}
|
||||
|
||||
cv::Mat getRandomImage(const cv::Size &sz) {
|
||||
cv::Mat image(sz, CV_8UC3);
|
||||
cv::randu(image, 0, 255);
|
||||
return image;
|
||||
}
|
||||
|
||||
cv::Mat getRandomTensor(const std::vector<int> &dims,
|
||||
const int depth) {
|
||||
cv::Mat tensor(dims, depth);
|
||||
cv::randu(tensor, -1, 1);
|
||||
return tensor;
|
||||
}
|
||||
|
||||
std::string xml_path;
|
||||
std::string bin_path;
|
||||
std::string blob_path;
|
||||
std::string device;
|
||||
|
||||
};
|
||||
|
||||
struct TestAgeGenderOV : public BaseAgeGenderOV {
|
||||
cv::Mat ov_age, ov_gender, gapi_age, gapi_gender;
|
||||
|
||||
void validate() {
|
||||
normAssert(ov_age, gapi_age, "Test age output" );
|
||||
normAssert(ov_gender, gapi_gender, "Test gender output");
|
||||
}
|
||||
};
|
||||
|
||||
struct TestAgeGenderListOV : public BaseAgeGenderOV {
|
||||
std::vector<cv::Mat> ov_age, ov_gender,
|
||||
gapi_age, gapi_gender;
|
||||
|
||||
std::vector<cv::Rect> roi_list = {
|
||||
cv::Rect(cv::Point{64, 60}, cv::Size{ 96, 96}),
|
||||
cv::Rect(cv::Point{50, 32}, cv::Size{128, 160}),
|
||||
};
|
||||
|
||||
TestAgeGenderListOV() {
|
||||
ov_age.resize(roi_list.size());
|
||||
ov_gender.resize(roi_list.size());
|
||||
gapi_age.resize(roi_list.size());
|
||||
gapi_gender.resize(roi_list.size());
|
||||
}
|
||||
|
||||
void validate() {
|
||||
ASSERT_EQ(ov_age.size(), ov_gender.size());
|
||||
|
||||
ASSERT_EQ(ov_age.size(), gapi_age.size());
|
||||
ASSERT_EQ(ov_gender.size(), gapi_gender.size());
|
||||
|
||||
for (size_t i = 0; i < ov_age.size(); ++i) {
|
||||
normAssert(ov_age[i], gapi_age[i], "Test age output");
|
||||
normAssert(ov_gender[i], gapi_gender[i], "Test gender output");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
// TODO: Make all of tests below parmetrized to avoid code duplication
|
||||
TEST(TestAgeGenderOV, InferTypedTensor) {
|
||||
initDLDTDataPath();
|
||||
const std::string xml_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml");
|
||||
const std::string bin_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin");
|
||||
const std::string device = "CPU";
|
||||
|
||||
cv::Mat in_mat({1, 3, 62, 62}, CV_32F);
|
||||
cv::randu(in_mat, -1, 1);
|
||||
cv::Mat ov_age, ov_gender, gapi_age, gapi_gender;
|
||||
|
||||
TEST_F(TestAgeGenderOV, Infer_Tensor) {
|
||||
const auto in_mat = getRandomTensor({1, 3, 62, 62}, CV_32F);
|
||||
// OpenVINO
|
||||
AGNetOVComp ref(xml_path, bin_path, device);
|
||||
ref.apply(in_mat, ov_age, ov_gender);
|
||||
@@ -226,19 +335,11 @@ TEST(TestAgeGenderOV, InferTypedTensor) {
|
||||
cv::compile_args(cv::gapi::networks(pp)));
|
||||
|
||||
// Assert
|
||||
normAssert(ov_age, gapi_age, "Test age output" );
|
||||
normAssert(ov_gender, gapi_gender, "Test gender output");
|
||||
validate();
|
||||
}
|
||||
|
||||
TEST(TestAgeGenderOV, InferTypedImage) {
|
||||
initDLDTDataPath();
|
||||
const std::string xml_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml");
|
||||
const std::string bin_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin");
|
||||
const std::string device = "CPU";
|
||||
|
||||
cv::Mat in_mat(300, 300, CV_8UC3);
|
||||
cv::randu(in_mat, 0, 255);
|
||||
cv::Mat ov_age, ov_gender, gapi_age, gapi_gender;
|
||||
TEST_F(TestAgeGenderOV, Infer_Image) {
|
||||
const auto in_mat = getRandomImage({300, 300});
|
||||
|
||||
// OpenVINO
|
||||
AGNetOVComp ref(xml_path, bin_path, device);
|
||||
@@ -252,19 +353,11 @@ TEST(TestAgeGenderOV, InferTypedImage) {
|
||||
cv::compile_args(cv::gapi::networks(pp)));
|
||||
|
||||
// Assert
|
||||
normAssert(ov_age, gapi_age, "Test age output" );
|
||||
normAssert(ov_gender, gapi_gender, "Test gender output");
|
||||
validate();
|
||||
}
|
||||
|
||||
TEST(TestAgeGenderOV, InferGenericTensor) {
|
||||
initDLDTDataPath();
|
||||
const std::string xml_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml");
|
||||
const std::string bin_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin");
|
||||
const std::string device = "CPU";
|
||||
|
||||
cv::Mat in_mat({1, 3, 62, 62}, CV_32F);
|
||||
cv::randu(in_mat, -1, 1);
|
||||
cv::Mat ov_age, ov_gender, gapi_age, gapi_gender;
|
||||
TEST_F(TestAgeGenderOV, InferGeneric_Tensor) {
|
||||
const auto in_mat = getRandomTensor({1, 3, 62, 62}, CV_32F);
|
||||
|
||||
// OpenVINO
|
||||
AGNetOVComp ref(xml_path, bin_path, device);
|
||||
@@ -277,19 +370,11 @@ TEST(TestAgeGenderOV, InferGenericTensor) {
|
||||
cv::compile_args(cv::gapi::networks(pp)));
|
||||
|
||||
// Assert
|
||||
normAssert(ov_age, gapi_age, "Test age output" );
|
||||
normAssert(ov_gender, gapi_gender, "Test gender output");
|
||||
validate();
|
||||
}
|
||||
|
||||
TEST(TestAgeGenderOV, InferGenericImage) {
|
||||
initDLDTDataPath();
|
||||
const std::string xml_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml");
|
||||
const std::string bin_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin");
|
||||
const std::string device = "CPU";
|
||||
|
||||
cv::Mat in_mat(300, 300, CV_8UC3);
|
||||
cv::randu(in_mat, 0, 255);
|
||||
cv::Mat ov_age, ov_gender, gapi_age, gapi_gender;
|
||||
TEST_F(TestAgeGenderOV, InferGenericImage) {
|
||||
const auto in_mat = getRandomImage({300, 300});
|
||||
|
||||
// OpenVINO
|
||||
AGNetOVComp ref(xml_path, bin_path, device);
|
||||
@@ -303,20 +388,11 @@ TEST(TestAgeGenderOV, InferGenericImage) {
|
||||
cv::compile_args(cv::gapi::networks(pp)));
|
||||
|
||||
// Assert
|
||||
normAssert(ov_age, gapi_age, "Test age output" );
|
||||
normAssert(ov_gender, gapi_gender, "Test gender output");
|
||||
validate();
|
||||
}
|
||||
|
||||
TEST(TestAgeGenderOV, InferGenericImageBlob) {
|
||||
initDLDTDataPath();
|
||||
const std::string xml_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml");
|
||||
const std::string bin_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin");
|
||||
const std::string blob_path = "age-gender-recognition-retail-0013.blob";
|
||||
const std::string device = "CPU";
|
||||
|
||||
cv::Mat in_mat(300, 300, CV_8UC3);
|
||||
cv::randu(in_mat, 0, 255);
|
||||
cv::Mat ov_age, ov_gender, gapi_age, gapi_gender;
|
||||
TEST_F(TestAgeGenderOV, InferGeneric_ImageBlob) {
|
||||
const auto in_mat = getRandomImage({300, 300});
|
||||
|
||||
// OpenVINO
|
||||
AGNetOVComp ref(xml_path, bin_path, device);
|
||||
@@ -333,20 +409,11 @@ TEST(TestAgeGenderOV, InferGenericImageBlob) {
|
||||
cv::compile_args(cv::gapi::networks(pp)));
|
||||
|
||||
// Assert
|
||||
normAssert(ov_age, gapi_age, "Test age output" );
|
||||
normAssert(ov_gender, gapi_gender, "Test gender output");
|
||||
validate();
|
||||
}
|
||||
|
||||
TEST(TestAgeGenderOV, InferGenericTensorBlob) {
|
||||
initDLDTDataPath();
|
||||
const std::string xml_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml");
|
||||
const std::string bin_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin");
|
||||
const std::string blob_path = "age-gender-recognition-retail-0013.blob";
|
||||
const std::string device = "CPU";
|
||||
|
||||
cv::Mat in_mat({1, 3, 62, 62}, CV_32F);
|
||||
cv::randu(in_mat, -1, 1);
|
||||
cv::Mat ov_age, ov_gender, gapi_age, gapi_gender;
|
||||
TEST_F(TestAgeGenderOV, InferGeneric_TensorBlob) {
|
||||
const auto in_mat = getRandomTensor({1, 3, 62, 62}, CV_32F);
|
||||
|
||||
// OpenVINO
|
||||
AGNetOVComp ref(xml_path, bin_path, device);
|
||||
@@ -361,19 +428,11 @@ TEST(TestAgeGenderOV, InferGenericTensorBlob) {
|
||||
cv::compile_args(cv::gapi::networks(pp)));
|
||||
|
||||
// Assert
|
||||
normAssert(ov_age, gapi_age, "Test age output" );
|
||||
normAssert(ov_gender, gapi_gender, "Test gender output");
|
||||
validate();
|
||||
}
|
||||
|
||||
TEST(TestAgeGenderOV, InferBothOutputsFP16) {
|
||||
initDLDTDataPath();
|
||||
const std::string xml_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml");
|
||||
const std::string bin_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin");
|
||||
const std::string device = "CPU";
|
||||
|
||||
cv::Mat in_mat({1, 3, 62, 62}, CV_32F);
|
||||
cv::randu(in_mat, -1, 1);
|
||||
cv::Mat ov_age, ov_gender, gapi_age, gapi_gender;
|
||||
TEST_F(TestAgeGenderOV, InferGeneric_BothOutputsFP16) {
|
||||
const auto in_mat = getRandomTensor({1, 3, 62, 62}, CV_32F);
|
||||
|
||||
// OpenVINO
|
||||
AGNetOVComp ref(xml_path, bin_path, device);
|
||||
@@ -392,19 +451,11 @@ TEST(TestAgeGenderOV, InferBothOutputsFP16) {
|
||||
cv::compile_args(cv::gapi::networks(pp)));
|
||||
|
||||
// Assert
|
||||
normAssert(ov_age, gapi_age, "Test age output" );
|
||||
normAssert(ov_gender, gapi_gender, "Test gender output");
|
||||
validate();
|
||||
}
|
||||
|
||||
TEST(TestAgeGenderOV, InferOneOutputFP16) {
|
||||
initDLDTDataPath();
|
||||
const std::string xml_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml");
|
||||
const std::string bin_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin");
|
||||
const std::string device = "CPU";
|
||||
|
||||
cv::Mat in_mat({1, 3, 62, 62}, CV_32F);
|
||||
cv::randu(in_mat, -1, 1);
|
||||
cv::Mat ov_age, ov_gender, gapi_age, gapi_gender;
|
||||
TEST_F(TestAgeGenderOV, InferGeneric_OneOutputFP16) {
|
||||
const auto in_mat = getRandomTensor({1, 3, 62, 62}, CV_32F);
|
||||
|
||||
// OpenVINO
|
||||
const std::string fp16_output_name = "prob";
|
||||
@@ -423,17 +474,10 @@ TEST(TestAgeGenderOV, InferOneOutputFP16) {
|
||||
cv::compile_args(cv::gapi::networks(pp)));
|
||||
|
||||
// Assert
|
||||
normAssert(ov_age, gapi_age, "Test age output" );
|
||||
normAssert(ov_gender, gapi_gender, "Test gender output");
|
||||
validate();
|
||||
}
|
||||
|
||||
TEST(TestAgeGenderOV, ThrowCfgOutputPrecForBlob) {
|
||||
initDLDTDataPath();
|
||||
const std::string xml_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml");
|
||||
const std::string bin_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin");
|
||||
const std::string blob_path = "age-gender-recognition-retail-0013.blob";
|
||||
const std::string device = "CPU";
|
||||
|
||||
TEST_F(TestAgeGenderOV, InferGeneric_ThrowCfgOutputPrecForBlob) {
|
||||
// OpenVINO (Just for blob compilation)
|
||||
AGNetOVComp ref(xml_path, bin_path, device);
|
||||
auto cc_ref = ref.compile();
|
||||
@@ -446,12 +490,7 @@ TEST(TestAgeGenderOV, ThrowCfgOutputPrecForBlob) {
|
||||
EXPECT_ANY_THROW(pp.cfgOutputTensorPrecision(CV_16F));
|
||||
}
|
||||
|
||||
TEST(TestAgeGenderOV, ThrowInvalidConfigIR) {
|
||||
initDLDTDataPath();
|
||||
const std::string xml_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml");
|
||||
const std::string bin_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin");
|
||||
const std::string device = "CPU";
|
||||
|
||||
TEST_F(TestAgeGenderOV, InferGeneric_ThrowInvalidConfigIR) {
|
||||
// G-API
|
||||
auto comp = AGNetGenComp::create();
|
||||
auto pp = AGNetGenComp::params(xml_path, bin_path, device);
|
||||
@@ -461,13 +500,7 @@ TEST(TestAgeGenderOV, ThrowInvalidConfigIR) {
|
||||
cv::compile_args(cv::gapi::networks(pp))));
|
||||
}
|
||||
|
||||
TEST(TestAgeGenderOV, ThrowInvalidConfigBlob) {
|
||||
initDLDTDataPath();
|
||||
const std::string xml_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml");
|
||||
const std::string bin_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin");
|
||||
const std::string blob_path = "age-gender-recognition-retail-0013.blob";
|
||||
const std::string device = "CPU";
|
||||
|
||||
TEST_F(TestAgeGenderOV, InferGeneric_ThrowInvalidConfigBlob) {
|
||||
// OpenVINO (Just for blob compilation)
|
||||
AGNetOVComp ref(xml_path, bin_path, device);
|
||||
auto cc_ref = ref.compile();
|
||||
@@ -482,16 +515,8 @@ TEST(TestAgeGenderOV, ThrowInvalidConfigBlob) {
|
||||
cv::compile_args(cv::gapi::networks(pp))));
|
||||
}
|
||||
|
||||
TEST(TestAgeGenderOV, ThrowInvalidImageLayout) {
|
||||
initDLDTDataPath();
|
||||
const std::string xml_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml");
|
||||
const std::string bin_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin");
|
||||
const std::string device = "CPU";
|
||||
|
||||
// NB: This mat may only have "NHWC" layout.
|
||||
cv::Mat in_mat(300, 300, CV_8UC3);
|
||||
cv::randu(in_mat, 0, 255);
|
||||
cv::Mat gender, gapi_age, gapi_gender;
|
||||
TEST_F(TestAgeGenderOV, Infer_ThrowInvalidImageLayout) {
|
||||
const auto in_mat = getRandomImage({300, 300});
|
||||
auto comp = AGNetTypedComp::create();
|
||||
auto pp = AGNetTypedComp::params(xml_path, bin_path, device);
|
||||
|
||||
@@ -501,15 +526,8 @@ TEST(TestAgeGenderOV, ThrowInvalidImageLayout) {
|
||||
cv::compile_args(cv::gapi::networks(pp))));
|
||||
}
|
||||
|
||||
TEST(TestAgeGenderOV, InferTensorWithPreproc) {
|
||||
initDLDTDataPath();
|
||||
const std::string xml_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.xml");
|
||||
const std::string bin_path = findDataFile(SUBDIR + "age-gender-recognition-retail-0013.bin");
|
||||
const std::string device = "CPU";
|
||||
|
||||
cv::Mat in_mat({1, 240, 320, 3}, CV_32F);
|
||||
cv::randu(in_mat, -1, 1);
|
||||
cv::Mat ov_age, ov_gender, gapi_age, gapi_gender;
|
||||
TEST_F(TestAgeGenderOV, Infer_TensorWithPreproc) {
|
||||
const auto in_mat = getRandomTensor({1, 240, 320, 3}, CV_32F);
|
||||
|
||||
// OpenVINO
|
||||
AGNetOVComp ref(xml_path, bin_path, device);
|
||||
@@ -531,8 +549,112 @@ TEST(TestAgeGenderOV, InferTensorWithPreproc) {
|
||||
cv::compile_args(cv::gapi::networks(pp)));
|
||||
|
||||
// Assert
|
||||
normAssert(ov_age, gapi_age, "Test age output" );
|
||||
normAssert(ov_gender, gapi_gender, "Test gender output");
|
||||
validate();
|
||||
}
|
||||
|
||||
TEST_F(TestAgeGenderOV, InferROIGeneric_Image) {
|
||||
const auto in_mat = getRandomImage({300, 300});
|
||||
cv::Rect roi(cv::Rect(cv::Point{64, 60}, cv::Size{96, 96}));
|
||||
|
||||
// OpenVINO
|
||||
AGNetOVComp ref(xml_path, bin_path, device);
|
||||
ref.cfgPrePostProcessing([](ov::preprocess::PrePostProcessor &ppp) {
|
||||
ppp.input().tensor().set_element_type(ov::element::u8);
|
||||
ppp.input().tensor().set_layout("NHWC");
|
||||
});
|
||||
ref.compile()(in_mat, roi, ov_age, ov_gender);
|
||||
|
||||
// G-API
|
||||
auto comp = AGNetROIGenComp::create();
|
||||
auto pp = AGNetROIGenComp::params(xml_path, bin_path, device);
|
||||
|
||||
comp.apply(cv::gin(in_mat, roi), cv::gout(gapi_age, gapi_gender),
|
||||
cv::compile_args(cv::gapi::networks(pp)));
|
||||
|
||||
// Assert
|
||||
validate();
|
||||
}
|
||||
|
||||
TEST_F(TestAgeGenderOV, InferROIGeneric_ThrowIncorrectLayout) {
|
||||
const auto in_mat = getRandomImage({300, 300});
|
||||
cv::Rect roi(cv::Rect(cv::Point{64, 60}, cv::Size{96, 96}));
|
||||
|
||||
// G-API
|
||||
auto comp = AGNetROIGenComp::create();
|
||||
auto pp = AGNetROIGenComp::params(xml_path, bin_path, device);
|
||||
|
||||
pp.cfgInputTensorLayout("NCHW");
|
||||
EXPECT_ANY_THROW(comp.apply(cv::gin(in_mat, roi), cv::gout(gapi_age, gapi_gender),
|
||||
cv::compile_args(cv::gapi::networks(pp))));
|
||||
}
|
||||
|
||||
TEST_F(TestAgeGenderOV, InferROIGeneric_ThrowTensorInput) {
|
||||
const auto in_mat = getRandomTensor({1, 3, 62, 62}, CV_32F);
|
||||
cv::Rect roi(cv::Rect(cv::Point{64, 60}, cv::Size{96, 96}));
|
||||
|
||||
// G-API
|
||||
auto comp = AGNetROIGenComp::create();
|
||||
auto pp = AGNetROIGenComp::params(xml_path, bin_path, device);
|
||||
|
||||
EXPECT_ANY_THROW(comp.apply(cv::gin(in_mat, roi), cv::gout(gapi_age, gapi_gender),
|
||||
cv::compile_args(cv::gapi::networks(pp))));
|
||||
}
|
||||
|
||||
TEST_F(TestAgeGenderOV, InferROIGeneric_ThrowExplicitResize) {
|
||||
const auto in_mat = getRandomImage({300, 300});
|
||||
cv::Rect roi(cv::Rect(cv::Point{64, 60}, cv::Size{96, 96}));
|
||||
|
||||
// G-API
|
||||
auto comp = AGNetROIGenComp::create();
|
||||
auto pp = AGNetROIGenComp::params(xml_path, bin_path, device);
|
||||
|
||||
pp.cfgResize(cv::INTER_LINEAR);
|
||||
EXPECT_ANY_THROW(comp.apply(cv::gin(in_mat, roi), cv::gout(gapi_age, gapi_gender),
|
||||
cv::compile_args(cv::gapi::networks(pp))));
|
||||
}
|
||||
|
||||
TEST_F(TestAgeGenderListOV, InferListGeneric_Image) {
|
||||
const auto in_mat = getRandomImage({300, 300});
|
||||
|
||||
// OpenVINO
|
||||
AGNetOVComp ref(xml_path, bin_path, device);
|
||||
ref.cfgPrePostProcessing([](ov::preprocess::PrePostProcessor &ppp) {
|
||||
ppp.input().tensor().set_element_type(ov::element::u8);
|
||||
ppp.input().tensor().set_layout("NHWC");
|
||||
});
|
||||
ref.compile()(in_mat, roi_list, ov_age, ov_gender);
|
||||
|
||||
// G-API
|
||||
auto comp = AGNetListGenComp::create();
|
||||
auto pp = AGNetListGenComp::params(xml_path, bin_path, device);
|
||||
|
||||
comp.apply(cv::gin(in_mat, roi_list), cv::gout(gapi_age, gapi_gender),
|
||||
cv::compile_args(cv::gapi::networks(pp)));
|
||||
|
||||
// Assert
|
||||
validate();
|
||||
}
|
||||
|
||||
TEST_F(TestAgeGenderListOV, InferList2Generic_Image) {
|
||||
const auto in_mat = getRandomImage({300, 300});
|
||||
|
||||
// OpenVINO
|
||||
AGNetOVComp ref(xml_path, bin_path, device);
|
||||
ref.cfgPrePostProcessing([](ov::preprocess::PrePostProcessor &ppp) {
|
||||
ppp.input().tensor().set_element_type(ov::element::u8);
|
||||
ppp.input().tensor().set_layout("NHWC");
|
||||
});
|
||||
ref.compile()(in_mat, roi_list, ov_age, ov_gender);
|
||||
|
||||
// G-API
|
||||
auto comp = AGNetList2GenComp::create();
|
||||
auto pp = AGNetList2GenComp::params(xml_path, bin_path, device);
|
||||
|
||||
comp.apply(cv::gin(in_mat, roi_list), cv::gout(gapi_age, gapi_gender),
|
||||
cv::compile_args(cv::gapi::networks(pp)));
|
||||
|
||||
// Assert
|
||||
validate();
|
||||
}
|
||||
|
||||
} // namespace opencv_test
|
||||
|
||||
@@ -30,7 +30,8 @@ namespace
|
||||
, nullptr
|
||||
, { GShape::GMAT }
|
||||
, { D::OpaqueKind::CV_UNKNOWN }
|
||||
, { cv::detail::HostCtor{cv::util::monostate{}} }
|
||||
, { D::HostCtor{cv::util::monostate{}} }
|
||||
, { D::OpaqueKind::CV_UNKNOWN }
|
||||
}).pass(m).yield(0);
|
||||
}
|
||||
|
||||
@@ -41,7 +42,8 @@ namespace
|
||||
, nullptr
|
||||
, { GShape::GMAT }
|
||||
, { D::OpaqueKind::CV_UNKNOWN, D::OpaqueKind::CV_UNKNOWN }
|
||||
, { cv::detail::HostCtor{cv::util::monostate{}} }
|
||||
, { D::HostCtor{cv::util::monostate{}} }
|
||||
, { D::OpaqueKind::CV_UNKNOWN}
|
||||
}).pass(m1, m2).yield(0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user