Enable some tests for clDNN plugin from Intel's Inference Engine
This commit is contained in:
@@ -23,9 +23,9 @@ public:
|
||||
}
|
||||
|
||||
void processNet(const std::string& weights, const std::string& proto,
|
||||
Size inpSize, const std::string& outputLayer,
|
||||
Size inpSize, const std::string& outputLayer = "",
|
||||
const std::string& halideScheduler = "",
|
||||
double l1 = 1e-5, double lInf = 1e-4)
|
||||
double l1 = 0.0, double lInf = 0.0)
|
||||
{
|
||||
// Create a common input blob.
|
||||
int blobSize[] = {1, 3, inpSize.height, inpSize.width};
|
||||
@@ -36,9 +36,9 @@ public:
|
||||
}
|
||||
|
||||
void processNet(std::string weights, std::string proto,
|
||||
Mat inp, const std::string& outputLayer,
|
||||
Mat inp, const std::string& outputLayer = "",
|
||||
std::string halideScheduler = "",
|
||||
double l1 = 1e-5, double lInf = 1e-4)
|
||||
double l1 = 0.0, double lInf = 0.0)
|
||||
{
|
||||
if (backend == DNN_BACKEND_DEFAULT && target == DNN_TARGET_OPENCL)
|
||||
{
|
||||
@@ -49,6 +49,16 @@ public:
|
||||
throw SkipTestException("OpenCL is not available/disabled in OpenCV");
|
||||
}
|
||||
}
|
||||
if (target == DNN_TARGET_OPENCL_FP16)
|
||||
{
|
||||
l1 = l1 == 0.0 ? 4e-3 : l1;
|
||||
lInf = lInf == 0.0 ? 2e-2 : lInf;
|
||||
}
|
||||
else
|
||||
{
|
||||
l1 = l1 == 0.0 ? 1e-5 : l1;
|
||||
lInf = lInf == 0.0 ? 1e-4 : lInf;
|
||||
}
|
||||
weights = findDataFile(weights, false);
|
||||
if (!proto.empty())
|
||||
proto = findDataFile(proto, false);
|
||||
@@ -71,31 +81,28 @@ public:
|
||||
Mat out = net.forward(outputLayer).clone();
|
||||
|
||||
if (outputLayer == "detection_out")
|
||||
normAssertDetections(outDefault, out, "First run", 0.2);
|
||||
normAssertDetections(outDefault, out, "First run", 0.2, l1, lInf);
|
||||
else
|
||||
normAssert(outDefault, out, "First run", l1, lInf);
|
||||
|
||||
// Test 2: change input.
|
||||
inp *= 0.1f;
|
||||
float* inpData = (float*)inp.data;
|
||||
for (int i = 0; i < inp.size[0] * inp.size[1]; ++i)
|
||||
{
|
||||
Mat slice(inp.size[2], inp.size[3], CV_32F, inpData);
|
||||
cv::flip(slice, slice, 1);
|
||||
inpData += slice.total();
|
||||
}
|
||||
netDefault.setInput(inp);
|
||||
net.setInput(inp);
|
||||
outDefault = netDefault.forward(outputLayer).clone();
|
||||
out = net.forward(outputLayer).clone();
|
||||
|
||||
if (outputLayer == "detection_out")
|
||||
checkDetections(outDefault, out, "Second run", l1, lInf);
|
||||
normAssertDetections(outDefault, out, "Second run", 0.2, l1, lInf);
|
||||
else
|
||||
normAssert(outDefault, out, "Second run", l1, lInf);
|
||||
}
|
||||
|
||||
void checkDetections(const Mat& out, const Mat& ref, const std::string& msg,
|
||||
float l1, float lInf, int top = 5)
|
||||
{
|
||||
top = std::min(std::min(top, out.size[2]), out.size[3]);
|
||||
std::vector<cv::Range> range(4, cv::Range::all());
|
||||
range[2] = cv::Range(0, top);
|
||||
normAssert(out(range), ref(range));
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(DNNTestNetwork, AlexNet)
|
||||
@@ -110,8 +117,6 @@ TEST_P(DNNTestNetwork, AlexNet)
|
||||
|
||||
TEST_P(DNNTestNetwork, ResNet_50)
|
||||
{
|
||||
if (backend == DNN_BACKEND_INFERENCE_ENGINE && target == DNN_TARGET_OPENCL_FP16)
|
||||
throw SkipTestException("");
|
||||
processNet("dnn/ResNet-50-model.caffemodel", "dnn/ResNet-50-deploy.prototxt",
|
||||
Size(224, 224), "prob",
|
||||
target == DNN_TARGET_OPENCL ? "dnn/halide_scheduler_opencl_resnet_50.yml" :
|
||||
@@ -120,8 +125,6 @@ TEST_P(DNNTestNetwork, ResNet_50)
|
||||
|
||||
TEST_P(DNNTestNetwork, SqueezeNet_v1_1)
|
||||
{
|
||||
if (backend == DNN_BACKEND_INFERENCE_ENGINE && target == DNN_TARGET_OPENCL_FP16)
|
||||
throw SkipTestException("");
|
||||
processNet("dnn/squeezenet_v1.1.caffemodel", "dnn/squeezenet_v1.1.prototxt",
|
||||
Size(227, 227), "prob",
|
||||
target == DNN_TARGET_OPENCL ? "dnn/halide_scheduler_opencl_squeezenet_v1_1.yml" :
|
||||
@@ -130,8 +133,6 @@ TEST_P(DNNTestNetwork, SqueezeNet_v1_1)
|
||||
|
||||
TEST_P(DNNTestNetwork, GoogLeNet)
|
||||
{
|
||||
if (backend == DNN_BACKEND_INFERENCE_ENGINE && target == DNN_TARGET_OPENCL_FP16)
|
||||
throw SkipTestException("");
|
||||
processNet("dnn/bvlc_googlenet.caffemodel", "dnn/bvlc_googlenet.prototxt",
|
||||
Size(224, 224), "prob");
|
||||
}
|
||||
@@ -180,7 +181,7 @@ TEST_P(DNNTestNetwork, SSD_VGG16)
|
||||
{
|
||||
if (backend == DNN_BACKEND_DEFAULT && target == DNN_TARGET_OPENCL ||
|
||||
backend == DNN_BACKEND_HALIDE && target == DNN_TARGET_CPU ||
|
||||
backend == DNN_BACKEND_INFERENCE_ENGINE)
|
||||
backend == DNN_BACKEND_INFERENCE_ENGINE && target != DNN_TARGET_CPU)
|
||||
throw SkipTestException("");
|
||||
processNet("dnn/VGG_ILSVRC2016_SSD_300x300_iter_440000.caffemodel",
|
||||
"dnn/ssd_vgg16.prototxt", Size(300, 300), "detection_out");
|
||||
@@ -189,30 +190,24 @@ TEST_P(DNNTestNetwork, SSD_VGG16)
|
||||
TEST_P(DNNTestNetwork, OpenPose_pose_coco)
|
||||
{
|
||||
if (backend == DNN_BACKEND_HALIDE) throw SkipTestException("");
|
||||
double l1 = target == DNN_TARGET_OPENCL_FP16 ? 3e-5 : 1e-5;
|
||||
double lInf = target == DNN_TARGET_OPENCL_FP16 ? 3e-3 : 1e-4;
|
||||
processNet("dnn/openpose_pose_coco.caffemodel", "dnn/openpose_pose_coco.prototxt",
|
||||
Size(368, 368), "", "", l1, lInf);
|
||||
Size(368, 368));
|
||||
}
|
||||
|
||||
TEST_P(DNNTestNetwork, OpenPose_pose_mpi)
|
||||
{
|
||||
if (backend == DNN_BACKEND_HALIDE) throw SkipTestException("");
|
||||
double l1 = target == DNN_TARGET_OPENCL_FP16 ? 4e-5 : 1e-5;
|
||||
double lInf = target == DNN_TARGET_OPENCL_FP16 ? 7e-3 : 1e-4;
|
||||
processNet("dnn/openpose_pose_mpi.caffemodel", "dnn/openpose_pose_mpi.prototxt",
|
||||
Size(368, 368), "", "", l1, lInf);
|
||||
Size(368, 368));
|
||||
}
|
||||
|
||||
TEST_P(DNNTestNetwork, OpenPose_pose_mpi_faster_4_stages)
|
||||
{
|
||||
if (backend == DNN_BACKEND_HALIDE) throw SkipTestException("");
|
||||
double l1 = target == DNN_TARGET_OPENCL_FP16 ? 5e-5 : 1e-5;
|
||||
double lInf = target == DNN_TARGET_OPENCL_FP16 ? 5e-3 : 1e-4;
|
||||
// The same .caffemodel but modified .prototxt
|
||||
// See https://github.com/CMU-Perceptual-Computing-Lab/openpose/blob/master/src/openpose/pose/poseParameters.cpp
|
||||
processNet("dnn/openpose_pose_mpi.caffemodel", "dnn/openpose_pose_mpi_faster_4_stages.prototxt",
|
||||
Size(368, 368), "", "", l1, lInf);
|
||||
Size(368, 368));
|
||||
}
|
||||
|
||||
TEST_P(DNNTestNetwork, OpenFace)
|
||||
|
||||
Reference in New Issue
Block a user