Skip to content

Commit

Permalink
Add script to evaluate face detection by WIDERFace (opencv#70)
Browse files Browse the repository at this point in the history
* Add script to evaluate face detection by WIDERFace

* add the result of YuNet
  • Loading branch information
WanliZhong authored Jul 14, 2022
1 parent 004a627 commit b1b4df4
Show file tree
Hide file tree
Showing 5 changed files with 385 additions and 1 deletion.
9 changes: 9 additions & 0 deletions models/face_detection_yunet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ Notes:
- 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

Run the following command to try the demo:
Expand Down
43 changes: 42 additions & 1 deletion tools/eval/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Make sure you have the following packages installed:

```shell
pip install tqdm
pip install scipy
```

Generally speaking, evaluation can be done with the following command:
Expand All @@ -13,7 +14,8 @@ python eval.py -m model_name -d dataset_name -dr dataset_root_dir
```

Supported datasets:
- [ImageNet](./datasets/imagenet.py)
- [ImageNet](#imagenet)
- [WIDERFace](#widerface)

## ImageNet

Expand Down Expand Up @@ -53,3 +55,42 @@ Run evaluation with the following command:
python eval.py -m mobilenet -d imagenet -dr /path/to/imagenet
```

## WIDERFace

The script is modified based on [WiderFace-Evaluation](https://github.com/wondervictor/WiderFace-Evaluation).

### Prepare data

Please visit http://shuoyang1213.me/WIDERFACE to download the WIDERFace dataset [Validation Images](https://huggingface.co/datasets/wider_face/resolve/main/data/WIDER_val.zip), [Face annotations](http://shuoyang1213.me/WIDERFACE/support/bbx_annotation/wider_face_split.zip) and [eval_tools](http://shuoyang1213.me/WIDERFACE/support/eval_script/eval_tools.zip). Organize files as follow:

```shell
$ tree -L 2 /path/to/widerface
.
├── eval_tools
│   ├── boxoverlap.m
│   ├── evaluation.m
│   ├── ground_truth
│   ├── nms.m
│   ├── norm_score.m
│   ├── plot
│   ├── read_pred.m
│   └── wider_eval.m
├── wider_face_split
│   ├── readme.txt
│   ├── wider_face_test_filelist.txt
│   ├── wider_face_test.mat
│   ├── wider_face_train_bbx_gt.txt
│   ├── wider_face_train.mat
│   ├── wider_face_val_bbx_gt.txt
│   └── wider_face_val.mat
└── WIDER_val
└── images
```

### Evaluation

Run evaluation with the following command:

```shell
python eval.py -m yunet -d widerface -dr /path/to/widerface
```
2 changes: 2 additions & 0 deletions tools/eval/datasets/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from .imagenet import ImageNet
from .widerface import WIDERFace

class Registery:
def __init__(self, name):
Expand All @@ -13,3 +14,4 @@ def register(self, item):

DATASETS = Registery("Datasets")
DATASETS.register(ImageNet)
DATASETS.register(WIDERFace)
Loading

0 comments on commit b1b4df4

Please sign in to comment.