Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language: en
|
| 3 |
+
license: apache-2.0
|
| 4 |
+
model_name: version-RFB-320-int8.onnx
|
| 5 |
+
tags:
|
| 6 |
+
- validated
|
| 7 |
+
- vision
|
| 8 |
+
- body_analysis
|
| 9 |
+
- ultraface
|
| 10 |
+
---
|
| 11 |
+
<!--- SPDX-License-Identifier: MIT -->
|
| 12 |
+
|
| 13 |
+
# Ultra-lightweight face detection model
|
| 14 |
+
|
| 15 |
+
## Description
|
| 16 |
+
This model is a lightweight facedetection model designed for edge computing devices.
|
| 17 |
+
|
| 18 |
+
## Model
|
| 19 |
+
| Model | Download | Download (with sample test data) | ONNX version | Opset version |
|
| 20 |
+
| ------------- | ------------- | ------------- | ------------- | ------------- |
|
| 21 |
+
|version-RFB-320| [1.21 MB](models/version-RFB-320.onnx) | [1.92 MB](models/version-RFB-320.tar.gz) | 1.4 | 9 |
|
| 22 |
+
|version-RFB-640| [1.51 MB](models/version-RFB-640.onnx) | [4.59 MB](models/version-RFB-640.tar.gz) | 1.4 | 9 |
|
| 23 |
+
|version-RFB-320-int8| [0.44 MB](models/version-RFB-320-int8.onnx) | [1.2 MB](models/version-RFB-320-int8.tar.gz) | 1.14 | 12 |
|
| 24 |
+
|
| 25 |
+
### Dataset
|
| 26 |
+
The training set is the VOC format data set generated by using the cleaned widerface labels provided by [Retinaface](https://arxiv.org/pdf/1905.00641.pdf) in conjunction with the widerface [dataset](http://shuoyang1213.me/WIDERFACE/).
|
| 27 |
+
|
| 28 |
+
### Source
|
| 29 |
+
You can find the source code [here](https://github.com/Linzaer/Ultra-Light-Fast-Generic-Face-Detector-1MB).
|
| 30 |
+
|
| 31 |
+
### Demo
|
| 32 |
+
Run [demo.py](demo.py) python scripts example.
|
| 33 |
+
|
| 34 |
+
## Inference
|
| 35 |
+
|
| 36 |
+
### Input
|
| 37 |
+
Input tensor is `1 x 3 x height x width` with mean values `127, 127, 127` and scale factor `1.0 / 128`. Input image have to be previously converted to `RGB` format and resized to `320 x 240` pixels for **version-RFB-320** model (or `640 x 480` for **version-RFB-640** model).
|
| 38 |
+
|
| 39 |
+
### Preprocessing
|
| 40 |
+
Given a path `image_path` to the image you would like to score:
|
| 41 |
+
```python
|
| 42 |
+
image = cv2.cvtColor(orig_image, cv2.COLOR_BGR2RGB)
|
| 43 |
+
image = cv2.resize(image, (320, 240))
|
| 44 |
+
image_mean = np.array([127, 127, 127])
|
| 45 |
+
image = (image - image_mean) / 128
|
| 46 |
+
image = np.transpose(image, [2, 0, 1])
|
| 47 |
+
image = np.expand_dims(image, axis=0)
|
| 48 |
+
image = image.astype(np.float32)
|
| 49 |
+
```
|
| 50 |
+
|
| 51 |
+
### Output
|
| 52 |
+
The model outputs two arrays `(1 x 4420 x 2)` and `(1 x 4420 x 4)` of scores and boxes.
|
| 53 |
+
|
| 54 |
+
### Postprocessing
|
| 55 |
+
In postprocessing, threshold filtration and [non-max suppression](dependencies/box_utils.py) are applied to the scores and boxes arrays.
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
## Quantization
|
| 59 |
+
version-RFB-320-int8 is obtained by quantizing fp32 version-RFB-320 model. We use [Intel® Neural Compressor](https://github.com/intel/neural-compressor) with onnxruntime backend to perform quantization. View the [instructions](https://github.com/intel/neural-compressor/blob/master/examples/onnxrt/body_analysis/onnx_model_zoo/ultraface/quantization/ptq_static/README.md) to understand how to use Intel® Neural Compressor for quantization.
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
### Prepare Model
|
| 63 |
+
Download model from [ONNX Model Zoo](https://github.com/onnx/models).
|
| 64 |
+
|
| 65 |
+
```shell
|
| 66 |
+
wget https://github.com/onnx/models/raw/main/vision/body_analysis/ultraface/models/version-RFB-320.onnx
|
| 67 |
+
```
|
| 68 |
+
|
| 69 |
+
Convert opset version to 12 for more quantization capability.
|
| 70 |
+
|
| 71 |
+
```python
|
| 72 |
+
import onnx
|
| 73 |
+
from onnx import version_converter
|
| 74 |
+
model = onnx.load('version-RFB-320.onnx')
|
| 75 |
+
model = version_converter.convert_version(model, 12)
|
| 76 |
+
onnx.save_model(model, 'version-RFB-320-12.onnx')
|
| 77 |
+
```
|
| 78 |
+
|
| 79 |
+
### Model quantize
|
| 80 |
+
|
| 81 |
+
```bash
|
| 82 |
+
cd neural-compressor/examples/onnxrt/body_analysis/onnx_model_zoo/ultraface/quantization/ptq_static
|
| 83 |
+
bash run_tuning.sh --input_model=path/to/model \ # model path as *.onnx
|
| 84 |
+
--dataset_location=/path/to/data \
|
| 85 |
+
--output_model=path/to/save
|
| 86 |
+
```
|
| 87 |
+
|
| 88 |
+
## Contributors
|
| 89 |
+
|
| 90 |
+
* [asiryan](https://github.com/asiryan)
|
| 91 |
+
* [yuwenzho](https://github.com/yuwenzho) (Intel)
|
| 92 |
+
* [ftian1](https://github.com/ftian1) (Intel)
|
| 93 |
+
* [hshen14](https://github.com/hshen14) (Intel)
|
| 94 |
+
|
| 95 |
+
## License
|
| 96 |
+
MIT
|
| 97 |
+
|