mirror of
https://github.com/opencv/opencv.git
synced 2025-06-12 12:22:51 +08:00
Fix for opencv face detector ocl test
Signed-off-by: Li Peng <peng.li@intel.com>
This commit is contained in:
parent
c524f669c7
commit
e7d35d51fa
@ -105,6 +105,18 @@ public:
|
|||||||
float norm = pow(absSum, 1.0f / pnorm);
|
float norm = pow(absSum, 1.0f / pnorm);
|
||||||
multiply(src, 1.0f / norm, dst);
|
multiply(src, 1.0f / norm, dst);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Mat norm;
|
||||||
|
reduce(buffer, norm, 0, REDUCE_SUM);
|
||||||
|
norm += epsilon;
|
||||||
|
|
||||||
|
// compute inverted norm to call multiply instead divide
|
||||||
|
cv::pow(norm, -1.0f / pnorm, norm);
|
||||||
|
|
||||||
|
repeat(norm, channels, 1, buffer);
|
||||||
|
multiply(src, buffer, dst);
|
||||||
|
}
|
||||||
|
|
||||||
if (!blobs.empty())
|
if (!blobs.empty())
|
||||||
{
|
{
|
||||||
|
@ -222,9 +222,7 @@ TEST_P(DNNTestNetwork, OpenFace)
|
|||||||
|
|
||||||
TEST_P(DNNTestNetwork, opencv_face_detector)
|
TEST_P(DNNTestNetwork, opencv_face_detector)
|
||||||
{
|
{
|
||||||
if (backend == DNN_BACKEND_HALIDE ||
|
if (backend == DNN_BACKEND_HALIDE) throw SkipTestException("");
|
||||||
backend == DNN_BACKEND_DEFAULT && target == DNN_TARGET_OPENCL)
|
|
||||||
throw SkipTestException("");
|
|
||||||
Mat img = imread(findDataFile("gpu/lbpcascade/er.png", false));
|
Mat img = imread(findDataFile("gpu/lbpcascade/er.png", false));
|
||||||
Mat inp = blobFromImage(img, 1.0, Size(), Scalar(104.0, 177.0, 123.0), false, false);
|
Mat inp = blobFromImage(img, 1.0, Size(), Scalar(104.0, 177.0, 123.0), false, false);
|
||||||
processNet("dnn/opencv_face_detector.caffemodel", "dnn/opencv_face_detector.prototxt",
|
processNet("dnn/opencv_face_detector.caffemodel", "dnn/opencv_face_detector.prototxt",
|
||||||
|
@ -456,16 +456,21 @@ TEST(Test_Caffe, multiple_inputs)
|
|||||||
normAssert(out, first_image + second_image);
|
normAssert(out, first_image + second_image);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef testing::TestWithParam<std::string> opencv_face_detector;
|
CV_ENUM(DNNTarget, DNN_TARGET_CPU, DNN_TARGET_OPENCL)
|
||||||
|
typedef testing::TestWithParam<tuple<std::string, DNNTarget> > opencv_face_detector;
|
||||||
TEST_P(opencv_face_detector, Accuracy)
|
TEST_P(opencv_face_detector, Accuracy)
|
||||||
{
|
{
|
||||||
std::string proto = findDataFile("dnn/opencv_face_detector.prototxt", false);
|
std::string proto = findDataFile("dnn/opencv_face_detector.prototxt", false);
|
||||||
std::string model = findDataFile(GetParam(), false);
|
std::string model = findDataFile(get<0>(GetParam()), false);
|
||||||
|
dnn::Target targetId = (dnn::Target)(int)get<1>(GetParam());
|
||||||
|
|
||||||
Net net = readNetFromCaffe(proto, model);
|
Net net = readNetFromCaffe(proto, model);
|
||||||
Mat img = imread(findDataFile("gpu/lbpcascade/er.png", false));
|
Mat img = imread(findDataFile("gpu/lbpcascade/er.png", false));
|
||||||
Mat blob = blobFromImage(img, 1.0, Size(), Scalar(104.0, 177.0, 123.0), false, false);
|
Mat blob = blobFromImage(img, 1.0, Size(), Scalar(104.0, 177.0, 123.0), false, false);
|
||||||
|
|
||||||
|
net.setPreferableBackend(DNN_BACKEND_DEFAULT);
|
||||||
|
net.setPreferableTarget(targetId);
|
||||||
|
|
||||||
net.setInput(blob);
|
net.setInput(blob);
|
||||||
// Output has shape 1x1xNx7 where N - number of detections.
|
// Output has shape 1x1xNx7 where N - number of detections.
|
||||||
// An every detection is a vector of values [id, classId, confidence, left, top, right, bottom]
|
// An every detection is a vector of values [id, classId, confidence, left, top, right, bottom]
|
||||||
@ -479,11 +484,13 @@ TEST_P(opencv_face_detector, Accuracy)
|
|||||||
0.95097077, 0.51901293, 0.45863652, 0.5777427, 0.5347801);
|
0.95097077, 0.51901293, 0.45863652, 0.5777427, 0.5347801);
|
||||||
normAssert(out.reshape(1, out.total() / 7).rowRange(0, 6).colRange(2, 7), ref);
|
normAssert(out.reshape(1, out.total() / 7).rowRange(0, 6).colRange(2, 7), ref);
|
||||||
}
|
}
|
||||||
INSTANTIATE_TEST_CASE_P(Test_Caffe, opencv_face_detector, Values(
|
INSTANTIATE_TEST_CASE_P(Test_Caffe, opencv_face_detector,
|
||||||
"dnn/opencv_face_detector.caffemodel",
|
Combine(
|
||||||
"dnn/opencv_face_detector_fp16.caffemodel"
|
Values("dnn/opencv_face_detector.caffemodel",
|
||||||
));
|
"dnn/opencv_face_detector_fp16.caffemodel"),
|
||||||
|
Values(DNN_TARGET_CPU, DNN_TARGET_OPENCL)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
TEST(Test_Caffe, FasterRCNN_and_RFCN)
|
TEST(Test_Caffe, FasterRCNN_and_RFCN)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user