mirror of
https://github.com/opencv/opencv.git
synced 2025-01-18 14:13:15 +08:00
Merge pull request #10983 from dkurt:dnn_face_detection_uint8
This commit is contained in:
commit
7bc980edaf
@ -17,7 +17,6 @@ parser = argparse.ArgumentParser(
|
||||
'using COCO evaluation tool, http://cocodataset.org/#detections-eval')
|
||||
parser.add_argument('--proto', help='Path to .prototxt of Caffe model or .pbtxt of TensorFlow graph')
|
||||
parser.add_argument('--model', help='Path to .caffemodel trained in Caffe or .pb from TensorFlow')
|
||||
parser.add_argument('--caffe', help='Indicate that tested model is from Caffe. Otherwise model from TensorFlow is expected.', action='store_true')
|
||||
parser.add_argument('--cascade', help='Optional path to trained Haar cascade as '
|
||||
'an additional model for evaluation')
|
||||
parser.add_argument('--ann', help='Path to text file with ground truth annotations')
|
||||
@ -141,10 +140,7 @@ with open('annotations.json', 'wt') as f:
|
||||
### Obtain detections ##########################################################
|
||||
detections = []
|
||||
if args.proto and args.model:
|
||||
if args.caffe:
|
||||
net = cv.dnn.readNetFromCaffe(args.proto, args.model)
|
||||
else:
|
||||
net = cv.dnn.readNetFromTensorflow(args.model, args.proto)
|
||||
net = cv.dnn.readNet(args.proto, args.model)
|
||||
|
||||
def detect(img, imageId):
|
||||
imgWidth = img.shape[1]
|
||||
|
@ -13,23 +13,32 @@ if(NOT BUILD_EXAMPLES OR NOT OCV_DEPENDENCIES_FOUND)
|
||||
return()
|
||||
endif()
|
||||
|
||||
# Model branch name: dnn_samples_face_detector_20170830
|
||||
set(DNN_FACE_DETECTOR_MODEL_COMMIT "b2bfc75f6aea5b1f834ff0f0b865a7c18ff1459f")
|
||||
set(DNN_FACE_DETECTOR_MODEL_HASH "afbb6037fd180e8d2acb3b58ca737b9e")
|
||||
set(DNN_FACE_DETECTOR_MODEL_NAME "res10_300x300_ssd_iter_140000.caffemodel")
|
||||
set(DNN_FACE_DETECTOR_MODEL_DOWNLOAD_DIR "${CMAKE_CURRENT_LIST_DIR}/face_detector")
|
||||
if(COMMAND ocv_download)
|
||||
ocv_download(FILENAME ${DNN_FACE_DETECTOR_MODEL_NAME}
|
||||
HASH ${DNN_FACE_DETECTOR_MODEL_HASH}
|
||||
URL
|
||||
"$ENV{OPENCV_DNN_MODELS_URL}"
|
||||
"${OPENCV_DNN_MODELS_URL}"
|
||||
"https://raw.githubusercontent.com/opencv/opencv_3rdparty/${DNN_FACE_DETECTOR_MODEL_COMMIT}/"
|
||||
DESTINATION_DIR ${DNN_FACE_DETECTOR_MODEL_DOWNLOAD_DIR}
|
||||
ID DNN_FACE_DETECTOR
|
||||
RELATIVE_URL
|
||||
STATUS res)
|
||||
endif()
|
||||
function(download_net name commit hash)
|
||||
set(DNN_FACE_DETECTOR_MODEL_DOWNLOAD_DIR "${CMAKE_CURRENT_LIST_DIR}/face_detector")
|
||||
if(COMMAND ocv_download)
|
||||
ocv_download(FILENAME ${name}
|
||||
HASH ${hash}
|
||||
URL
|
||||
"$ENV{OPENCV_DNN_MODELS_URL}"
|
||||
"${OPENCV_DNN_MODELS_URL}"
|
||||
"https://raw.githubusercontent.com/opencv/opencv_3rdparty/${commit}/"
|
||||
DESTINATION_DIR ${DNN_FACE_DETECTOR_MODEL_DOWNLOAD_DIR}
|
||||
ID DNN_FACE_DETECTOR
|
||||
RELATIVE_URL
|
||||
STATUS res)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# Model branch name: dnn_samples_face_detector_20180205_fp16
|
||||
download_net("res10_300x300_ssd_iter_140000_fp16.caffemodel"
|
||||
"19512576c112aa2c7b6328cb0e8d589a4a90a26d"
|
||||
"f737f886e33835410c69e3ccfe0720a1")
|
||||
|
||||
# Model branch name: dnn_samples_face_detector_20180220_uint8
|
||||
download_net("opencv_face_detector_uint8.pb"
|
||||
"7b425df276ba2161b8edaab0f0756f4a735d61b9"
|
||||
"56acf81f55d9b9e96c3347bc65409b9e")
|
||||
|
||||
project(dnn_samples)
|
||||
ocv_include_modules_recurse(${OPENCV_DNN_SAMPLES_REQUIRED_DEPS})
|
||||
file(GLOB_RECURSE dnn_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
|
||||
|
@ -14,6 +14,34 @@
|
||||
| [Faster-RCNN](https://github.com/rbgirshick/py-faster-rcnn) | `1.0` | `800x600` | `102.9801, 115.9465, 122.7717` | BGR |
|
||||
| [R-FCN](https://github.com/YuwenXiong/py-R-FCN) | `1.0` | `800x600` | `102.9801 115.9465 122.7717` | BGR |
|
||||
|
||||
#### Face detection
|
||||
[An origin model](https://github.com/opencv/opencv/tree/master/samples/dnn/face_detector)
|
||||
with single precision floating point weights has been quantized using [TensorFlow framework](https://www.tensorflow.org/).
|
||||
To achieve the best accuracy run the model on BGR images resized to `300x300` applying mean subtraction
|
||||
of values `(104, 177, 123)` for each blue, green and red channels correspondingly.
|
||||
|
||||
The following are accuracy metrics obtained using [COCO object detection evaluation
|
||||
tool](http://cocodataset.org/#detections-eval) on [FDDB dataset](http://vis-www.cs.umass.edu/fddb/)
|
||||
(see [script](https://github.com/opencv/opencv/blob/master/modules/dnn/misc/face_detector_accuracy.py))
|
||||
applying resize to `300x300` and keeping an origin images' sizes.
|
||||
```
|
||||
AP - Average Precision | FP32/FP16 | UINT8 | FP32/FP16 | UINT8 |
|
||||
AR - Average Recall | 300x300 | 300x300 | any size | any size |
|
||||
--------------------------------------------------|-----------|----------------|-----------|----------------|
|
||||
AP @[ IoU=0.50:0.95 | area= all | maxDets=100 ] | 0.408 | 0.408 | 0.378 | 0.328 (-0.050) |
|
||||
AP @[ IoU=0.50 | area= all | maxDets=100 ] | 0.849 | 0.849 | 0.797 | 0.790 (-0.007) |
|
||||
AP @[ IoU=0.75 | area= all | maxDets=100 ] | 0.251 | 0.251 | 0.208 | 0.140 (-0.068) |
|
||||
AP @[ IoU=0.50:0.95 | area= small | maxDets=100 ] | 0.050 | 0.051 (+0.001) | 0.107 | 0.070 (-0.037) |
|
||||
AP @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] | 0.381 | 0.379 (-0.002) | 0.380 | 0.368 (-0.012) |
|
||||
AP @[ IoU=0.50:0.95 | area= large | maxDets=100 ] | 0.455 | 0.455 | 0.412 | 0.337 (-0.075) |
|
||||
AR @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] | 0.299 | 0.299 | 0.279 | 0.246 (-0.033) |
|
||||
AR @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] | 0.482 | 0.482 | 0.476 | 0.436 (-0.040) |
|
||||
AR @[ IoU=0.50:0.95 | area= all | maxDets=100 ] | 0.496 | 0.496 | 0.491 | 0.451 (-0.040) |
|
||||
AR @[ IoU=0.50:0.95 | area= small | maxDets=100 ] | 0.189 | 0.193 (+0.004) | 0.284 | 0.232 (-0.052) |
|
||||
AR @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] | 0.481 | 0.480 (-0.001) | 0.470 | 0.458 (-0.012) |
|
||||
AR @[ IoU=0.50:0.95 | area= large | maxDets=100 ] | 0.528 | 0.528 | 0.520 | 0.462 (-0.058) |
|
||||
```
|
||||
|
||||
### Classification
|
||||
| Model | Scale | Size WxH| Mean subtraction | Channels order |
|
||||
|---------------|-------|-----------|--------------------|-------|
|
||||
|
2294
samples/dnn/face_detector/opencv_face_detector.pbtxt
Normal file
2294
samples/dnn/face_detector/opencv_face_detector.pbtxt
Normal file
File diff suppressed because it is too large
Load Diff
@ -70,7 +70,7 @@ function recognize(face) {
|
||||
function loadModels(callback) {
|
||||
var utils = new Utils('');
|
||||
var proto = 'https://raw.githubusercontent.com/opencv/opencv/master/samples/dnn/face_detector/deploy.prototxt';
|
||||
var weights = 'https://github.com/opencv/opencv_3rdparty/raw/19512576c112aa2c7b6328cb0e8d589a4a90a26d/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';
|
||||
utils.createFileFromUrl('face_detector.prototxt', proto, () => {
|
||||
document.getElementById('status').innerHTML = 'Downloading face_detector.caffemodel';
|
||||
|
Loading…
Reference in New Issue
Block a user