File size: 1,934 Bytes
42310ef
 
 
 
83bb178
e7d94f5
83bb178
92ff628
83bb178
62917b7
83bb178
60ba673
 
e7d94f5
 
60ba673
 
 
 
 
42310ef
 
84bf331
 
42310ef
e7d94f5
42310ef
 
 
 
 
e7d94f5
 
 
42310ef
 
84bf331
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
237ca2e
 
 
 
 
 
42310ef
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# YuNet

YuNet is a light-weight, fast and accurate face detection model, which achieves 0.834(AP_easy), 0.824(AP_medium), 0.708(AP_hard) on the WIDER Face validation set.

Notes:

- Model source: [here](https://github.com/ShiqiYu/libfacedetection.train/blob/a61a428929148171b488f024b5d6774f93cdbc13/tasks/task1/onnx/yunet.onnx).
- This model can detect **faces of pixels between around 10x10 to 300x300** due to the training scheme.
- For details on training this model, please visit https://github.com/ShiqiYu/libfacedetection.train.
- This ONNX model has fixed input shape, but OpenCV DNN infers on the exact shape of input image. See https://github.com/opencv/opencv_zoo/issues/44 for more information.

Results of accuracy evaluation with [tools/eval](../../tools/eval).

| Models      | Easy AP | Medium AP | Hard AP |
| ----------- | ------- | --------- | ------- |
| YuNet       | 0.8498  | 0.8384    | 0.7357  |
| YuNet quant | 0.7751  | 0.8145    | 0.7312  |

\*: 'quant' stands for 'quantized'.

## Demo

### Python

Run the following command to try the demo:

```shell
# detect on camera input
python demo.py
# detect on an image
python demo.py --input /path/to/image

# get help regarding various parameters
python demo.py --help
```

### C++

Install latest OpenCV and CMake >= 3.24.0 to get started with:

```shell
# A typical and default installation path of OpenCV is /usr/local
cmake -B build -D OPENCV_INSTALLATION_PATH /path/to/opencv/installation .
cmake --build build

# detect on camera input
./build/demo
# detect on an image
./build/demo -i=/path/to/image
# get help messages
./build/demo -h
```

### Example outputs

![webcam demo](./examples/yunet_demo.gif)

![largest selfie](./examples/largest_selfie.jpg)

## License

All files in this directory are licensed under [MIT License](./LICENSE).

## Reference

- https://github.com/ShiqiYu/libfacedetection
- https://github.com/ShiqiYu/libfacedetection.train