@@ -56,16 +56,10 @@ static std::string _tf(TString filename)
56
56
return (getOpenCVExtraDir () + " /dnn/" ) + filename;
57
57
}
58
58
59
- static void launchGoogleNetTest ( )
59
+ TEST (Reproducibility_GoogLeNet, Accuracy )
60
60
{
61
- Net net;
62
- {
63
- const string proto = findDataFile (" dnn/bvlc_googlenet.prototxt" , false );
64
- const string model = findDataFile (" dnn/bvlc_googlenet.caffemodel" , false );
65
- Ptr<Importer> importer = createCaffeImporter (proto, model);
66
- ASSERT_TRUE (importer != NULL );
67
- importer->populateNet (net);
68
- }
61
+ Net net = readNetFromCaffe (findDataFile (" dnn/bvlc_googlenet.prototxt" , false ),
62
+ findDataFile (" dnn/bvlc_googlenet.caffemodel" , false ));
69
63
70
64
std::vector<Mat> inpMats;
71
65
inpMats.push_back ( imread (_tf (" googlenet_0.png" )) );
@@ -77,14 +71,20 @@ static void launchGoogleNetTest()
77
71
78
72
Mat ref = blobFromNPY (_tf (" googlenet_prob.npy" ));
79
73
normAssert (out, ref);
74
+ }
75
+
76
+ TEST (IntermediateBlobs_GoogLeNet, Accuracy)
77
+ {
78
+ Net net = readNetFromCaffe (findDataFile (" dnn/bvlc_googlenet.prototxt" , false ),
79
+ findDataFile (" dnn/bvlc_googlenet.caffemodel" , false ));
80
80
81
81
std::vector<String> blobsNames;
82
82
blobsNames.push_back (" conv1/7x7_s2" );
83
83
blobsNames.push_back (" conv1/relu_7x7" );
84
84
blobsNames.push_back (" inception_4c/1x1" );
85
85
blobsNames.push_back (" inception_4c/relu_1x1" );
86
86
std::vector<Mat> outs;
87
- Mat in = blobFromImage (inpMats[ 0 ] );
87
+ Mat in = blobFromImage (imread ( _tf ( " googlenet_0.png " )) );
88
88
net.setInput (in, " data" );
89
89
net.forward (outs, blobsNames);
90
90
CV_Assert (outs.size () == blobsNames.size ());
@@ -95,13 +95,37 @@ static void launchGoogleNetTest()
95
95
std::replace ( filename.begin (), filename.end (), ' /' , ' #' );
96
96
Mat ref = blobFromNPY (_tf (" googlenet_" + filename + " .npy" ));
97
97
98
- // normAssert(outs[i], ref, "", 1E-4, 1E-2);
98
+ normAssert (outs[i], ref, " " , 1E-4 , 1E-2 );
99
99
}
100
100
}
101
101
102
- TEST (Reproducibility_GoogLeNet , Accuracy)
102
+ TEST (SeveralCalls_GoogLeNet , Accuracy)
103
103
{
104
- launchGoogleNetTest ();
104
+ Net net = readNetFromCaffe (findDataFile (" dnn/bvlc_googlenet.prototxt" , false ),
105
+ findDataFile (" dnn/bvlc_googlenet.caffemodel" , false ));
106
+
107
+ std::vector<Mat> inpMats;
108
+ inpMats.push_back ( imread (_tf (" googlenet_0.png" )) );
109
+ inpMats.push_back ( imread (_tf (" googlenet_1.png" )) );
110
+ ASSERT_TRUE (!inpMats[0 ].empty () && !inpMats[1 ].empty ());
111
+
112
+ net.setInput (blobFromImages (inpMats), " data" );
113
+ Mat out = net.forward ();
114
+
115
+ Mat ref = blobFromNPY (_tf (" googlenet_prob.npy" ));
116
+ normAssert (out, ref);
117
+
118
+ std::vector<String> blobsNames;
119
+ blobsNames.push_back (" conv1/7x7_s2" );
120
+ std::vector<Mat> outs;
121
+ Mat in = blobFromImage (inpMats[0 ]);
122
+ net.setInput (in, " data" );
123
+ net.forward (outs, blobsNames);
124
+ CV_Assert (outs.size () == blobsNames.size ());
125
+
126
+ ref = blobFromNPY (_tf (" googlenet_conv1#7x7_s2.npy" ));
127
+
128
+ normAssert (outs[0 ], ref, " " , 1E-4 , 1E-2 );
105
129
}
106
130
107
131
}
0 commit comments