mirror of
https://github.com/opencv/opencv.git
synced 2025-06-07 17:44:04 +08:00
Fix false positives of face detection network for large faces
This commit is contained in:
parent
ad092bf1ce
commit
a2125594ea
@ -561,7 +561,7 @@ TEST(Test_Caffe, shared_weights)
|
|||||||
typedef testing::TestWithParam<tuple<std::string, Target> > opencv_face_detector;
|
typedef testing::TestWithParam<tuple<std::string, Target> > 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");
|
||||||
std::string model = findDataFile(get<0>(GetParam()), false);
|
std::string model = findDataFile(get<0>(GetParam()), false);
|
||||||
dnn::Target targetId = (dnn::Target)(int)get<1>(GetParam());
|
dnn::Target targetId = (dnn::Target)(int)get<1>(GetParam());
|
||||||
|
|
||||||
@ -584,6 +584,29 @@ TEST_P(opencv_face_detector, Accuracy)
|
|||||||
0, 1, 0.95097077, 0.51901293, 0.45863652, 0.5777427, 0.5347801);
|
0, 1, 0.95097077, 0.51901293, 0.45863652, 0.5777427, 0.5347801);
|
||||||
normAssertDetections(ref, out, "", 0.5, 1e-5, 2e-4);
|
normAssertDetections(ref, out, "", 0.5, 1e-5, 2e-4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// False positives bug for large faces: https://github.com/opencv/opencv/issues/15106
|
||||||
|
TEST_P(opencv_face_detector, issue_15106)
|
||||||
|
{
|
||||||
|
std::string proto = findDataFile("dnn/opencv_face_detector.prototxt");
|
||||||
|
std::string model = findDataFile(get<0>(GetParam()), false);
|
||||||
|
dnn::Target targetId = (dnn::Target)(int)get<1>(GetParam());
|
||||||
|
|
||||||
|
Net net = readNetFromCaffe(proto, model);
|
||||||
|
Mat img = imread(findDataFile("cv/shared/lena.png"));
|
||||||
|
img = img.rowRange(img.rows / 4, 3 * img.rows / 4).colRange(img.cols / 4, 3 * img.cols / 4);
|
||||||
|
Mat blob = blobFromImage(img, 1.0, Size(300, 300), Scalar(104.0, 177.0, 123.0), false, false);
|
||||||
|
|
||||||
|
net.setPreferableBackend(DNN_BACKEND_OPENCV);
|
||||||
|
net.setPreferableTarget(targetId);
|
||||||
|
|
||||||
|
net.setInput(blob);
|
||||||
|
// Output has shape 1x1xNx7 where N - number of detections.
|
||||||
|
// An every detection is a vector of values [id, classId, confidence, left, top, right, bottom]
|
||||||
|
Mat out = net.forward();
|
||||||
|
Mat ref = (Mat_<float>(1, 7) << 0, 1, 0.9149431, 0.30424616, 0.26964942, 0.88733053, 0.99815309);
|
||||||
|
normAssertDetections(ref, out, "", 0.2, 6e-5, 1e-4);
|
||||||
|
}
|
||||||
INSTANTIATE_TEST_CASE_P(Test_Caffe, opencv_face_detector,
|
INSTANTIATE_TEST_CASE_P(Test_Caffe, opencv_face_detector,
|
||||||
Combine(
|
Combine(
|
||||||
Values("dnn/opencv_face_detector.caffemodel",
|
Values("dnn/opencv_face_detector.caffemodel",
|
||||||
|
@ -892,7 +892,7 @@ layer {
|
|||||||
}
|
}
|
||||||
convolution_param {
|
convolution_param {
|
||||||
num_output: 128
|
num_output: 128
|
||||||
pad: 1
|
pad: 0
|
||||||
kernel_size: 3
|
kernel_size: 3
|
||||||
stride: 1
|
stride: 1
|
||||||
weight_filler {
|
weight_filler {
|
||||||
@ -958,7 +958,7 @@ layer {
|
|||||||
}
|
}
|
||||||
convolution_param {
|
convolution_param {
|
||||||
num_output: 128
|
num_output: 128
|
||||||
pad: 1
|
pad: 0
|
||||||
kernel_size: 3
|
kernel_size: 3
|
||||||
stride: 1
|
stride: 1
|
||||||
weight_filler {
|
weight_filler {
|
||||||
|
1790
samples/dnn/face_detector/deploy_lowres.prototxt
Normal file
1790
samples/dnn/face_detector/deploy_lowres.prototxt
Normal file
File diff suppressed because it is too large
Load Diff
@ -69,7 +69,7 @@ function recognize(face) {
|
|||||||
|
|
||||||
function loadModels(callback) {
|
function loadModels(callback) {
|
||||||
var utils = new Utils('');
|
var utils = new Utils('');
|
||||||
var proto = 'https://raw.githubusercontent.com/opencv/opencv/3.4/samples/dnn/face_detector/deploy.prototxt';
|
var proto = 'https://raw.githubusercontent.com/opencv/opencv/3.4/samples/dnn/face_detector/deploy_lowres.prototxt';
|
||||||
var weights = 'https://raw.githubusercontent.com/opencv/opencv_3rdparty/dnn_samples_face_detector_20180205_fp16/res10_300x300_ssd_iter_140000_fp16.caffemodel';
|
var weights = 'https://raw.githubusercontent.com/opencv/opencv_3rdparty/dnn_samples_face_detector_20180205_fp16/res10_300x300_ssd_iter_140000_fp16.caffemodel';
|
||||||
var recognModel = 'https://raw.githubusercontent.com/pyannote/pyannote-data/master/openface.nn4.small2.v1.t7';
|
var recognModel = 'https://raw.githubusercontent.com/pyannote/pyannote-data/master/openface.nn4.small2.v1.t7';
|
||||||
utils.createFileFromUrl('face_detector.prototxt', proto, () => {
|
utils.createFileFromUrl('face_detector.prototxt', proto, () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user