Repository for OpenCV's extra modules
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

51 lines
1.2 KiB

// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
// Copyright (C) 2016, Intel Corporation, all rights reserved.
// Third party copyrights are property of their respective owners.
/*
Test for Tensorflow models loading
*/
#include "test_precomp.hpp"
namespace cvtest
{
using namespace cv;
using namespace cv::dnn;
template<typename TString>
static std::string _tf(TString filename)
{
return (getOpenCVExtraDir() + "/dnn/") + filename;
}
TEST(Test_TensorFlow, read_inception)
{
Net net;
{
Ptr<Importer> importer = createTensorflowImporter(_tf("tensorflow_inception_graph.pb"));
ASSERT_TRUE(importer != NULL);
importer->populateNet(net);
}
Mat sample = imread(_tf("grace_hopper.jpg"));
ASSERT_TRUE(!sample.empty());
Mat input;
resize(sample, input, Size(224, 224));
input -= 128; // mean sub
std::vector<Mat> inpMats;
inpMats.push_back(input);
net.setBlob("_input.input", Blob(inpMats));
net.forward();
Blob out = net.getBlob("output");
std::cout << out.dims() << std::endl;
}
}