Merge pull request #16616 from alalek:dnn_fix_input_shape
* dnn: fix processing of input shapes - importer: avoid using of .setInput() => .setInputShape() - setInput: shape limitation check (partial) * dnn(test): test .setInput() in readNet()
This commit is contained in:
committed by
GitHub
parent
966c2191cb
commit
01048e5603
@@ -78,6 +78,65 @@ TEST(readNet, Regression)
|
||||
EXPECT_FALSE(net.empty());
|
||||
}
|
||||
|
||||
TEST(readNet, do_not_call_setInput) // https://github.com/opencv/opencv/issues/16618
|
||||
{
|
||||
// 1. load network
|
||||
const string proto = findDataFile("dnn/squeezenet_v1.1.prototxt");
|
||||
const string model = findDataFile("dnn/squeezenet_v1.1.caffemodel", false);
|
||||
Net net = readNetFromCaffe(proto, model);
|
||||
|
||||
// 2. mistake: no inputs are specified through .setInput()
|
||||
|
||||
// 3. try inference
|
||||
Mat res;
|
||||
EXPECT_THROW(
|
||||
{
|
||||
res = net.forward(); // no inputs after loading => should fail
|
||||
}, cv::Exception);
|
||||
EXPECT_TRUE(res.empty()) << res.size;
|
||||
}
|
||||
|
||||
#ifdef HAVE_INF_ENGINE
|
||||
static
|
||||
void test_readNet_IE_do_not_call_setInput(Backend backendId)
|
||||
{
|
||||
const Target targetId = DNN_TARGET_CPU;
|
||||
|
||||
const std::string& model = findDataFile("dnn/layers/layer_convolution.bin");
|
||||
const std::string& proto = findDataFile("dnn/layers/layer_convolution.xml");
|
||||
|
||||
if (backendId == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
|
||||
setInferenceEngineBackendType(CV_DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_API);
|
||||
else if (backendId == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
|
||||
setInferenceEngineBackendType(CV_DNN_BACKEND_INFERENCE_ENGINE_NGRAPH);
|
||||
else
|
||||
FAIL() << "Unknown backendId";
|
||||
|
||||
Net net = readNet(model, proto);
|
||||
net.setPreferableBackend(backendId);
|
||||
net.setPreferableTarget(targetId);
|
||||
|
||||
// 2. mistake: no inputs are specified through .setInput()
|
||||
|
||||
// 3. try inference
|
||||
Mat res;
|
||||
EXPECT_THROW(
|
||||
{
|
||||
res = net.forward(); // no inputs after loading => should fail
|
||||
}, cv::Exception);
|
||||
EXPECT_TRUE(res.empty()) << res.size;
|
||||
}
|
||||
|
||||
TEST(readNet, do_not_call_setInput_IE_NN_BUILDER_2019)
|
||||
{
|
||||
test_readNet_IE_do_not_call_setInput(DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019);
|
||||
}
|
||||
TEST(readNet, do_not_call_setInput_IE_NGRAPH)
|
||||
{
|
||||
test_readNet_IE_do_not_call_setInput(DNN_BACKEND_INFERENCE_ENGINE_NGRAPH);
|
||||
}
|
||||
#endif // HAVE_INF_ENGINE
|
||||
|
||||
typedef testing::TestWithParam<tuple<Backend, Target> > dump;
|
||||
TEST_P(dump, Regression)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user