|
|
|
@ -56,16 +56,10 @@ static std::string _tf(TString filename) |
|
|
|
|
return (getOpenCVExtraDir() + "/dnn/") + filename; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void launchGoogleNetTest() |
|
|
|
|
TEST(Reproducibility_GoogLeNet, Accuracy) |
|
|
|
|
{ |
|
|
|
|
Net net; |
|
|
|
|
{ |
|
|
|
|
const string proto = findDataFile("dnn/bvlc_googlenet.prototxt", false); |
|
|
|
|
const string model = findDataFile("dnn/bvlc_googlenet.caffemodel", false); |
|
|
|
|
Ptr<Importer> importer = createCaffeImporter(proto, model); |
|
|
|
|
ASSERT_TRUE(importer != NULL); |
|
|
|
|
importer->populateNet(net); |
|
|
|
|
} |
|
|
|
|
Net net = readNetFromCaffe(findDataFile("dnn/bvlc_googlenet.prototxt", false), |
|
|
|
|
findDataFile("dnn/bvlc_googlenet.caffemodel", false)); |
|
|
|
|
|
|
|
|
|
std::vector<Mat> inpMats; |
|
|
|
|
inpMats.push_back( imread(_tf("googlenet_0.png")) ); |
|
|
|
@ -77,6 +71,12 @@ static void launchGoogleNetTest() |
|
|
|
|
|
|
|
|
|
Mat ref = blobFromNPY(_tf("googlenet_prob.npy")); |
|
|
|
|
normAssert(out, ref); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST(IntermediateBlobs_GoogLeNet, Accuracy) |
|
|
|
|
{ |
|
|
|
|
Net net = readNetFromCaffe(findDataFile("dnn/bvlc_googlenet.prototxt", false), |
|
|
|
|
findDataFile("dnn/bvlc_googlenet.caffemodel", false)); |
|
|
|
|
|
|
|
|
|
std::vector<String> blobsNames; |
|
|
|
|
blobsNames.push_back("conv1/7x7_s2"); |
|
|
|
@ -84,7 +84,7 @@ static void launchGoogleNetTest() |
|
|
|
|
blobsNames.push_back("inception_4c/1x1"); |
|
|
|
|
blobsNames.push_back("inception_4c/relu_1x1"); |
|
|
|
|
std::vector<Mat> outs; |
|
|
|
|
Mat in = blobFromImage(inpMats[0]); |
|
|
|
|
Mat in = blobFromImage(imread(_tf("googlenet_0.png"))); |
|
|
|
|
net.setInput(in, "data"); |
|
|
|
|
net.forward(outs, blobsNames); |
|
|
|
|
CV_Assert(outs.size() == blobsNames.size()); |
|
|
|
@ -95,13 +95,37 @@ static void launchGoogleNetTest() |
|
|
|
|
std::replace( filename.begin(), filename.end(), '/', '#'); |
|
|
|
|
Mat ref = blobFromNPY(_tf("googlenet_" + filename + ".npy")); |
|
|
|
|
|
|
|
|
|
//normAssert(outs[i], ref, "", 1E-4, 1E-2);
|
|
|
|
|
normAssert(outs[i], ref, "", 1E-4, 1E-2); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST(Reproducibility_GoogLeNet, Accuracy) |
|
|
|
|
TEST(SeveralCalls_GoogLeNet, Accuracy) |
|
|
|
|
{ |
|
|
|
|
launchGoogleNetTest(); |
|
|
|
|
Net net = readNetFromCaffe(findDataFile("dnn/bvlc_googlenet.prototxt", false), |
|
|
|
|
findDataFile("dnn/bvlc_googlenet.caffemodel", false)); |
|
|
|
|
|
|
|
|
|
std::vector<Mat> inpMats; |
|
|
|
|
inpMats.push_back( imread(_tf("googlenet_0.png")) ); |
|
|
|
|
inpMats.push_back( imread(_tf("googlenet_1.png")) ); |
|
|
|
|
ASSERT_TRUE(!inpMats[0].empty() && !inpMats[1].empty()); |
|
|
|
|
|
|
|
|
|
net.setInput(blobFromImages(inpMats), "data"); |
|
|
|
|
Mat out = net.forward(); |
|
|
|
|
|
|
|
|
|
Mat ref = blobFromNPY(_tf("googlenet_prob.npy")); |
|
|
|
|
normAssert(out, ref); |
|
|
|
|
|
|
|
|
|
std::vector<String> blobsNames; |
|
|
|
|
blobsNames.push_back("conv1/7x7_s2"); |
|
|
|
|
std::vector<Mat> outs; |
|
|
|
|
Mat in = blobFromImage(inpMats[0]); |
|
|
|
|
net.setInput(in, "data"); |
|
|
|
|
net.forward(outs, blobsNames); |
|
|
|
|
CV_Assert(outs.size() == blobsNames.size()); |
|
|
|
|
|
|
|
|
|
ref = blobFromNPY(_tf("googlenet_conv1#7x7_s2.npy")); |
|
|
|
|
|
|
|
|
|
normAssert(outs[0], ref, "", 1E-4, 1E-2); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|